From e634b27fded3acf866e6455fa537f1fdf213f7e1 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 23 Aug 2023 21:58:01 +0200 Subject: [PATCH 01/56] Unify deprecated and casm contract caches. --- bench/internals.rs | 10 +- cli/src/main.rs | 3 +- fuzzer/src/main.rs | 13 +- rpc_state_reader/src/lib.rs | 4 +- src/bin/fibonacci.rs | 20 +- src/bin/invoke.rs | 20 +- src/bin/invoke_with_cachedstate.rs | 14 +- src/execution/execution_entry_point.rs | 1 - src/lib.rs | 63 ++-- src/state/cached_state.rs | 187 ++++-------- src/state/in_memory_state_reader.rs | 45 ++- src/state/mod.rs | 17 +- src/syscalls/deprecated_syscall_handler.rs | 22 +- src/syscalls/deprecated_syscall_response.rs | 4 +- src/testing/erc20.rs | 13 +- src/testing/mod.rs | 14 +- src/testing/state.rs | 20 +- src/transaction/declare.rs | 48 ++- src/transaction/declare_v2.rs | 10 +- src/transaction/deploy.rs | 6 +- src/transaction/deploy_account.rs | 20 +- src/transaction/fee.rs | 4 +- src/transaction/invoke_function.rs | 33 +- src/transaction/l1_handler.rs | 2 +- tests/cairo_1_syscalls.rs | 285 ++++++++++-------- tests/complex_contracts/amm_contracts/amm.rs | 54 +--- .../amm_contracts/amm_proxy.rs | 30 +- tests/complex_contracts/nft/erc721.rs | 84 +----- tests/delegate_call.rs | 13 +- tests/delegate_l1_handler.rs | 13 +- tests/deploy_account.rs | 9 +- tests/fibonacci.rs | 12 +- tests/increase_balance.rs | 8 +- tests/internal_calls.rs | 8 +- tests/internals.rs | 128 ++++---- tests/multi_syscall_test.rs | 9 +- tests/storage.rs | 8 +- tests/syscalls.rs | 104 ++++--- tests/syscalls_errors.rs | 32 +- 39 files changed, 651 insertions(+), 739 deletions(-) diff --git a/bench/internals.rs b/bench/internals.rs index 075f216a2..ea6906013 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -17,7 +17,7 @@ use starknet_in_rust::{ transaction::{declare::Declare, Deploy, DeployAccount, InvokeFunction}, utils::Address, }; -use std::{hint::black_box, sync::Arc}; +use std::{collections::HashMap, hint::black_box, sync::Arc}; lazy_static! { // include_str! doesn't seem to work in CI @@ -61,7 +61,7 @@ fn deploy_account() { const RUNS: usize = 500; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); state .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) @@ -97,7 +97,7 @@ fn declare() { const RUNS: usize = 5; let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Some(Default::default()), None); + let state = CachedState::new(state_reader, HashMap::new()); let block_context = &Default::default(); @@ -129,7 +129,7 @@ fn deploy() { const RUNS: usize = 8; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); state .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) @@ -164,7 +164,7 @@ fn invoke() { const RUNS: usize = 100; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); state .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) diff --git a/cli/src/main.rs b/cli/src/main.rs index f37bdf544..bc9e0d6bc 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -313,8 +313,7 @@ pub async fn start_devnet(port: u16) -> Result<(), std::io::Error> { let cached_state = web::Data::new(AppState { cached_state: Mutex::new(CachedState::::new( Arc::new(InMemoryStateReader::default()), - Some(HashMap::new()), - None, + HashMap::new(), )), }); diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index edbfb1cf5..2b14e11b4 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -25,6 +25,7 @@ use std::{ path::PathBuf, }; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; use std::fs; use std::process::Command; use std::thread; @@ -44,11 +45,11 @@ fn main() { let file_content1 = " %lang starknet from starkware.cairo.common.cairo_builtins import HashBuiltin - + @storage_var func _counter() -> (res: felt) { } - + @external func write_and_read{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}() -> (res:felt) { _counter.write('"; @@ -116,7 +117,10 @@ fn main() { let address = Address(1111.into()); let class_hash = [1; 32]; - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -126,8 +130,7 @@ fn main() { //* Create state with previous data //* --------------------------------------- - let mut state = - CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* ------------------------------------ //* Create execution entry point diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 280f14aa0..254b26b00 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -741,7 +741,7 @@ mod transaction_tests { felt::felt_str, state::cached_state::CachedState, }; - use std::sync::Arc; + use std::{collections::HashMap, sync::Arc}; fn test_tx( tx_hash: &str, @@ -754,7 +754,7 @@ mod transaction_tests { // Instantiate the RPC StateReader and the CachedState let block = BlockValue::Number(serde_json::to_value(block_number).unwrap()); let rpc_state = Arc::new(RpcState::new(network, block)); - let mut state = CachedState::new(rpc_state.clone(), None, None); + let mut state = CachedState::new(rpc_state.clone(), HashMap::new()); let fee_token_address = Address(felt_str!( "049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", diff --git a/src/bin/fibonacci.rs b/src/bin/fibonacci.rs index b14be188a..df61410cf 100644 --- a/src/bin/fibonacci.rs +++ b/src/bin/fibonacci.rs @@ -5,9 +5,13 @@ use num_traits::Zero; use lazy_static::lazy_static; use starknet_in_rust::{ - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, - testing::state::StarknetState, utils::Address, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::cached_state::CachedState, + state::in_memory_state_reader::InMemoryStateReader, + testing::state::StarknetState, + utils::Address, }; #[cfg(feature = "with_mimalloc")] @@ -78,17 +82,17 @@ fn create_initial_state() -> CachedState { state_reader .address_to_nonce_mut() .insert(CONTRACT_ADDRESS.clone(), Felt252::zero()); - state_reader - .class_hash_to_contract_class_mut() - .insert(*CONTRACT_CLASS_HASH, CONTRACT_CLASS.clone()); + state_reader.class_hash_to_compiled_class_mut().insert( + *CONTRACT_CLASS_HASH, + CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ); state_reader .address_to_storage_mut() .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - Some(HashMap::new()), - None, + HashMap::new(), ); cached_state diff --git a/src/bin/invoke.rs b/src/bin/invoke.rs index afec929fa..f29a78ad0 100644 --- a/src/bin/invoke.rs +++ b/src/bin/invoke.rs @@ -4,9 +4,13 @@ use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; use starknet_in_rust::{ - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, - testing::state::StarknetState, utils::Address, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::cached_state::CachedState, + state::in_memory_state_reader::InMemoryStateReader, + testing::state::StarknetState, + utils::Address, }; use lazy_static::lazy_static; @@ -92,17 +96,17 @@ fn create_initial_state() -> CachedState { state_reader .address_to_nonce_mut() .insert(CONTRACT_ADDRESS.clone(), Felt252::zero()); - state_reader - .class_hash_to_contract_class_mut() - .insert(*CONTRACT_CLASS_HASH, CONTRACT_CLASS.clone()); + state_reader.class_hash_to_compiled_class_mut().insert( + *CONTRACT_CLASS_HASH, + CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ); state_reader .address_to_storage_mut() .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - Some(HashMap::new()), - None, + HashMap::new(), ); cached_state diff --git a/src/bin/invoke_with_cachedstate.rs b/src/bin/invoke_with_cachedstate.rs index e5c7cac2f..4868a0ab4 100644 --- a/src/bin/invoke_with_cachedstate.rs +++ b/src/bin/invoke_with_cachedstate.rs @@ -8,7 +8,9 @@ use starknet_in_rust::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, constants::TRANSACTION_VERSION, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::in_memory_state_reader::InMemoryStateReader, state::{cached_state::CachedState, BlockInfo}, transaction::InvokeFunction, @@ -99,17 +101,17 @@ fn create_initial_state() -> CachedState { state_reader .address_to_nonce_mut() .insert(CONTRACT_ADDRESS.clone(), Felt252::zero()); - state_reader - .class_hash_to_contract_class_mut() - .insert(*CONTRACT_CLASS_HASH, CONTRACT_CLASS.clone()); + state_reader.class_hash_to_compiled_class_mut().insert( + *CONTRACT_CLASS_HASH, + CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ); state_reader .address_to_storage_mut() .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - Some(HashMap::new()), - None, + HashMap::new(), ); cached_state diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 554463471..1b6d33870 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -131,7 +131,6 @@ impl ExecutionEntryPoint { let mut tmp_state = CachedState::new( state.state_reader.clone(), state.contract_classes.clone(), - state.casm_contract_classes.clone(), ); tmp_state.cache = state.cache.clone(); diff --git a/src/lib.rs b/src/lib.rs index 6dc8c24fa..42677df79 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,7 +61,7 @@ pub fn simulate_transaction( ignore_max_fee: bool, skip_nonce_check: bool, ) -> Result, TransactionError> { - let mut cache_state = CachedState::new(Arc::new(state), None, Some(HashMap::new())); + let mut cache_state = CachedState::new(Arc::new(state), HashMap::new()); let mut result = Vec::with_capacity(transactions.len()); for transaction in transactions { let tx_for_simulation = transaction.create_for_simulation( @@ -89,7 +89,7 @@ where T: StateReader, { // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = CachedState::::new(Arc::new(state), None, None); + let mut cached_state = CachedState::::new(Arc::new(state), HashMap::new()); let mut result = Vec::with_capacity(transactions.len()); for transaction in transactions { @@ -177,7 +177,7 @@ where T: StateReader, { // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = CachedState::::new(Arc::new(state), None, None); + let mut cached_state = CachedState::::new(Arc::new(state), HashMap::new()); // Check if the contract is deployed. cached_state.get_class_hash_at(l1_handler.contract_address())?; @@ -251,6 +251,7 @@ mod test { utils::{Address, ClassHash}, }; + use crate::services::api::contract_classes::compiled_class::CompiledClass; use lazy_static::lazy_static; lazy_static! { @@ -317,7 +318,7 @@ mod test { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -326,7 +327,7 @@ mod test { .address_to_nonce_mut() .insert(address.clone(), nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let retdata = call_contract( @@ -378,10 +379,13 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes - let contract_classes = HashMap::from([(class_hash, contract_class)]); + let contract_classes = HashMap::from([( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + )]); state.set_contract_classes(contract_classes).unwrap(); let mut block_context = BlockContext::default(); @@ -407,7 +411,8 @@ mod test { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -416,7 +421,7 @@ mod test { .address_to_nonce_mut() .insert(address.clone(), nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let invoke = InvokeFunction::new( @@ -483,9 +488,10 @@ mod test { .insert(address.clone(), nonce); // simulate deploy - state_reader - .class_hash_to_contract_class_mut() - .insert(acc_class_hash, contract_class); + state_reader.class_hash_to_compiled_class_mut().insert( + acc_class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let hash = felt_str!( "134328839377938040543570691566621575472567895629741043448357033688476792132" @@ -494,9 +500,10 @@ mod test { state_reader .class_hash_to_compiled_class_hash_mut() .insert(fib_address, class_hash); - state_reader - .casm_contract_classes - .insert(fib_address, casm_contract_class); + state_reader.class_hash_to_compiled_class.insert( + fib_address, + CompiledClass::Casm(Arc::new(casm_contract_class)), + ); let calldata = [ address.0.clone(), @@ -610,9 +617,10 @@ mod test { .insert(address.clone(), nonce); // simulate deploy - state_reader - .class_hash_to_contract_class_mut() - .insert(acc_class_hash, contract_class); + state_reader.class_hash_to_compiled_class_mut().insert( + acc_class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let hash = felt_str!( "134328839377938040543570691566621575472567895629741043448357033688476792132" @@ -621,9 +629,10 @@ mod test { state_reader .class_hash_to_compiled_class_hash_mut() .insert(fib_address, class_hash); - state_reader - .casm_contract_classes - .insert(fib_address, casm_contract_class); + state_reader.class_hash_to_compiled_class.insert( + fib_address, + CompiledClass::Casm(Arc::new(casm_contract_class)), + ); let calldata = [ address.0.clone(), @@ -672,7 +681,7 @@ mod test { #[test] fn test_simulate_deploy() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); state .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) @@ -711,7 +720,7 @@ mod test { #[test] fn test_simulate_declare() { let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Some(Default::default()), None); + let state = CachedState::new(state_reader, HashMap::new()); let block_context = &Default::default(); @@ -748,7 +757,7 @@ mod test { #[test] fn test_simulate_invoke() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); state .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) @@ -809,7 +818,7 @@ mod test { #[test] fn test_simulate_deploy_account() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); state .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) @@ -930,7 +939,7 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -959,7 +968,7 @@ mod test { #[test] fn test_deploy_and_invoke_simulation() { let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Some(Default::default()), None); + let state = CachedState::new(state_reader, HashMap::new()); let block_context = &Default::default(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 8b2298de8..350877bd6 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -19,11 +19,7 @@ use std::{ sync::Arc, }; -// K: class_hash V: ContractClass -pub type ContractClassCache = HashMap; -pub type CasmClassCache = HashMap; - -pub const UNINITIALIZED_CLASS_HASH: &ClassHash = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; +pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; /// Represents a cached state of contract classes with optional caches. #[derive(Default, Clone, Debug, Eq, Getters, MutGetters, PartialEq)] @@ -32,60 +28,51 @@ pub struct CachedState { #[getset(get = "pub", get_mut = "pub")] pub(crate) cache: StateCache, #[get = "pub"] - pub(crate) contract_classes: Option, - #[get = "pub"] - pub(crate) casm_contract_classes: Option, + pub(crate) contract_classes: HashMap, } impl CachedState { /// Constructor, creates a new cached state. - pub fn new( - state_reader: Arc, - contract_class_cache: Option, - casm_class_cache: Option, - ) -> Self { + pub fn new(state_reader: Arc, contract_classes: HashMap) -> Self { Self { cache: StateCache::default(), - contract_classes: contract_class_cache, state_reader, - casm_contract_classes: casm_class_cache, + contract_classes, } } /// Creates a CachedState for testing purposes. pub fn new_for_testing( state_reader: Arc, - contract_classes: Option, cache: StateCache, - casm_contract_classes: Option, + contract_classes: HashMap, ) -> Self { Self { cache, contract_classes, state_reader, - casm_contract_classes, } } /// Sets the contract classes cache. pub fn set_contract_classes( &mut self, - contract_classes: ContractClassCache, + contract_classes: HashMap, ) -> Result<(), StateError> { - if self.contract_classes.is_some() { + if !self.contract_classes.is_empty() { return Err(StateError::AssignedContractClassCache); } - self.contract_classes = Some(contract_classes); + self.contract_classes = contract_classes; Ok(()) } - /// Returns the casm classes. - #[allow(dead_code)] - pub(crate) fn get_casm_classes(&mut self) -> Result<&CasmClassCache, StateError> { - self.casm_contract_classes - .as_ref() - .ok_or(StateError::MissingCasmClassCache) - } + // /// Returns the casm classes. + // #[allow(dead_code)] + // pub(crate) fn get_casm_classes(&mut self) -> Result<&CasmClassCache, StateError> { + // self.casm_contract_classes + // .as_ref() + // .ok_or(StateError::MissingCasmClassCache) + // } } impl StateReader for CachedState { @@ -172,37 +159,24 @@ impl StateReader for CachedState { if class_hash == UNINITIALIZED_CLASS_HASH { return Err(StateError::UninitiaizedClassHash); } + // I: FETCHING FROM CACHE - // I: DEPRECATED CONTRACT CLASS - // deprecated contract classes dont have compiled class hashes, so we only have one case - if let Some(compiled_class) = self - .contract_classes - .as_ref() - .and_then(|x| x.get(class_hash)) - { - return Ok(CompiledClass::Deprecated(Arc::new(compiled_class.clone()))); - } - // I: CASM CONTRACT CLASS : COMPILED_CLASS_HASH - if let Some(compiled_class) = self - .casm_contract_classes - .as_ref() - .and_then(|x| x.get(class_hash)) - { - return Ok(CompiledClass::Casm(Arc::new(compiled_class.clone()))); + if let Some(compiled_class) = self.contract_classes.get(class_hash) { + return Ok(compiled_class.clone()); } + // I: CASM CONTRACT CLASS : CLASS_HASH if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = &mut self - .casm_contract_classes - .as_ref() - .and_then(|m| m.get(compiled_class_hash)) - { - return Ok(CompiledClass::Casm(Arc::new(casm_class.clone()))); + if let Some(casm_class) = self.contract_classes.get(compiled_class_hash) { + return Ok(casm_class.clone()); } } + // II: FETCHING FROM STATE_READER + // TODO: Should this modify the cache? + // TODO: Related: Isn't this exact method available in `impl State for CachedState`? self.state_reader.get_contract_class(class_hash) } } @@ -214,15 +188,13 @@ impl State for CachedState { class_hash: &ClassHash, contract_class: &ContractClass, ) -> Result<(), StateError> { - match self.contract_classes.as_mut() { - Some(x) => { - x.insert(*class_hash, contract_class.clone()); - } - None => { - self.contract_classes = Some(HashMap::new()); - self.set_contract_class(class_hash, contract_class)?; - } - } + // TODO: Could this method's signature use `CompiledClass` instead of `ContractClass`? Or + // even better, could the entire trait use `Arc`? + self.contract_classes.insert( + *class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); + Ok(()) } @@ -291,11 +263,11 @@ impl State for CachedState { casm_class: CasmContractClass, ) -> Result<(), StateError> { let compiled_class_hash = compiled_class_hash.to_be_bytes(); + self.contract_classes.insert( + compiled_class_hash, + CompiledClass::Casm(Arc::new(casm_class)), + ); - self.casm_contract_classes - .as_mut() - .ok_or(StateError::MissingCasmClassCache)? - .insert(compiled_class_hash, casm_class); Ok(()) } @@ -437,45 +409,32 @@ impl State for CachedState { if class_hash == UNINITIALIZED_CLASS_HASH { return Err(StateError::UninitiaizedClassHash); } + // I: FETCHING FROM CACHE - // I: DEPRECATED CONTRACT CLASS // deprecated contract classes dont have compiled class hashes, so we only have one case - if let Some(compiled_class) = self - .contract_classes - .as_ref() - .and_then(|x| x.get(class_hash)) - { - return Ok(CompiledClass::Deprecated(Arc::new(compiled_class.clone()))); - } - // I: CASM CONTRACT CLASS : COMPILED_CLASS_HASH - if let Some(compiled_class) = self - .casm_contract_classes - .as_ref() - .and_then(|x| x.get(class_hash)) - { - return Ok(CompiledClass::Casm(Arc::new(compiled_class.clone()))); + if let Some(compiled_class) = self.contract_classes.get(class_hash) { + return Ok(compiled_class.clone()); } + // I: CASM CONTRACT CLASS : CLASS_HASH if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = &mut self - .casm_contract_classes - .as_ref() - .and_then(|m| m.get(compiled_class_hash)) - { - return Ok(CompiledClass::Casm(Arc::new(casm_class.clone()))); + if let Some(casm_class) = self.contract_classes.get(compiled_class_hash) { + return Ok(casm_class.clone()); } } + // II: FETCHING FROM STATE_READER let contract = self.state_reader.get_contract_class(class_hash)?; match contract { - CompiledClass::Casm(ref class) => { + CompiledClass::Casm(ref casm_class) => { // We call this method instead of state_reader's in order to update the cache's class_hash_initial_values map let compiled_class_hash = self.get_compiled_class_hash(class_hash)?; - self.casm_contract_classes - .as_mut() - .and_then(|m| m.insert(compiled_class_hash, class.as_ref().clone())); + self.set_compiled_class( + &Felt252::from_bytes_be(&compiled_class_hash), + casm_class.as_ref().clone(), + )?; } CompiledClass::Deprecated(ref contract) => { self.set_contract_class(class_hash, &contract.clone())? @@ -503,7 +462,6 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_address = Address(4242.into()); @@ -522,7 +480,7 @@ mod tests { .address_to_storage_mut() .insert(storage_entry, storage_value); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); assert_eq!( cached_state.get_class_hash_at(&contract_address).unwrap(), @@ -545,20 +503,18 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_class = ContractClass::from_path("starknet_programs/raw_contract_classes/class_with_abi.json") .unwrap(); state_reader - .class_hash_to_contract_class - .insert([1; 32], contract_class); + .class_hash_to_compiled_class + .insert([1; 32], CompiledClass::Deprecated(Arc::new(contract_class))); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); cached_state.set_contract_classes(HashMap::new()).unwrap(); - assert!(cached_state.contract_classes.is_some()); assert_eq!( cached_state.get_contract_class(&[1; 32]).unwrap(), @@ -573,7 +529,7 @@ mod tests { #[test] fn cached_state_storage_test() { let mut cached_state = - CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let storage_entry: StorageEntry = (Address(31.into()), [0; 32]); let value = Felt252::new(10); @@ -595,7 +551,7 @@ mod tests { let contract_address = Address(32123.into()); - let mut cached_state = CachedState::new(state_reader, None, None); + let mut cached_state = CachedState::new(state_reader, HashMap::new()); assert!(cached_state .deploy_contract(contract_address, [10; 32]) @@ -611,7 +567,7 @@ mod tests { let storage_key = [18; 32]; let value = Felt252::new(912); - let mut cached_state = CachedState::new(state_reader, None, None); + let mut cached_state = CachedState::new(state_reader, HashMap::new()); // set storage_key cached_state.set_storage_at(&(contract_address.clone(), storage_key), value.clone()); @@ -629,27 +585,6 @@ mod tests { assert_eq!(new_result.unwrap(), new_value); } - /// This test ensures that an error is thrown when trying to set contract classes twice. - #[test] - fn set_contract_classes_twice_error_test() { - let state_reader = InMemoryStateReader::new( - HashMap::new(), - HashMap::new(), - HashMap::new(), - HashMap::new(), - HashMap::new(), - HashMap::new(), - ); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); - - cached_state.set_contract_classes(HashMap::new()).unwrap(); - let result = cached_state - .set_contract_classes(HashMap::new()) - .unwrap_err(); - - assert_matches!(result, StateError::AssignedContractClassCache); - } - /// This test ensures that an error is thrown if a contract address is out of range. #[test] fn deploy_contract_address_out_of_range_error_test() { @@ -659,12 +594,11 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_address = Address(0.into()); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); let result = cached_state .deploy_contract(contract_address.clone(), [10; 32]) @@ -685,12 +619,11 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_address = Address(42.into()); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); cached_state .deploy_contract(contract_address.clone(), [10; 32]) @@ -714,12 +647,11 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_address = Address(32123.into()); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); cached_state .deploy_contract(contract_address.clone(), [10; 32]) @@ -744,12 +676,11 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let address_one = Address(Felt252::one()); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); let state_diff = StateDiff { address_to_class_hash: HashMap::from([( @@ -784,7 +715,7 @@ mod tests { #[test] fn count_actual_storage_changes_test() { let state_reader = InMemoryStateReader::default(); - let mut cached_state = CachedState::new(Arc::new(state_reader), None, None); + let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); let address_one = Address(1.into()); let address_two = Address(2.into()); diff --git a/src/state/in_memory_state_reader.rs b/src/state/in_memory_state_reader.rs index de9b3e827..7a7f1c372 100644 --- a/src/state/in_memory_state_reader.rs +++ b/src/state/in_memory_state_reader.rs @@ -1,19 +1,15 @@ use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, + services::api::contract_classes::compiled_class::CompiledClass, state::{ - cached_state::{CasmClassCache, UNINITIALIZED_CLASS_HASH}, - state_api::StateReader, - state_cache::StorageEntry, + cached_state::UNINITIALIZED_CLASS_HASH, state_api::StateReader, state_cache::StorageEntry, }, utils::{Address, ClassHash, CompiledClassHash}, }; use cairo_vm::felt::Felt252; use getset::{Getters, MutGetters}; use num_traits::Zero; -use std::{collections::HashMap, sync::Arc}; +use std::collections::HashMap; /// A [StateReader] that holds all the data in memory. /// @@ -28,9 +24,7 @@ pub struct InMemoryStateReader { #[getset(get_mut = "pub")] pub address_to_storage: HashMap, #[getset(get_mut = "pub")] - pub class_hash_to_contract_class: HashMap, - #[getset(get_mut = "pub")] - pub(crate) casm_contract_classes: CasmClassCache, + pub class_hash_to_compiled_class: HashMap, #[getset(get_mut = "pub")] pub(crate) class_hash_to_compiled_class_hash: HashMap, } @@ -49,16 +43,14 @@ impl InMemoryStateReader { address_to_class_hash: HashMap, address_to_nonce: HashMap, address_to_storage: HashMap, - class_hash_to_contract_class: HashMap, - casm_contract_classes: CasmClassCache, + class_hash_to_compiled_class: HashMap, class_hash_to_compiled_class_hash: HashMap, ) -> Self { Self { address_to_class_hash, address_to_nonce, address_to_storage, - class_hash_to_contract_class, - casm_contract_classes, + class_hash_to_compiled_class, class_hash_to_compiled_class_hash, } } @@ -79,13 +71,10 @@ impl InMemoryStateReader { &self, compiled_class_hash: &CompiledClassHash, ) -> Result { - if let Some(compiled_class) = self.casm_contract_classes.get(compiled_class_hash) { - return Ok(CompiledClass::Casm(Arc::new(compiled_class.clone()))); + match self.class_hash_to_compiled_class.get(compiled_class_hash) { + Some(compiled_class) => Ok(compiled_class.clone()), + None => Err(StateError::NoneCompiledClass(*compiled_class_hash)), } - if let Some(compiled_class) = self.class_hash_to_contract_class.get(compiled_class_hash) { - return Ok(CompiledClass::Deprecated(Arc::new(compiled_class.clone()))); - } - Err(StateError::NoneCompiledClass(*compiled_class_hash)) } } @@ -127,9 +116,10 @@ impl StateReader for InMemoryStateReader { fn get_contract_class(&self, class_hash: &ClassHash) -> Result { // Deprecated contract classes dont have a compiled_class_hash, we dont need to fetch it - if let Some(compiled_class) = self.class_hash_to_contract_class.get(class_hash) { - return Ok(CompiledClass::Deprecated(Arc::new(compiled_class.clone()))); + if let Some(compiled_class) = self.class_hash_to_compiled_class.get(class_hash) { + return Ok(compiled_class.clone()); } + let compiled_class_hash = self.get_compiled_class_hash(class_hash)?; if compiled_class_hash != *UNINITIALIZED_CLASS_HASH { let compiled_class = self.get_compiled_class(&compiled_class_hash)?; @@ -143,6 +133,8 @@ impl StateReader for InMemoryStateReader { #[cfg(test)] mod tests { use super::*; + use crate::services::api::contract_classes::deprecated_contract_class::ContractClass; + use std::sync::Arc; #[test] fn get_contract_state_test() { @@ -152,7 +144,6 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_address = Address(37810.into()); @@ -190,7 +181,6 @@ mod tests { HashMap::new(), HashMap::new(), HashMap::new(), - HashMap::new(), ); let contract_class_key = [0; 32]; @@ -198,9 +188,10 @@ mod tests { ContractClass::from_path("starknet_programs/raw_contract_classes/class_with_abi.json") .unwrap(); - state_reader - .class_hash_to_contract_class - .insert([0; 32], contract_class.clone()); + state_reader.class_hash_to_compiled_class.insert( + [0; 32], + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); assert_eq!( state_reader .get_contract_class(&contract_class_key) diff --git a/src/state/mod.rs b/src/state/mod.rs index 8b6ace0cc..3920165a8 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -166,7 +166,7 @@ impl StateDiff { where T: StateReader + Clone, { - let mut cache_state = CachedState::new(state_reader, None, None); + let mut cache_state = CachedState::new(state_reader, HashMap::new()); let cache_storage_mapping = to_cache_state_storage_mapping(&self.storage_updates); cache_state.cache_mut().set_initial_values( @@ -240,7 +240,7 @@ mod test { use crate::{ state::in_memory_state_reader::InMemoryStateReader, state::{ - cached_state::{CachedState, ContractClassCache}, + cached_state::CachedState, state_api::StateReader, state_cache::{StateCache, StorageEntry}, }, @@ -263,7 +263,7 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let cached_state = CachedState::new(Arc::new(state_reader), None, None); + let cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); let diff = StateDiff::from_cached_state(cached_state).unwrap(); @@ -323,7 +323,8 @@ mod test { .address_to_nonce .insert(contract_address.clone(), nonce); - let cached_state_original = CachedState::new(Arc::new(state_reader.clone()), None, None); + let cached_state_original = + CachedState::new(Arc::new(state_reader.clone()), HashMap::new()); let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); @@ -370,12 +371,8 @@ mod test { storage_writes, HashMap::new(), ); - let cached_state = CachedState::new_for_testing( - Arc::new(state_reader), - Some(ContractClassCache::new()), - cache, - None, - ); + let cached_state = + CachedState::new_for_testing(Arc::new(state_reader), cache, HashMap::new()); let mut diff = StateDiff::from_cached_state(cached_state).unwrap(); diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index d131d5ff1..fb9b38c1a 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -730,7 +730,7 @@ mod tests { ] ); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -766,7 +766,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_CONTRACT_ADDRESS.to_string(), ids_data); // invoke syscall - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -808,7 +808,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_TX_SIGNATURE.to_string(), ids_data); // invoke syscall - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -847,7 +847,7 @@ mod tests { ); } - /// Tests the correct behavior of a storage read operation within a blockchain. + /// Tests the correct behavior of a storage read operation within a blockchain. #[test] fn test_bl_storage_read_hint_ok() { let mut vm = vm!(); @@ -876,7 +876,7 @@ mod tests { let hint_data = HintProcessorData::new_default(STORAGE_READ.to_string(), ids_data); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -911,7 +911,7 @@ mod tests { assert_matches!(get_big_int(&vm, relocatable!(2, 2)), Ok(response) if response == storage_value ); } - /// Tests the correct behavior of a storage write operation within a blockchain. + /// Tests the correct behavior of a storage write operation within a blockchain. #[test] fn test_bl_storage_write_hint_ok() { let mut vm = vm!(); @@ -941,7 +941,7 @@ mod tests { let hint_data = HintProcessorData::new_default(STORAGE_WRITE.to_string(), ids_data); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -980,7 +980,7 @@ mod tests { assert_eq!(write, Felt252::new(45)); } - /// Tests the correct behavior of a deploy operation within a blockchain. + /// Tests the correct behavior of a deploy operation within a blockchain. #[test] fn test_bl_deploy_ok() { let mut vm = vm!(); @@ -1015,7 +1015,7 @@ mod tests { let hint_data = HintProcessorData::new_default(DEPLOY.to_string(), ids_data); // Create SyscallHintProcessor - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -1071,7 +1071,7 @@ mod tests { ); } - /// Tests the correct behavior of a storage deploy and invoke operations within a blockchain. + /// Tests the correct behavior of a storage deploy and invoke operations within a blockchain. #[test] fn test_deploy_and_invoke() { /* @@ -1113,7 +1113,7 @@ mod tests { ); // Create SyscallHintProcessor - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), diff --git a/src/syscalls/deprecated_syscall_response.rs b/src/syscalls/deprecated_syscall_response.rs index 85e3e9cc1..bc7d3523f 100644 --- a/src/syscalls/deprecated_syscall_response.rs +++ b/src/syscalls/deprecated_syscall_response.rs @@ -309,7 +309,7 @@ impl DeprecatedWriteSyscallResponse for DeprecatedStorageReadResponse { #[cfg(test)] mod tests { - use std::sync::Arc; + use std::{collections::HashMap, sync::Arc}; use super::*; use crate::{ @@ -330,7 +330,7 @@ mod tests { #[test] fn write_get_caller_address_response() { // Initialize a VM and syscall handler - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index eab540352..717097e53 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -10,7 +10,9 @@ use crate::{ execution::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{ cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, @@ -58,8 +60,11 @@ fn test_erc20_cairo2() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); - contract_class_cache.insert(erc20_class_hash, test_contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.insert( + erc20_class_hash, + CompiledClass::Casm(Arc::new(test_contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -70,7 +75,7 @@ fn test_erc20_cairo2() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let name_ = Felt252::from_bytes_be(b"some-token"); let symbol_ = Felt252::from_bytes_be(b"my-super-awesome-token"); diff --git a/src/testing/mod.rs b/src/testing/mod.rs index 7772aae10..018082643 100644 --- a/src/testing/mod.rs +++ b/src/testing/mod.rs @@ -14,7 +14,9 @@ use crate::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, constants::DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{ cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, state_cache::StorageEntry, BlockInfo, @@ -149,14 +151,14 @@ pub fn create_account_tx_test_state( state_reader.address_to_storage_mut().extend(stored); } for (class_hash, contract_class) in class_hash_to_class { - state_reader - .class_hash_to_contract_class_mut() - .insert(class_hash, contract_class); + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); } Arc::new(state_reader) }, - Some(HashMap::new()), - Some(HashMap::new()), + HashMap::new(), ); Ok((block_context, cached_state)) diff --git a/src/testing/state.rs b/src/testing/state.rs index 28c1ef84a..a16bf66fe 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -40,7 +40,7 @@ impl StarknetState { let block_context = context.unwrap_or_default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Some(HashMap::new()), Some(HashMap::new())); + let state = CachedState::new(state_reader, HashMap::new()); let l2_to_l1_messages = HashMap::new(); let l2_to_l1_messages_log = Vec::new(); @@ -330,6 +330,7 @@ mod tests { }, execution::{CallType, OrderedL2ToL1Message}, hash_utils::calculate_contract_address, + services::api::contract_classes::compiled_class::CompiledClass, state::state_cache::StorageEntry, utils::{calculate_sn_keccak, felt_to_hash}, }; @@ -399,11 +400,10 @@ mod tests { starknet_state .state .contract_classes - .unwrap() .get(&class_hash) .unwrap() .to_owned(), - contract_class + CompiledClass::Deprecated(Arc::new(contract_class)) ); } @@ -419,7 +419,10 @@ mod tests { // hack store account contract let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class.clone()); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); // store sender_address let sender_address = Address(1.into()); @@ -440,11 +443,12 @@ mod tests { state_reader .address_to_storage_mut() .insert(storage_entry.clone(), storage.clone()); - state_reader - .class_hash_to_contract_class_mut() - .insert(class_hash, contract_class.clone()); + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); - let state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* -------------------------------------------- //* Create starknet state with previous data diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index abb20c0b7..b7bce7833 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -332,7 +332,9 @@ mod tests { transaction_type::TransactionType, }, execution::CallType, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, utils::{felt_to_hash, Address}, @@ -353,7 +355,10 @@ mod tests { let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = hash.to_be_bytes(); - contract_class_cache.insert(class_hash, contract_class.clone()); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); // store sender_address let sender_address = Address(1.into()); @@ -369,7 +374,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let mut state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* --------------------------------------- //* Test declare with previous data @@ -510,7 +515,10 @@ mod tests { let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); // store sender_address let sender_address = Address(1.into()); @@ -526,7 +534,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let _state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* --------------------------------------- //* Test declare with previous data @@ -573,7 +581,10 @@ mod tests { let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); // store sender_address let sender_address = Address(1.into()); @@ -589,7 +600,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let _state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* --------------------------------------- //* Test declare with previous data @@ -635,7 +646,10 @@ mod tests { let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); // store sender_address let sender_address = Address(1.into()); @@ -651,7 +665,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* --------------------------------------- //* Test declare with previous data @@ -711,7 +725,10 @@ mod tests { let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); // store sender_address let sender_address = Address(1.into()); @@ -727,7 +744,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* --------------------------------------- //* Test declare with previous data @@ -774,7 +791,7 @@ mod tests { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(contract_class_cache), None); + let mut state = CachedState::new(state_reader, contract_class_cache); // There are no account contracts in the state, so the transaction should fail let fib_contract_class = @@ -815,7 +832,10 @@ mod tests { let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); // store sender_address let sender_address = Address(1.into()); @@ -831,7 +851,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* --------------------------------------- //* Test declare with previous data diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 0b80174c5..406e4b50c 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -510,7 +510,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, None, Some(casm_contract_class_cache)); + let mut state = CachedState::new(state_reader, casm_contract_class_cache); // call compile and store assert!(internal_declare @@ -579,7 +579,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, None, Some(casm_contract_class_cache)); + let mut state = CachedState::new(state_reader, casm_contract_class_cache); // call compile and store assert!(internal_declare @@ -650,7 +650,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, None, Some(casm_contract_class_cache)); + let mut state = CachedState::new(state_reader, casm_contract_class_cache); // call compile and store assert!(internal_declare @@ -719,7 +719,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, None, Some(casm_contract_class_cache)); + let mut state = CachedState::new(state_reader, casm_contract_class_cache); // call compile and store assert!(internal_declare @@ -789,7 +789,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, None, Some(casm_contract_class_cache)); + let mut state = CachedState::new(state_reader, casm_contract_class_cache); let expected_err = format!( "Invalid compiled class, expected class hash: {}, but received: {}", diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index 23606ca65..c6132445c 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -328,7 +328,7 @@ mod tests { fn invoke_constructor_test() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); // Set contract_class let contract_class = @@ -376,7 +376,7 @@ mod tests { fn invoke_constructor_no_calldata_should_fail() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); let contract_class = ContractClass::from_path("starknet_programs/constructor.json").unwrap(); @@ -402,7 +402,7 @@ mod tests { fn deploy_contract_without_constructor_should_fail() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Some(Default::default()), None); + let mut state = CachedState::new(state_reader, HashMap::new()); let contract_path = "starknet_programs/amm.json"; let contract_class = ContractClass::from_path(contract_path).unwrap(); diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index 2833004e1..1a048d450 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -385,7 +385,7 @@ impl DeployAccount { #[cfg(test)] mod tests { - use std::{path::PathBuf, sync::Arc}; + use std::{collections::HashMap, path::PathBuf, sync::Arc}; use super::*; use crate::{ @@ -406,11 +406,7 @@ mod tests { let class_hash = felt_to_hash(&hash); let block_context = BlockContext::default(); - let mut _state = CachedState::new( - Arc::new(InMemoryStateReader::default()), - Some(Default::default()), - None, - ); + let mut _state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let internal_deploy = DeployAccount::new( class_hash, @@ -442,11 +438,7 @@ mod tests { let class_hash = felt_to_hash(&hash); let block_context = BlockContext::default(); - let mut state = CachedState::new( - Arc::new(InMemoryStateReader::default()), - Some(Default::default()), - None, - ); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let internal_deploy = DeployAccount::new( class_hash, @@ -494,11 +486,7 @@ mod tests { let class_hash = felt_to_hash(&hash); let block_context = BlockContext::default(); - let mut state = CachedState::new( - Arc::new(InMemoryStateReader::default()), - Some(Default::default()), - None, - ); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let internal_deploy = DeployAccount::new( class_hash, diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 12d9ec686..818c62a54 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -196,7 +196,7 @@ mod tests { #[test] fn test_charge_fee_v0_actual_fee_exceeds_max_fee_should_return_error() { - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut tx_execution_context = TransactionExecutionContext::default(); let mut block_context = BlockContext::default(); block_context.starknet_os_config.gas_price = 1; @@ -222,7 +222,7 @@ mod tests { #[test] fn test_charge_fee_v1_actual_fee_exceeds_max_fee_should_return_error() { - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), None, None); + let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); let mut tx_execution_context = TransactionExecutionContext { version: 1.into(), ..Default::default() diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index f4ec8a579..33a5d1b3f 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -401,8 +401,11 @@ pub(crate) fn preprocess_invoke_function_fields( mod tests { use super::*; use crate::{ - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::cached_state::CachedState, + state::in_memory_state_reader::InMemoryStateReader, utils::calculate_sn_keccak, }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; @@ -449,7 +452,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -518,7 +521,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -583,7 +586,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -642,7 +645,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -707,7 +710,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -766,7 +769,7 @@ mod tests { skip_nonce_check: false, }; - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -823,7 +826,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -881,7 +884,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -944,7 +947,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); @@ -1087,13 +1090,9 @@ mod tests { let mut casm_contract_class_cache = HashMap::new(); - casm_contract_class_cache.insert(class_hash, contract_class); + casm_contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state = CachedState::new( - Arc::new(state_reader), - None, - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), casm_contract_class_cache); let state_before_execution = state.clone(); diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index 9b479a340..7cb1766d9 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -266,7 +266,7 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), None, None); + let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); // Initialize state.contract_classes state.set_contract_classes(HashMap::new()).unwrap(); diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index 1f32b20e6..9e7cc02a3 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -65,7 +65,7 @@ fn storage_write_read() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -75,7 +75,7 @@ fn storage_write_read() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -204,7 +204,7 @@ fn library_call() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -226,7 +226,10 @@ fn library_call() { let lib_class_hash: ClassHash = [2; 32]; let lib_nonce = Felt252::zero(); - contract_class_cache.insert(lib_class_hash, lib_contract_class); + contract_class_cache.insert( + lib_class_hash, + CompiledClass::Casm(Arc::new(lib_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(lib_address.clone(), lib_class_hash); @@ -235,7 +238,7 @@ fn library_call() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -361,7 +364,7 @@ fn call_contract_storage_write_read() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -392,7 +395,10 @@ fn call_contract_storage_write_read() { let simple_wallet_class_hash: ClassHash = [2; 32]; let simple_wallet_nonce = Felt252::zero(); - contract_class_cache.insert(simple_wallet_class_hash, simple_wallet_contract_class); + contract_class_cache.insert( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(simple_wallet_address.clone(), simple_wallet_class_hash); @@ -401,7 +407,7 @@ fn call_contract_storage_write_read() { .insert(simple_wallet_address.clone(), simple_wallet_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -547,7 +553,7 @@ fn emit_event() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -557,7 +563,7 @@ fn emit_event() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [].to_vec(); @@ -659,8 +665,11 @@ fn deploy_cairo1_from_cairo1() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); - contract_class_cache.insert(test_class_hash, test_contract_class.clone()); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Casm(Arc::new(test_contract_class.clone())), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -671,7 +680,7 @@ fn deploy_cairo1_from_cairo1() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -750,15 +759,17 @@ fn deploy_cairo0_from_cairo1_without_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - casm_contract_class_cache.insert(class_hash, contract_class); - contract_class_cache.insert(test_class_hash, test_contract_class.clone()); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Deprecated(Arc::new(test_contract_class.clone())), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -769,11 +780,7 @@ fn deploy_cairo0_from_cairo1_without_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -850,7 +857,6 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); @@ -858,8 +864,11 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let nonce = Felt252::zero(); // simulate contract declare - casm_contract_class_cache.insert(class_hash, contract_class); - contract_class_cache.insert(test_class_hash, test_contract_class.clone()); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Deprecated(Arc::new(test_contract_class.clone())), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -870,11 +879,7 @@ fn deploy_cairo0_from_cairo1_with_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt, address.0.clone(), Felt252::zero()].to_vec(); @@ -953,15 +958,17 @@ fn deploy_cairo0_and_invoke() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - casm_contract_class_cache.insert(class_hash, contract_class); - contract_class_cache.insert(test_class_hash, test_contract_class.clone()); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Deprecated(Arc::new(test_contract_class.clone())), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -972,11 +979,7 @@ fn deploy_cairo0_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state: CachedState<_> = CachedState::new( - Arc::new(state_reader), - Some(contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state: CachedState<_> = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1085,7 +1088,7 @@ fn test_send_message_to_l1_syscall() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -1096,7 +1099,7 @@ fn test_send_message_to_l1_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // RUN SEND_MSG // Create an execution entry point @@ -1179,7 +1182,7 @@ fn test_get_execution_info() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1189,7 +1192,7 @@ fn test_get_execution_info() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -1274,7 +1277,10 @@ fn replace_class_internal() { let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash_a, contract_class_a); + contract_class_cache.insert( + class_hash_a, + CompiledClass::Casm(Arc::new(contract_class_a)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1292,10 +1298,13 @@ fn replace_class_internal() { let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert(class_hash_b, contract_class_b.clone()); + contract_class_cache.insert( + class_hash_b, + CompiledClass::Casm(Arc::new(contract_class_b.clone())), + ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Run upgrade entrypoint and check that the storage was updated with the new contract class // Create an execution entry point @@ -1370,7 +1379,10 @@ fn replace_class_contract_call() { let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash_a, contract_class_a); + contract_class_cache.insert( + class_hash_a, + CompiledClass::Casm(Arc::new(contract_class_a)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1391,7 +1403,10 @@ fn replace_class_contract_call() { let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert(class_hash_b, contract_class_b); + contract_class_cache.insert( + class_hash_b, + CompiledClass::Casm(Arc::new(contract_class_b)), + ); // SET GET_NUMBER_WRAPPER @@ -1408,7 +1423,10 @@ fn replace_class_contract_call() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert(wrapper_class_hash, wrapper_contract_class); + contract_class_cache.insert( + wrapper_class_hash, + CompiledClass::Casm(Arc::new(wrapper_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(wrapper_address.clone(), wrapper_class_hash); @@ -1417,7 +1435,7 @@ fn replace_class_contract_call() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1537,7 +1555,10 @@ fn replace_class_contract_call_same_transaction() { let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash_a, contract_class_a); + contract_class_cache.insert( + class_hash_a, + CompiledClass::Casm(Arc::new(contract_class_a)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1558,7 +1579,10 @@ fn replace_class_contract_call_same_transaction() { let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert(class_hash_b, contract_class_b); + contract_class_cache.insert( + class_hash_b, + CompiledClass::Casm(Arc::new(contract_class_b)), + ); // SET GET_NUMBER_WRAPPER @@ -1574,7 +1598,10 @@ fn replace_class_contract_call_same_transaction() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert(wrapper_class_hash, wrapper_contract_class); + contract_class_cache.insert( + wrapper_class_hash, + CompiledClass::Casm(Arc::new(wrapper_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(wrapper_address.clone(), wrapper_class_hash); @@ -1583,7 +1610,7 @@ fn replace_class_contract_call_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1645,14 +1672,16 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); - let mut deprecated_contract_class_cache = HashMap::new(); + let mut contract_class_cache = HashMap::new(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); let nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(class_hash_c, contract_class_c); + contract_class_cache.insert( + class_hash_c, + CompiledClass::Deprecated(Arc::new(contract_class_c)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1673,7 +1702,10 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let class_hash_b: ClassHash = Felt252::from(2).to_be_bytes(); - casm_contract_class_cache.insert(class_hash_b, contract_class_b); + contract_class_cache.insert( + class_hash_b, + CompiledClass::Casm(Arc::new(contract_class_b)), + ); // SET GET_NUMBER_WRAPPER @@ -1689,7 +1721,10 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - casm_contract_class_cache.insert(wrapper_class_hash, wrapper_contract_class); + contract_class_cache.insert( + wrapper_class_hash, + CompiledClass::Casm(Arc::new(wrapper_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(wrapper_address.clone(), wrapper_class_hash); @@ -1698,11 +1733,7 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(deprecated_contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1762,14 +1793,16 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); - let mut deprecated_contract_class_cache = HashMap::new(); + let mut contract_class_cache = HashMap::new(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); let nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(class_hash_c, contract_class_c); + contract_class_cache.insert( + class_hash_c, + CompiledClass::Deprecated(Arc::new(contract_class_c)), + ); // SET GET_NUMBER_B @@ -1783,7 +1816,10 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let class_hash_b: ClassHash = Felt252::from(2).to_be_bytes(); - casm_contract_class_cache.insert(class_hash_b, contract_class_b); + contract_class_cache.insert( + class_hash_b, + CompiledClass::Casm(Arc::new(contract_class_b)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1806,7 +1842,10 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - casm_contract_class_cache.insert(wrapper_class_hash, wrapper_contract_class); + contract_class_cache.insert( + wrapper_class_hash, + CompiledClass::Casm(Arc::new(wrapper_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(wrapper_address.clone(), wrapper_class_hash); @@ -1815,11 +1854,7 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(deprecated_contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1879,14 +1914,16 @@ fn call_contract_replace_class_cairo_0() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); - let mut deprecated_contract_class_cache = HashMap::new(); + let mut contract_class_cache = HashMap::new(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); let nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(class_hash_c, contract_class_c); + contract_class_cache.insert( + class_hash_c, + CompiledClass::Deprecated(Arc::new(contract_class_c)), + ); // SET GET_NUMBER_B @@ -1896,7 +1933,10 @@ fn call_contract_replace_class_cairo_0() { let class_hash_d: ClassHash = Felt252::from(2).to_be_bytes(); - deprecated_contract_class_cache.insert(class_hash_d, contract_class_d); + contract_class_cache.insert( + class_hash_d, + CompiledClass::Deprecated(Arc::new(contract_class_d)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1919,7 +1959,10 @@ fn call_contract_replace_class_cairo_0() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - casm_contract_class_cache.insert(wrapper_class_hash, wrapper_contract_class); + contract_class_cache.insert( + wrapper_class_hash, + CompiledClass::Casm(Arc::new(wrapper_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(wrapper_address.clone(), wrapper_class_hash); @@ -1928,11 +1971,7 @@ fn call_contract_replace_class_cairo_0() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(deprecated_contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1998,7 +2037,7 @@ fn test_out_of_gas_failure() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2008,7 +2047,7 @@ fn test_out_of_gas_failure() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [].to_vec(); @@ -2075,7 +2114,7 @@ fn deploy_syscall_failure_uninitialized_class_hash() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2085,7 +2124,7 @@ fn deploy_syscall_failure_uninitialized_class_hash() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [Felt252::zero()].to_vec(); @@ -2151,7 +2190,7 @@ fn deploy_syscall_failure_in_constructor() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2167,10 +2206,13 @@ fn deploy_syscall_failure_in_constructor() { let f_c_program_data = include_bytes!("../starknet_programs/cairo1/failing_constructor.casm"); let f_c_contract_class: CasmContractClass = serde_json::from_slice(f_c_program_data).unwrap(); let f_c_class_hash = Felt252::one(); - contract_class_cache.insert(f_c_class_hash.to_be_bytes(), f_c_contract_class); + contract_class_cache.insert( + f_c_class_hash.to_be_bytes(), + CompiledClass::Casm(Arc::new(f_c_contract_class)), + ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [f_c_class_hash].to_vec(); @@ -2238,7 +2280,7 @@ fn storage_read_no_value() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2248,7 +2290,7 @@ fn storage_read_no_value() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2309,7 +2351,7 @@ fn storage_read_unavailable_address_domain() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2319,7 +2361,7 @@ fn storage_read_unavailable_address_domain() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2383,7 +2425,7 @@ fn storage_write_unavailable_address_domain() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2393,7 +2435,7 @@ fn storage_write_unavailable_address_domain() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2455,7 +2497,7 @@ fn library_call_failure() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2476,7 +2518,10 @@ fn library_call_failure() { let lib_class_hash: ClassHash = [2; 32]; let lib_nonce = Felt252::zero(); - contract_class_cache.insert(lib_class_hash, lib_contract_class); + contract_class_cache.insert( + lib_class_hash, + CompiledClass::Casm(Arc::new(lib_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(lib_address.clone(), lib_class_hash); @@ -2485,7 +2530,7 @@ fn library_call_failure() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -2564,7 +2609,7 @@ fn send_messages_to_l1_different_contract_calls() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2585,7 +2630,10 @@ fn send_messages_to_l1_different_contract_calls() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - contract_class_cache.insert(send_msg_class_hash, send_msg_contract_class); + contract_class_cache.insert( + send_msg_class_hash, + CompiledClass::Casm(Arc::new(send_msg_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(send_msg_address.clone(), send_msg_class_hash); @@ -2594,7 +2642,7 @@ fn send_messages_to_l1_different_contract_calls() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2679,13 +2727,12 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { // Create state reader with class hash data let mut contract_class_cache = HashMap::new(); - let mut deprecated_contract_class_cache = HashMap::new(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2703,7 +2750,10 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(send_msg_class_hash, send_msg_contract_class); + contract_class_cache.insert( + send_msg_class_hash, + CompiledClass::Deprecated(Arc::new(send_msg_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(send_msg_address.clone(), send_msg_class_hash); @@ -2712,11 +2762,7 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(deprecated_contract_class_cache), - Some(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2796,13 +2842,15 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { // Create state reader with class hash data let mut contract_class_cache = HashMap::new(); - let mut deprecated_contract_class_cache = HashMap::new(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2823,7 +2871,10 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - contract_class_cache.insert(send_msg_class_hash, send_msg_contract_class); + contract_class_cache.insert( + send_msg_class_hash, + CompiledClass::Casm(Arc::new(send_msg_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(send_msg_address.clone(), send_msg_class_hash); @@ -2832,11 +2883,7 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(deprecated_contract_class_cache), - Some(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2920,7 +2967,7 @@ fn keccak_syscall() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2930,7 +2977,7 @@ fn keccak_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), None, Some(contract_class_cache)); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index bbab48eb9..6f987ed64 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -54,11 +54,7 @@ fn swap(calldata: &[Felt252], call_config: &mut CallConfig) -> Result CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); - let state_cache = ContractClassCache::new(); - - CachedState::new( - Arc::new(in_memory_state_reader), - Some(state_cache), - Some(HashMap::new()), - ) + CachedState::new(Arc::new(in_memory_state_reader), HashMap::new()) } fn expected_state_after_tx(fee: u128) -> CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); - let contract_classes_cache = ContractClassCache::from([ + let contract_classes_cache = HashMap::from([ ( felt_to_hash(&TEST_CLASS_HASH.clone()), - ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + )), ), ( felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH.clone()), - ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + )), ), ( felt_to_hash(&TEST_ERC20_CONTRACT_CLASS_HASH.clone()), - ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + )), ), ]); CachedState::new_for_testing( Arc::new(in_memory_state_reader), - Some(contract_classes_cache), state_cache_after_invoke_tx(fee), - Some(HashMap::new()), + contract_classes_cache, ) } @@ -372,19 +371,24 @@ fn initial_in_memory_state_reader() -> InMemoryStateReader { HashMap::from([ ( felt_to_hash(&TEST_ERC20_CONTRACT_CLASS_HASH), - ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + )), ), ( felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH), - ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + )), ), ( felt_to_hash(&TEST_CLASS_HASH), - ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + )), ), ]), HashMap::new(), - HashMap::new(), ) } @@ -524,10 +528,6 @@ fn test_create_account_tx_test_state() { &state.contract_classes(), &expected_initial_state.contract_classes() ); - assert_eq!( - &state.casm_contract_classes(), - &expected_initial_state.casm_contract_classes() - ); assert_eq!( &state.state_reader.address_to_class_hash, &expected_initial_state.state_reader.address_to_class_hash @@ -542,21 +542,21 @@ fn test_create_account_tx_test_state() { ); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17 @@ -874,10 +874,6 @@ fn test_declare_tx() { &state.contract_classes(), &expected_initial_state.contract_classes() ); - assert_eq!( - &state.casm_contract_classes(), - &expected_initial_state.casm_contract_classes() - ); assert_eq!( &state.state_reader.address_to_class_hash, &expected_initial_state.state_reader.address_to_class_hash @@ -892,21 +888,21 @@ fn test_declare_tx() { ); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17 @@ -962,10 +958,6 @@ fn test_declarev2_tx() { &state.contract_classes(), &expected_initial_state.contract_classes() ); - assert_eq!( - &state.casm_contract_classes(), - &expected_initial_state.casm_contract_classes() - ); assert_eq!( &state.state_reader.address_to_class_hash, &expected_initial_state.state_reader.address_to_class_hash @@ -980,21 +972,21 @@ fn test_declarev2_tx() { ); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17 @@ -1308,10 +1300,6 @@ fn test_invoke_tx_state() { &state.contract_classes(), &expected_initial_state.contract_classes() ); - assert_eq!( - &state.casm_contract_classes(), - &expected_initial_state.casm_contract_classes() - ); assert_eq!( &state.state_reader.address_to_class_hash, &expected_initial_state.state_reader.address_to_class_hash @@ -1326,21 +1314,21 @@ fn test_invoke_tx_state() { ); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17 @@ -1362,10 +1350,6 @@ fn test_invoke_tx_state() { let expected_final_state = expected_state_after_tx(result.actual_fee); assert_eq!(&state.cache(), &expected_final_state.cache()); - assert_eq!( - &state.casm_contract_classes(), - &expected_final_state.casm_contract_classes() - ); assert_eq!( &state.state_reader.address_to_class_hash, &expected_final_state.state_reader.address_to_class_hash @@ -1389,10 +1373,6 @@ fn test_invoke_with_declarev2_tx() { &state.contract_classes(), &expected_initial_state.contract_classes() ); - assert_eq!( - &state.casm_contract_classes(), - &expected_initial_state.casm_contract_classes() - ); assert_eq!( &state.state_reader.address_to_class_hash, &expected_initial_state.state_reader.address_to_class_hash @@ -1407,21 +1387,21 @@ fn test_invoke_with_declarev2_tx() { ); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16 ])); assert!(&state .state_reader - .class_hash_to_contract_class + .class_hash_to_compiled_class .contains_key(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17 @@ -1488,19 +1468,11 @@ fn test_deploy_account() { assert_eq!(&state.cache(), &state_before.cache()); assert_eq!(&state.contract_classes(), &state_before.contract_classes()); - assert_eq!( - &state.casm_contract_classes(), - &state_before.casm_contract_classes() - ); let tx_info = deploy_account_tx .execute(&mut state, &block_context) .unwrap(); - assert_eq!( - state.casm_contract_classes(), - state_after.casm_contract_classes() - ); assert_eq!(state.cache(), state_after.cache()); let expected_validate_call_info = expected_validate_call_info( @@ -1599,22 +1571,26 @@ fn expected_deploy_account_states() -> ( HashMap::from([ ( felt_to_hash(&0x110.into()), - ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + )), ), ( felt_to_hash(&0x111.into()), - ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + )), ), ( felt_to_hash(&0x1010.into()), - ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + )), ), ]), HashMap::new(), - HashMap::new(), )), - Some(ContractClassCache::new()), - Some(HashMap::new()), + HashMap::new(), ); state_before.set_storage_at( &( diff --git a/tests/multi_syscall_test.rs b/tests/multi_syscall_test.rs index 7aa7890d7..9f75e7925 100644 --- a/tests/multi_syscall_test.rs +++ b/tests/multi_syscall_test.rs @@ -1,6 +1,7 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::felt::Felt252; use num_traits::{Num, Zero}; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; use starknet_in_rust::utils::calculate_sn_keccak; use starknet_in_rust::EntryPointType; use starknet_in_rust::{ @@ -28,7 +29,7 @@ fn test_multiple_syscall() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -38,11 +39,7 @@ fn test_multiple_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - None, - Some(contract_class_cache.clone()), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache.clone()); // Create an execution entry point let calldata = [].to_vec(); diff --git a/tests/storage.rs b/tests/storage.rs index 19d03359e..f13bc141c 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -1,6 +1,7 @@ use cairo_vm::felt::Felt252; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use num_traits::Zero; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, @@ -50,7 +51,10 @@ fn integration_storage_test() { let storage_entry = (address.clone(), [90; 32]); let storage_value = Felt252::new(10902); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -66,7 +70,7 @@ fn integration_storage_test() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new(Arc::new(state_reader), Some(contract_class_cache), None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); //* ------------------------------------ //* Create execution entry point diff --git a/tests/syscalls.rs b/tests/syscalls.rs index 23ee0b2e0..03bfd188f 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -10,7 +10,6 @@ use cairo_vm::{ }, }; use num_traits::{Num, One, Zero}; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{ block_context::{BlockContext, StarknetChainId}, @@ -20,16 +19,17 @@ use starknet_in_rust::{ execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, L2toL1MessageInfo, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, }, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, + services::api::contract_classes::deprecated_contract_class::ContractClass, state::{ - cached_state::{CachedState, ContractClassCache}, + cached_state::CachedState, state_api::{State, StateReader}, }, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{calculate_sn_keccak, felt_to_hash, Address, ClassHash}, }; +use starknet_in_rust::{ + services::api::contract_classes::compiled_class::CompiledClass, EntryPointType, +}; use std::{ collections::{HashMap, HashSet}, iter::empty, @@ -85,19 +85,23 @@ fn test_contract<'a>( state_reader .address_to_nonce_mut() .insert(contract_address.clone(), nonce); - state_reader - .class_hash_to_contract_class_mut() - .insert(class_hash, contract_class); + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut storage_entries = Vec::new(); let contract_class_cache = { - let mut contract_class_cache = ContractClassCache::new(); + let mut contract_class_cache = HashMap::new(); for (class_hash, contract_path, contract_address) in extra_contracts { let contract_class = ContractClass::from_path(contract_path) .expect("Could not load extra contract from JSON"); - contract_class_cache.insert(class_hash, contract_class.clone()); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); if let Some((contract_address, data)) = contract_address { storage_entries.extend( @@ -108,15 +112,16 @@ fn test_contract<'a>( state_reader .address_to_class_hash_mut() .insert(contract_address.clone(), class_hash); - state_reader - .class_hash_to_contract_class_mut() - .insert(class_hash, contract_class.clone()); + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); } } - Some(contract_class_cache) + contract_class_cache }; - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache, None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); storage_entries .into_iter() .for_each(|(a, b, c)| state.set_storage_at(&(a, b), c)); @@ -1079,7 +1084,6 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); @@ -1087,8 +1091,14 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let nonce = Felt252::zero(); // simulate contract declare - casm_contract_class_cache.insert(test_class_hash, test_contract_class.clone()); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Casm(Arc::new(test_contract_class.clone())), + ); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -1099,11 +1109,7 @@ fn deploy_cairo1_from_cairo0_with_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt, Felt252::one()].to_vec(); @@ -1180,7 +1186,6 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); @@ -1188,8 +1193,14 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let nonce = Felt252::zero(); // simulate contract declare - casm_contract_class_cache.insert(test_class_hash, test_contract_class.clone()); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Casm(Arc::new(test_contract_class.clone())), + ); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -1200,11 +1211,7 @@ fn deploy_cairo1_from_cairo0_without_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1283,7 +1290,6 @@ fn deploy_cairo1_and_invoke() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut casm_contract_class_cache = HashMap::new(); let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); @@ -1291,8 +1297,14 @@ fn deploy_cairo1_and_invoke() { let nonce = Felt252::zero(); // simulate contract declare - casm_contract_class_cache.insert(test_class_hash, test_contract_class.clone()); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + test_class_hash, + CompiledClass::Casm(Arc::new(test_contract_class.clone())), + ); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -1303,11 +1315,7 @@ fn deploy_cairo1_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(contract_class_cache), - Some(casm_contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1408,13 +1416,16 @@ fn send_messages_to_l1_different_contract_calls() { .to_owned(); // Create state reader with class hash data - let mut deprecated_contract_class_cache = HashMap::new(); + let mut contract_class_cache = HashMap::new(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1432,7 +1443,10 @@ fn send_messages_to_l1_different_contract_calls() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - deprecated_contract_class_cache.insert(send_msg_class_hash, send_msg_contract_class); + contract_class_cache.insert( + send_msg_class_hash, + CompiledClass::Deprecated(Arc::new(send_msg_contract_class)), + ); state_reader .address_to_class_hash_mut() .insert(send_msg_address.clone(), send_msg_class_hash); @@ -1441,11 +1455,7 @@ fn send_messages_to_l1_different_contract_calls() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Some(deprecated_contract_class_cache), - None, - ); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); diff --git a/tests/syscalls_errors.rs b/tests/syscalls_errors.rs index 17d85bb1f..1e9433e93 100644 --- a/tests/syscalls_errors.rs +++ b/tests/syscalls_errors.rs @@ -10,10 +10,7 @@ use starknet_in_rust::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, services::api::contract_classes::deprecated_contract_class::ContractClass, - state::{ - cached_state::{CachedState, ContractClassCache}, - state_api::State, - }, + state::{cached_state::CachedState, state_api::State}, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{calculate_sn_keccak, Address, ClassHash}, }; @@ -21,6 +18,8 @@ use std::path::Path; use std::sync::Arc; use assert_matches::assert_matches; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; +use std::collections::HashMap; #[allow(clippy::too_many_arguments)] fn test_contract<'a>( @@ -63,19 +62,23 @@ fn test_contract<'a>( state_reader .address_to_nonce_mut() .insert(contract_address.clone(), nonce); - state_reader - .class_hash_to_contract_class_mut() - .insert(class_hash, contract_class); + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut storage_entries = Vec::new(); let contract_class_cache = { - let mut contract_class_cache = ContractClassCache::new(); + let mut contract_class_cache = HashMap::new(); for (class_hash, contract_path, contract_address) in extra_contracts { let contract_class = ContractClass::from_path(contract_path) .expect("Could not load extra contract from JSON"); - contract_class_cache.insert(class_hash, contract_class.clone()); + contract_class_cache.insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); if let Some((contract_address, data)) = contract_address { storage_entries.extend(data.into_iter().map(|(name, value)| { @@ -89,15 +92,16 @@ fn test_contract<'a>( state_reader .address_to_class_hash_mut() .insert(contract_address.clone(), class_hash); - state_reader - .class_hash_to_contract_class_mut() - .insert(class_hash, contract_class.clone()); + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ); } } - Some(contract_class_cache) + contract_class_cache }; - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache, None); + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); storage_entries .into_iter() .for_each(|(a, b, c)| state.set_storage_at(&(a, b), c)); From 63e4bc4511616e60c93c6ce63e16e9192c79abb4 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 23 Aug 2023 22:21:51 +0200 Subject: [PATCH 02/56] Fix formatting and clippy. --- src/execution/execution_entry_point.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 1b6d33870..b16b500a9 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -128,10 +128,8 @@ impl ExecutionEntryPoint { }) } CompiledClass::Casm(contract_class) => { - let mut tmp_state = CachedState::new( - state.state_reader.clone(), - state.contract_classes.clone(), - ); + let mut tmp_state = + CachedState::new(state.state_reader.clone(), state.contract_classes.clone()); tmp_state.cache = state.cache.clone(); match self._execute( From 3efec30ca5008318f544a43ad6bbc50c03f6d269 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 12:09:24 +0200 Subject: [PATCH 03/56] Remove unused code. --- src/state/cached_state.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 350877bd6..74451d8f9 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -65,14 +65,6 @@ impl CachedState { self.contract_classes = contract_classes; Ok(()) } - - // /// Returns the casm classes. - // #[allow(dead_code)] - // pub(crate) fn get_casm_classes(&mut self) -> Result<&CasmClassCache, StateError> { - // self.casm_contract_classes - // .as_ref() - // .ok_or(StateError::MissingCasmClassCache) - // } } impl StateReader for CachedState { From a4afabb9d009e77da492e95d4d67aece6435aa15 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 12:41:27 +0200 Subject: [PATCH 04/56] Unify contract classes in the state traits too. --- bench/internals.rs | 19 +++++++-- cli/src/main.rs | 9 ++++- src/lib.rs | 20 ++++++++-- src/state/cached_state.rs | 44 ++++++--------------- src/state/state_api.rs | 13 +------ src/syscalls/deprecated_syscall_handler.rs | 11 +++++- src/testing/erc20.rs | 10 ++++- src/testing/state.rs | 12 ++++-- src/transaction/declare.rs | 7 +++- src/transaction/declare_v2.rs | 7 +++- src/transaction/deploy.rs | 25 +++++------- src/transaction/deploy_account.rs | 8 +++- src/transaction/invoke_function.rs | 45 +++++++++++++++++----- src/transaction/l1_handler.rs | 9 ++++- tests/complex_contracts/utils.rs | 14 +++++-- tests/deploy_account.rs | 15 +++++--- tests/internals.rs | 10 +++-- 17 files changed, 177 insertions(+), 101 deletions(-) diff --git a/bench/internals.rs b/bench/internals.rs index ea6906013..430dc5446 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -11,7 +11,9 @@ use starknet_in_rust::{ constants::{TRANSACTION_VERSION, VALIDATE_ENTRY_POINT_SELECTOR}, }, hash_utils::calculate_contract_address, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::in_memory_state_reader::InMemoryStateReader, state::{cached_state::CachedState, state_api::State}, transaction::{declare::Declare, Deploy, DeployAccount, InvokeFunction}, @@ -64,7 +66,10 @@ fn deploy_account() { let mut state = CachedState::new(state_reader, HashMap::new()); state - .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) + .set_contract_class( + &CLASS_HASH_BYTES, + &CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ) .unwrap(); let block_context = &Default::default(); @@ -132,7 +137,10 @@ fn deploy() { let mut state = CachedState::new(state_reader, HashMap::new()); state - .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) + .set_contract_class( + &CLASS_HASH_BYTES, + &CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ) .unwrap(); let block_context = &Default::default(); @@ -167,7 +175,10 @@ fn invoke() { let mut state = CachedState::new(state_reader, HashMap::new()); state - .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) + .set_contract_class( + &CLASS_HASH_BYTES, + &CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ) .unwrap(); let block_context = &Default::default(); diff --git a/cli/src/main.rs b/cli/src/main.rs index bc9e0d6bc..1248123dd 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -23,7 +23,9 @@ use starknet_in_rust::{ hash_utils::calculate_contract_address, parser_errors::ParserError, serde_structs::read_abi, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{cached_state::CachedState, state_api::State}, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, transaction::{error::TransactionError, InvokeFunction}, @@ -110,7 +112,10 @@ fn declare_parser( let contract_class = ContractClass::from_path(&args.contract).map_err(ContractAddressError::Program)?; let class_hash = compute_deprecated_class_hash(&contract_class)?; - cached_state.set_contract_class(&felt_to_hash(&class_hash), &contract_class)?; + cached_state.set_contract_class( + &felt_to_hash(&class_hash), + &CompiledClass::Deprecated(Arc::new(contract_class.clone())), + )?; let tx_hash = calculate_declare_transaction_hash( &contract_class, diff --git a/src/lib.rs b/src/lib.rs index 42677df79..1b9a441e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -684,7 +684,10 @@ mod test { let mut state = CachedState::new(state_reader, HashMap::new()); state - .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) + .set_contract_class( + &CLASS_HASH_BYTES, + &CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ) .unwrap(); let block_context = &Default::default(); @@ -760,7 +763,10 @@ mod test { let mut state = CachedState::new(state_reader, HashMap::new()); state - .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) + .set_contract_class( + &CLASS_HASH_BYTES, + &CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ) .unwrap(); let block_context = Default::default(); @@ -821,7 +827,10 @@ mod test { let mut state = CachedState::new(state_reader, HashMap::new()); state - .set_contract_class(&CLASS_HASH_BYTES, &CONTRACT_CLASS) + .set_contract_class( + &CLASS_HASH_BYTES, + &CompiledClass::Deprecated(Arc::new(CONTRACT_CLASS.clone())), + ) .unwrap(); let block_context = &Default::default(); @@ -945,7 +954,10 @@ mod test { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let mut block_context = BlockContext::default(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 74451d8f9..29f863b30 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -4,13 +4,10 @@ use super::{ }; use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, + services::api::contract_classes::compiled_class::CompiledClass, state::StateDiff, utils::{subtract_mappings, to_cache_state_storage_mapping, Address, ClassHash}, }; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::felt::Felt252; use getset::{Getters, MutGetters}; use num_traits::Zero; @@ -167,8 +164,6 @@ impl StateReader for CachedState { } // II: FETCHING FROM STATE_READER - // TODO: Should this modify the cache? - // TODO: Related: Isn't this exact method available in `impl State for CachedState`? self.state_reader.get_contract_class(class_hash) } } @@ -178,14 +173,10 @@ impl State for CachedState { fn set_contract_class( &mut self, class_hash: &ClassHash, - contract_class: &ContractClass, + contract_class: &CompiledClass, ) -> Result<(), StateError> { - // TODO: Could this method's signature use `CompiledClass` instead of `ContractClass`? Or - // even better, could the entire trait use `Arc`? - self.contract_classes.insert( - *class_hash, - CompiledClass::Deprecated(Arc::new(contract_class.clone())), - ); + self.contract_classes + .insert(*class_hash, contract_class.clone()); Ok(()) } @@ -249,20 +240,6 @@ impl State for CachedState { Ok(()) } - fn set_compiled_class( - &mut self, - compiled_class_hash: &Felt252, - casm_class: CasmContractClass, - ) -> Result<(), StateError> { - let compiled_class_hash = compiled_class_hash.to_be_bytes(); - self.contract_classes.insert( - compiled_class_hash, - CompiledClass::Casm(Arc::new(casm_class)), - ); - - Ok(()) - } - fn set_compiled_class_hash( &mut self, class_hash: &Felt252, @@ -423,13 +400,13 @@ impl State for CachedState { CompiledClass::Casm(ref casm_class) => { // We call this method instead of state_reader's in order to update the cache's class_hash_initial_values map let compiled_class_hash = self.get_compiled_class_hash(class_hash)?; - self.set_compiled_class( - &Felt252::from_bytes_be(&compiled_class_hash), - casm_class.as_ref().clone(), + self.set_contract_class( + &compiled_class_hash, + &CompiledClass::Casm(casm_class.clone()), )?; } CompiledClass::Deprecated(ref contract) => { - self.set_contract_class(class_hash, &contract.clone())? + self.set_contract_class(class_hash, &CompiledClass::Deprecated(contract.clone()))? } } Ok(contract) @@ -440,7 +417,10 @@ impl State for CachedState { mod tests { use super::*; - use crate::state::in_memory_state_reader::InMemoryStateReader; + use crate::{ + services::api::contract_classes::deprecated_contract_class::ContractClass, + state::in_memory_state_reader::InMemoryStateReader, + }; use num_traits::One; diff --git a/src/state/state_api.rs b/src/state/state_api.rs index 27ffa8599..885eee4be 100644 --- a/src/state/state_api.rs +++ b/src/state/state_api.rs @@ -1,13 +1,10 @@ use super::state_cache::StorageEntry; use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, + services::api::contract_classes::compiled_class::CompiledClass, state::StateDiff, utils::{Address, ClassHash, CompiledClassHash}, }; -use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::felt::Felt252; pub trait StateReader { @@ -30,7 +27,7 @@ pub trait State { fn set_contract_class( &mut self, class_hash: &ClassHash, - contract_class: &ContractClass, + contract_class: &CompiledClass, ) -> Result<(), StateError>; fn deploy_contract( @@ -49,12 +46,6 @@ pub trait State { class_hash: ClassHash, ) -> Result<(), StateError>; - fn set_compiled_class( - &mut self, - compiled_class_hash: &Felt252, - casm_class: CasmContractClass, - ) -> Result<(), StateError>; - fn set_compiled_class_hash( &mut self, class_hash: &Felt252, diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index fb9b38c1a..7ee047b76 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -227,6 +227,7 @@ mod tests { use std::sync::Arc; use super::*; + use crate::services::api::contract_classes::compiled_class::CompiledClass; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use crate::{ add_segments, allocate_selector, any_box, @@ -1034,7 +1035,10 @@ mod tests { .syscall_handler .starknet_storage_state .state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); // Execute Deploy hint @@ -1133,7 +1137,10 @@ mod tests { .syscall_handler .starknet_storage_state .state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); // Execute Deploy hint diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index 717097e53..97dbf7cb8 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -142,7 +142,10 @@ fn test_erc20_cairo2() { serde_json::from_slice(program_data_account).unwrap(); state - .set_compiled_class(&felt_str!("1"), contract_class_account) + .set_contract_class( + &felt_str!("1").to_be_bytes(), + &CompiledClass::Casm(Arc::new(contract_class_account)), + ) .unwrap(); let contract_address_salt = @@ -181,7 +184,10 @@ fn test_erc20_cairo2() { serde_json::from_slice(program_data_account).unwrap(); state - .set_compiled_class(&felt_str!("1"), contract_class_account) + .set_contract_class( + &felt_str!("1").to_be_bytes(), + &CompiledClass::Casm(Arc::new(contract_class_account)), + ) .unwrap(); let contract_address_salt = felt_str!("123123123123123"); diff --git a/src/testing/state.rs b/src/testing/state.rs index a16bf66fe..8158786ce 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -1,5 +1,6 @@ use super::{state_error::StarknetStateError, type_utils::ExecutionInfo}; use crate::execution::execution_entry_point::ExecutionResult; +use crate::services::api::contract_classes::compiled_class::CompiledClass; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use crate::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, @@ -201,8 +202,10 @@ impl StarknetState { let contract_hash = deploy.contract_hash; let mut tx = Transaction::Deploy(deploy); - self.state - .set_contract_class(&contract_hash, &contract_class)?; + self.state.set_contract_class( + &contract_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + )?; let tx_execution_info = self.execute_tx(&mut tx, remaining_gas)?; Ok((contract_address, tx_execution_info)) @@ -472,7 +475,10 @@ mod tests { starknet_state .state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); // -------------------------------------------- diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index b7bce7833..ce93bc4b1 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -29,6 +29,8 @@ use num_traits::Zero; use super::fee::charge_fee; use super::{verify_version, Transaction}; +use crate::services::api::contract_classes::compiled_class::CompiledClass; +use std::sync::Arc; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Represents an internal transaction in the StarkNet network that is a declaration of a Cairo @@ -281,7 +283,10 @@ impl Declare { self.skip_fee_transfer, )?; - state.set_contract_class(&self.class_hash, &self.contract_class)?; + state.set_contract_class( + &self.class_hash, + &CompiledClass::Deprecated(Arc::new(self.contract_class.clone())), + )?; tx_exec_info.set_fee_info(actual_fee, fee_transfer_info); diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 406e4b50c..577c0738b 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -5,6 +5,7 @@ use crate::definitions::constants::QUERY_VERSION_BASE; use crate::execution::execution_entry_point::ExecutionResult; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; +use crate::services::api::contract_classes::compiled_class::CompiledClass; use crate::state::cached_state::CachedState; use crate::{ core::transaction_hash::calculate_declare_v2_transaction_hash, @@ -26,6 +27,7 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; use cairo_vm::felt::Felt252; use num_traits::Zero; +use std::sync::Arc; /// Represents a declare transaction in the starknet network. /// Declare creates a blueprint of a contract class that is used to deploy instances of the contract @@ -372,7 +374,10 @@ impl DeclareV2 { )); } state.set_compiled_class_hash(&self.sierra_class_hash, &self.compiled_class_hash)?; - state.set_compiled_class(&self.compiled_class_hash, casm_class)?; + state.set_contract_class( + &self.compiled_class_hash.to_be_bytes(), + &CompiledClass::Casm(Arc::new(casm_class)), + )?; Ok(()) } diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index c6132445c..b65e8559e 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -151,18 +151,7 @@ impl Deploy { state: &mut CachedState, block_context: &BlockContext, ) -> Result { - match self.contract_class.clone() { - CompiledClass::Casm(contract_class) => { - state.set_compiled_class( - &Felt252::from_bytes_be(&self.contract_hash), - contract_class.as_ref().clone(), - )?; - } - CompiledClass::Deprecated(contract_class) => { - state.set_contract_class(&self.contract_hash, &contract_class)?; - } - } - + state.set_contract_class(&self.contract_hash, &self.contract_class)?; state.deploy_contract(self.contract_address.clone(), self.contract_hash)?; if self.constructor_entry_points_empty(self.contract_class.clone())? { @@ -172,10 +161,10 @@ impl Deploy { self.invoke_constructor(state, block_context) } } + /// Executes the contract without constructor /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. - pub fn handle_empty_constructor( &self, state: &mut S, @@ -386,7 +375,10 @@ mod tests { let class_hash_bytes = class_hash.to_be_bytes(); state - .set_contract_class(&class_hash_bytes, &contract_class) + .set_contract_class( + &class_hash_bytes, + &CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ) .unwrap(); let internal_deploy = @@ -413,7 +405,10 @@ mod tests { class_hash_bytes.copy_from_slice(&class_hash.to_bytes_be()); state - .set_contract_class(&class_hash_bytes, &contract_class) + .set_contract_class( + &class_hash_bytes, + &CompiledClass::Deprecated(Arc::new(contract_class.clone())), + ) .unwrap(); let internal_deploy = Deploy::new( diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index 1a048d450..eccb34117 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -465,7 +465,9 @@ mod tests { .unwrap(); let class_hash = internal_deploy.class_hash(); - state.set_contract_class(class_hash, &contract).unwrap(); + state + .set_contract_class(class_hash, &CompiledClass::Deprecated(Arc::new(contract))) + .unwrap(); internal_deploy.execute(&mut state, &block_context).unwrap(); assert_matches!( internal_deploy_error @@ -501,7 +503,9 @@ mod tests { .unwrap(); let class_hash = internal_deploy.class_hash(); - state.set_contract_class(class_hash, &contract).unwrap(); + state + .set_contract_class(class_hash, &CompiledClass::Deprecated(Arc::new(contract))) + .unwrap(); internal_deploy.execute(&mut state, &block_context).unwrap(); } } diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 33a5d1b3f..ef707f510 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -458,7 +458,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let result = internal_invoke_function @@ -527,7 +530,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let result = internal_invoke_function @@ -592,7 +598,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let expected_error = @@ -651,7 +660,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let result = internal_invoke_function @@ -716,7 +728,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let expected_error = @@ -775,7 +790,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let block_context = BlockContext::default(); @@ -832,7 +850,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let mut block_context = BlockContext::default(); @@ -890,7 +911,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); internal_invoke_function @@ -953,7 +977,10 @@ mod tests { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let expected_error = diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index 7cb1766d9..4f84c910d 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -211,7 +211,9 @@ mod test { sync::Arc, }; - use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; + use crate::services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::EntryPointType, + }; use cairo_vm::{ felt::{felt_str, Felt252}, vm::runners::cairo_runner::ExecutionResources, @@ -272,7 +274,10 @@ mod test { state.set_contract_classes(HashMap::new()).unwrap(); state - .set_contract_class(&class_hash, &contract_class) + .set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let mut block_context = BlockContext::default(); diff --git a/tests/complex_contracts/utils.rs b/tests/complex_contracts/utils.rs index 82c0c5b94..1deeba647 100644 --- a/tests/complex_contracts/utils.rs +++ b/tests/complex_contracts/utils.rs @@ -12,14 +12,19 @@ use starknet_in_rust::{ execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, CallInfo, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{cached_state::CachedState, state_api::State}, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, transaction::{error::TransactionError, Deploy}, utils::{calculate_sn_keccak, Address}, }; use starknet_in_rust::{ContractEntryPoint, EntryPointType}; -use std::collections::{HashMap, HashSet}; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, +}; pub struct CallConfig<'a> { pub state: &'a mut CachedState, @@ -156,7 +161,10 @@ pub fn deploy( )?, }; let class_hash = internal_deploy.class_hash(); - state.set_contract_class(&class_hash, &contract_class)?; + state.set_contract_class( + &class_hash, + &CompiledClass::Deprecated(Arc::new(contract_class)), + )?; let tx_execution_info = internal_deploy.apply(state, block_context)?; diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index 58790be6a..6da3256af 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -4,7 +4,6 @@ use cairo_vm::{ }; use lazy_static::lazy_static; use num_traits::Zero; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ core::contract_address::compute_deprecated_class_hash, definitions::{ @@ -20,6 +19,9 @@ use starknet_in_rust::{ utils::Address, CasmContractClass, }; +use starknet_in_rust::{ + services::api::contract_classes::compiled_class::CompiledClass, EntryPointType, +}; use std::{ collections::{HashMap, HashSet}, sync::Arc, @@ -43,7 +45,10 @@ fn internal_deploy_account() { let class_hash_bytes = class_hash.to_be_bytes(); state - .set_contract_class(&class_hash_bytes, &contract_class) + .set_contract_class( + &class_hash_bytes, + &CompiledClass::Deprecated(Arc::new(contract_class)), + ) .unwrap(); let contract_address_salt = @@ -123,9 +128,9 @@ fn internal_deploy_account_cairo1() { let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); state - .set_compiled_class( - &TEST_ACCOUNT_COMPILED_CONTRACT_CLASS_HASH.clone(), - contract_class, + .set_contract_class( + &TEST_ACCOUNT_COMPILED_CONTRACT_CLASS_HASH.to_be_bytes(), + &CompiledClass::Casm(Arc::new(contract_class)), ) .unwrap(); diff --git a/tests/internals.rs b/tests/internals.rs index 335c0cf62..94f845e36 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -1688,13 +1688,17 @@ fn expected_deploy_account_states() -> ( state_after .set_contract_class( &felt_to_hash(&0x1010.into()), - &ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + &CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + )), ) .unwrap(); state_after .set_contract_class( &felt_to_hash(&0x111.into()), - &ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + &CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + )), ) .unwrap(); @@ -2010,7 +2014,7 @@ fn test_library_call_with_declare_v2() { .insert(address.clone(), nonce); state - .set_compiled_class(&Felt252::from_bytes_be(&class_hash), contract_class) + .set_contract_class(&class_hash, &CompiledClass::Casm(Arc::new(contract_class))) .unwrap(); let create_execute_extrypoint = |selector: &BigUint, From ae4750bd7779a2f169b99c6f0da598154df144e0 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 15:31:25 +0200 Subject: [PATCH 05/56] Fix typos. Make cache shared. --- bench/internals.rs | 14 +- cli/src/main.rs | 4 +- fuzzer/src/main.rs | 7 +- rpc_state_reader/src/lib.rs | 7 +- src/bin/fibonacci.rs | 8 +- src/bin/invoke.rs | 8 +- src/bin/invoke_with_cachedstate.rs | 8 +- src/core/errors/state_errors.rs | 18 +-- src/lib.rs | 57 +++++--- src/state/cached_state.rs | 91 ++++++++---- src/state/mod.rs | 34 +++-- src/syscalls/deprecated_syscall_handler.rs | 41 ++++-- src/syscalls/deprecated_syscall_response.rs | 10 +- src/testing/erc20.rs | 12 +- src/testing/mod.rs | 7 +- src/testing/state.rs | 11 +- src/transaction/declare.rs | 23 ++- src/transaction/declare_v2.rs | 27 +++- src/transaction/deploy.rs | 11 +- src/transaction/deploy_account.rs | 21 ++- src/transaction/fee.rs | 15 +- src/transaction/invoke_function.rs | 109 ++++++++++---- src/transaction/l1_handler.rs | 13 +- starknet_programs/syscalls.cairo | 14 +- tests/cairo_1_syscalls.rs | 137 ++++++++++++++---- tests/complex_contracts/amm_contracts/amm.rs | 47 ++++-- .../amm_contracts/amm_proxy.rs | 27 +++- tests/complex_contracts/nft/erc721.rs | 72 +++++++-- tests/delegate_call.rs | 7 +- tests/delegate_l1_handler.rs | 7 +- tests/deploy_account.rs | 6 +- tests/fibonacci.rs | 12 +- tests/increase_balance.rs | 7 +- tests/internal_calls.rs | 6 +- tests/internals.rs | 38 +++-- tests/multi_syscall_test.rs | 8 +- tests/storage.rs | 7 +- tests/syscalls.rs | 27 +++- tests/syscalls_errors.rs | 7 +- 39 files changed, 716 insertions(+), 269 deletions(-) diff --git a/bench/internals.rs b/bench/internals.rs index 430dc5446..0780b932f 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -19,7 +19,11 @@ use starknet_in_rust::{ transaction::{declare::Declare, Deploy, DeployAccount, InvokeFunction}, utils::Address, }; -use std::{collections::HashMap, hint::black_box, sync::Arc}; +use std::{ + collections::HashMap, + hint::black_box, + sync::{Arc, RwLock}, +}; lazy_static! { // include_str! doesn't seem to work in CI @@ -63,7 +67,7 @@ fn deploy_account() { const RUNS: usize = 500; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); state .set_contract_class( @@ -102,7 +106,7 @@ fn declare() { const RUNS: usize = 5; let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, HashMap::new()); + let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let block_context = &Default::default(); @@ -134,7 +138,7 @@ fn deploy() { const RUNS: usize = 8; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); state .set_contract_class( @@ -172,7 +176,7 @@ fn invoke() { const RUNS: usize = 100; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); state .set_contract_class( diff --git a/cli/src/main.rs b/cli/src/main.rs index 1248123dd..5f37e400a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -34,7 +34,7 @@ use starknet_in_rust::{ use std::{ collections::HashMap, path::PathBuf, - sync::{Arc, Mutex}, + sync::{Arc, Mutex, RwLock}, }; #[derive(Parser)] @@ -318,7 +318,7 @@ pub async fn start_devnet(port: u16) -> Result<(), std::io::Error> { let cached_state = web::Data::new(AppState { cached_state: Mutex::new(CachedState::::new( Arc::new(InMemoryStateReader::default()), - HashMap::new(), + Arc::new(RwLock::new(HashMap::new())), )), }); diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 2b14e11b4..0f579d265 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -19,7 +19,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, Address}, }; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; use std::{ collections::{HashMap, HashSet}, path::PathBuf, @@ -130,7 +130,10 @@ fn main() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* ------------------------------------ //* Create execution entry point diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 254b26b00..1b918fae2 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -741,7 +741,10 @@ mod transaction_tests { felt::felt_str, state::cached_state::CachedState, }; - use std::{collections::HashMap, sync::Arc}; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; fn test_tx( tx_hash: &str, @@ -754,7 +757,7 @@ mod transaction_tests { // Instantiate the RPC StateReader and the CachedState let block = BlockValue::Number(serde_json::to_value(block_number).unwrap()); let rpc_state = Arc::new(RpcState::new(network, block)); - let mut state = CachedState::new(rpc_state.clone(), HashMap::new()); + let mut state = CachedState::new(rpc_state.clone(), Arc::new(RwLock::new(HashMap::new()))); let fee_token_address = Address(felt_str!( "049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", diff --git a/src/bin/fibonacci.rs b/src/bin/fibonacci.rs index df61410cf..165f1a29a 100644 --- a/src/bin/fibonacci.rs +++ b/src/bin/fibonacci.rs @@ -1,4 +1,8 @@ -use std::{collections::HashMap, path::PathBuf, sync::Arc}; +use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, +}; use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; @@ -92,7 +96,7 @@ fn create_initial_state() -> CachedState { .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - HashMap::new(), + Arc::new(RwLock::new(HashMap::new())), ); cached_state diff --git a/src/bin/invoke.rs b/src/bin/invoke.rs index f29a78ad0..f30a68a0a 100644 --- a/src/bin/invoke.rs +++ b/src/bin/invoke.rs @@ -1,4 +1,8 @@ -use std::{collections::HashMap, path::PathBuf, sync::Arc}; +use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, +}; use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; @@ -106,7 +110,7 @@ fn create_initial_state() -> CachedState { .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - HashMap::new(), + Arc::new(RwLock::new(HashMap::new())), ); cached_state diff --git a/src/bin/invoke_with_cachedstate.rs b/src/bin/invoke_with_cachedstate.rs index 4868a0ab4..435e90249 100644 --- a/src/bin/invoke_with_cachedstate.rs +++ b/src/bin/invoke_with_cachedstate.rs @@ -1,4 +1,8 @@ -use std::{collections::HashMap, path::PathBuf, sync::Arc}; +use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, +}; use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; @@ -111,7 +115,7 @@ fn create_initial_state() -> CachedState { .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - HashMap::new(), + Arc::new(RwLock::new(HashMap::new())), ); cached_state diff --git a/src/core/errors/state_errors.rs b/src/core/errors/state_errors.rs index 29e03846d..4be4f7a21 100644 --- a/src/core/errors/state_errors.rs +++ b/src/core/errors/state_errors.rs @@ -7,21 +7,17 @@ use thiserror::Error; #[derive(Debug, Error)] pub enum StateError { - #[error("Missing ContractClassCache")] - MissingContractClassCache, - #[error("ContractClassCache must be None")] - AssignedContractClassCache, #[error("Missing key in StorageUpdate Map")] EmptyKeyInStorage, #[error("Try to create a CarriedState from a None parent")] ParentCarriedStateIsNone, #[error("Cache already initialized")] StateCacheAlreadyInitialized, - #[error("No contract state assigned for contact address: {0:?}")] + #[error("No contract state assigned for contract address: {0:?}")] NoneContractState(Address), - #[error("No class hash assigned for contact address: {0:?}")] + #[error("No class hash assigned for contract address: {0:?}")] NoneClassHash(Address), - #[error("No nonce assigned for contact address: {0:?}")] + #[error("No nonce assigned for contract address: {0:?}")] NoneNonce(Address), #[error("No storage value assigned for entry: {0:?}")] NoneStorage(StorageEntry), @@ -33,20 +29,16 @@ pub enum StateError { ContractAddressUnavailable(Address), #[error(transparent)] ContractClass(#[from] ContractClassError), - #[error("Missing CasmClassCache")] - MissingCasmClassCache, #[error("Constructor calldata is empty")] - ConstructorCalldataEmpty(), + ConstructorCalldataEmpty, #[error("Error in ExecutionEntryPoint")] - ExecutionEntryPoint(), + ExecutionEntryPoint, #[error("No compiled class found for compiled_class_hash {0:?}")] NoneCompiledClass(ClassHash), #[error("No compiled class hash found for class_hash {0:?}")] NoneCompiledHash(ClassHash), #[error("Missing casm class for hash {0:?}")] MissingCasmClass(ClassHash), - #[error("No class hash declared in class_hash_to_contract_class")] - MissingClassHash(), #[error("Uninitializes class_hash")] UninitiaizedClassHash, #[error(transparent)] diff --git a/src/lib.rs b/src/lib.rs index 1b9a441e6..ee647d886 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,10 @@ #![deny(warnings)] #![forbid(unsafe_code)] #![cfg_attr(coverage_nightly, feature(no_coverage))] -use std::{collections::HashMap, sync::Arc}; +use std::{ + collections::HashMap, + sync::{Arc, RwLock}, +}; use crate::{ execution::{ @@ -61,7 +64,7 @@ pub fn simulate_transaction( ignore_max_fee: bool, skip_nonce_check: bool, ) -> Result, TransactionError> { - let mut cache_state = CachedState::new(Arc::new(state), HashMap::new()); + let mut cache_state = CachedState::new(Arc::new(state), Arc::new(RwLock::new(HashMap::new()))); let mut result = Vec::with_capacity(transactions.len()); for transaction in transactions { let tx_for_simulation = transaction.create_for_simulation( @@ -89,7 +92,8 @@ where T: StateReader, { // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = CachedState::::new(Arc::new(state), HashMap::new()); + let mut cached_state = + CachedState::::new(Arc::new(state), Arc::new(RwLock::new(HashMap::new()))); let mut result = Vec::with_capacity(transactions.len()); for transaction in transactions { @@ -177,7 +181,8 @@ where T: StateReader, { // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = CachedState::::new(Arc::new(state), HashMap::new()); + let mut cached_state = + CachedState::::new(Arc::new(state), Arc::new(RwLock::new(HashMap::new()))); // Check if the contract is deployed. cached_state.get_class_hash_at(l1_handler.contract_address())?; @@ -209,7 +214,7 @@ pub fn execute_transaction( mod test { use std::collections::HashMap; use std::path::PathBuf; - use std::sync::Arc; + use std::sync::{Arc, RwLock}; use crate::core::contract_address::{compute_deprecated_class_hash, compute_sierra_class_hash}; use crate::definitions::constants::INITIAL_GAS_COST; @@ -327,7 +332,10 @@ mod test { .address_to_nonce_mut() .insert(address.clone(), nonce); - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let retdata = call_contract( @@ -368,7 +376,7 @@ mod test { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/l1l2.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -379,14 +387,19 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes let contract_classes = HashMap::from([( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), )]); - state.set_contract_classes(contract_classes).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(contract_classes))) + .unwrap(); let mut block_context = BlockContext::default(); block_context.starknet_os_config.gas_price = 1; @@ -421,7 +434,10 @@ mod test { .address_to_nonce_mut() .insert(address.clone(), nonce); - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let invoke = InvokeFunction::new( @@ -681,7 +697,7 @@ mod test { #[test] fn test_simulate_deploy() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); state .set_contract_class( @@ -723,7 +739,7 @@ mod test { #[test] fn test_simulate_declare() { let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, HashMap::new()); + let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let block_context = &Default::default(); @@ -760,7 +776,7 @@ mod test { #[test] fn test_simulate_invoke() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); state .set_contract_class( @@ -824,7 +840,7 @@ mod test { #[test] fn test_simulate_deploy_account() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); state .set_contract_class( @@ -937,7 +953,7 @@ mod test { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/l1l2.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -948,10 +964,15 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -980,7 +1001,7 @@ mod test { #[test] fn test_deploy_and_invoke_simulation() { let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, HashMap::new()); + let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let block_context = &Default::default(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 29f863b30..58db2546f 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -13,24 +13,26 @@ use getset::{Getters, MutGetters}; use num_traits::Zero; use std::{ collections::{HashMap, HashSet}, - sync::Arc, + sync::{Arc, RwLock}, }; +type ContractClassesCache = Arc>>; + pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; /// Represents a cached state of contract classes with optional caches. -#[derive(Default, Clone, Debug, Eq, Getters, MutGetters, PartialEq)] +#[derive(Default, Clone, Debug, Getters, MutGetters)] pub struct CachedState { pub state_reader: Arc, #[getset(get = "pub", get_mut = "pub")] pub(crate) cache: StateCache, #[get = "pub"] - pub(crate) contract_classes: HashMap, + pub(crate) contract_classes: ContractClassesCache, } impl CachedState { /// Constructor, creates a new cached state. - pub fn new(state_reader: Arc, contract_classes: HashMap) -> Self { + pub fn new(state_reader: Arc, contract_classes: ContractClassesCache) -> Self { Self { cache: StateCache::default(), state_reader, @@ -42,7 +44,7 @@ impl CachedState { pub fn new_for_testing( state_reader: Arc, cache: StateCache, - contract_classes: HashMap, + contract_classes: ContractClassesCache, ) -> Self { Self { cache, @@ -54,11 +56,11 @@ impl CachedState { /// Sets the contract classes cache. pub fn set_contract_classes( &mut self, - contract_classes: HashMap, + contract_classes: ContractClassesCache, ) -> Result<(), StateError> { - if !self.contract_classes.is_empty() { - return Err(StateError::AssignedContractClassCache); - } + // if !self.contract_classes.is_empty() { + // return Err(StateError::AssignedContractClassCache); + // } self.contract_classes = contract_classes; Ok(()) } @@ -150,7 +152,7 @@ impl StateReader for CachedState { } // I: FETCHING FROM CACHE - if let Some(compiled_class) = self.contract_classes.get(class_hash) { + if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { return Ok(compiled_class.clone()); } @@ -158,7 +160,12 @@ impl StateReader for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self.contract_classes.get(compiled_class_hash) { + if let Some(casm_class) = self + .contract_classes + .read() + .unwrap() + .get(compiled_class_hash) + { return Ok(casm_class.clone()); } } @@ -176,6 +183,8 @@ impl State for CachedState { contract_class: &CompiledClass, ) -> Result<(), StateError> { self.contract_classes + .write() + .unwrap() .insert(*class_hash, contract_class.clone()); Ok(()) @@ -381,7 +390,7 @@ impl State for CachedState { // I: FETCHING FROM CACHE // deprecated contract classes dont have compiled class hashes, so we only have one case - if let Some(compiled_class) = self.contract_classes.get(class_hash) { + if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { return Ok(compiled_class.clone()); } @@ -389,7 +398,12 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self.contract_classes.get(compiled_class_hash) { + if let Some(casm_class) = self + .contract_classes + .read() + .unwrap() + .get(compiled_class_hash) + { return Ok(casm_class.clone()); } } @@ -452,7 +466,10 @@ mod tests { .address_to_storage_mut() .insert(storage_entry, storage_value); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); assert_eq!( cached_state.get_class_hash_at(&contract_address).unwrap(), @@ -484,9 +501,14 @@ mod tests { .class_hash_to_compiled_class .insert([1; 32], CompiledClass::Deprecated(Arc::new(contract_class))); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); - cached_state.set_contract_classes(HashMap::new()).unwrap(); + cached_state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); assert_eq!( cached_state.get_contract_class(&[1; 32]).unwrap(), @@ -500,8 +522,10 @@ mod tests { /// This test verifies the correct handling of storage in the cached state. #[test] fn cached_state_storage_test() { - let mut cached_state = - CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let storage_entry: StorageEntry = (Address(31.into()), [0; 32]); let value = Felt252::new(10); @@ -523,7 +547,8 @@ mod tests { let contract_address = Address(32123.into()); - let mut cached_state = CachedState::new(state_reader, HashMap::new()); + let mut cached_state = + CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); assert!(cached_state .deploy_contract(contract_address, [10; 32]) @@ -539,7 +564,8 @@ mod tests { let storage_key = [18; 32]; let value = Felt252::new(912); - let mut cached_state = CachedState::new(state_reader, HashMap::new()); + let mut cached_state = + CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); // set storage_key cached_state.set_storage_at(&(contract_address.clone(), storage_key), value.clone()); @@ -570,7 +596,10 @@ mod tests { let contract_address = Address(0.into()); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); let result = cached_state .deploy_contract(contract_address.clone(), [10; 32]) @@ -595,7 +624,10 @@ mod tests { let contract_address = Address(42.into()); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); cached_state .deploy_contract(contract_address.clone(), [10; 32]) @@ -623,7 +655,10 @@ mod tests { let contract_address = Address(32123.into()); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); cached_state .deploy_contract(contract_address.clone(), [10; 32]) @@ -652,7 +687,10 @@ mod tests { let address_one = Address(Felt252::one()); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); let state_diff = StateDiff { address_to_class_hash: HashMap::from([( @@ -687,7 +725,10 @@ mod tests { #[test] fn count_actual_storage_changes_test() { let state_reader = InMemoryStateReader::default(); - let mut cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); let address_one = Address(1.into()); let address_two = Address(2.into()); diff --git a/src/state/mod.rs b/src/state/mod.rs index 3920165a8..c92f20b1d 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -13,7 +13,10 @@ use crate::{ }; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; use getset::Getters; -use std::{collections::HashMap, sync::Arc}; +use std::{ + collections::HashMap, + sync::{Arc, RwLock}, +}; use crate::{ transaction::error::TransactionError, @@ -166,7 +169,7 @@ impl StateDiff { where T: StateReader + Clone, { - let mut cache_state = CachedState::new(state_reader, HashMap::new()); + let mut cache_state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let cache_storage_mapping = to_cache_state_storage_mapping(&self.storage_updates); cache_state.cache_mut().set_initial_values( @@ -234,7 +237,10 @@ fn test_validate_legal_progress() { #[cfg(test)] mod test { - use std::{collections::HashMap, sync::Arc}; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; use super::StateDiff; use crate::{ @@ -263,7 +269,10 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let cached_state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let cached_state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); let diff = StateDiff::from_cached_state(cached_state).unwrap(); @@ -323,16 +332,18 @@ mod test { .address_to_nonce .insert(contract_address.clone(), nonce); - let cached_state_original = - CachedState::new(Arc::new(state_reader.clone()), HashMap::new()); + let cached_state_original = CachedState::new( + Arc::new(state_reader.clone()), + Arc::new(RwLock::new(HashMap::new())), + ); let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); let cached_state = diff.to_cached_state(Arc::new(state_reader)).unwrap(); assert_eq!( - cached_state_original.contract_classes(), - cached_state.contract_classes() + *cached_state_original.contract_classes().read().unwrap(), + *cached_state.contract_classes().read().unwrap() ); assert_eq!( cached_state_original @@ -371,8 +382,11 @@ mod test { storage_writes, HashMap::new(), ); - let cached_state = - CachedState::new_for_testing(Arc::new(state_reader), cache, HashMap::new()); + let cached_state = CachedState::new_for_testing( + Arc::new(state_reader), + cache, + Arc::new(RwLock::new(HashMap::new())), + ); let mut diff = StateDiff::from_cached_state(cached_state).unwrap(); diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index 7ee047b76..dfc2cd27b 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -224,7 +224,7 @@ fn get_syscall_ptr( /// Unit tests for this module #[cfg(test)] mod tests { - use std::sync::Arc; + use std::sync::{Arc, RwLock}; use super::*; use crate::services::api::contract_classes::compiled_class::CompiledClass; @@ -731,7 +731,10 @@ mod tests { ] ); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -767,7 +770,10 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_CONTRACT_ADDRESS.to_string(), ids_data); // invoke syscall - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -809,7 +815,10 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_TX_SIGNATURE.to_string(), ids_data); // invoke syscall - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -877,7 +886,10 @@ mod tests { let hint_data = HintProcessorData::new_default(STORAGE_READ.to_string(), ids_data); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -942,7 +954,10 @@ mod tests { let hint_data = HintProcessorData::new_default(STORAGE_WRITE.to_string(), ids_data); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -1016,7 +1031,10 @@ mod tests { let hint_data = HintProcessorData::new_default(DEPLOY.to_string(), ids_data); // Create SyscallHintProcessor - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -1026,7 +1044,7 @@ mod tests { .syscall_handler .starknet_storage_state .state - .set_contract_classes(HashMap::new()) + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) .unwrap(); // Set contract class @@ -1117,7 +1135,10 @@ mod tests { ); // Create SyscallHintProcessor - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -1127,7 +1148,7 @@ mod tests { .syscall_handler .starknet_storage_state .state - .set_contract_classes(HashMap::new()) + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) .unwrap(); // Set contract class diff --git a/src/syscalls/deprecated_syscall_response.rs b/src/syscalls/deprecated_syscall_response.rs index bc7d3523f..8ee64896d 100644 --- a/src/syscalls/deprecated_syscall_response.rs +++ b/src/syscalls/deprecated_syscall_response.rs @@ -309,7 +309,10 @@ impl DeprecatedWriteSyscallResponse for DeprecatedStorageReadResponse { #[cfg(test)] mod tests { - use std::{collections::HashMap, sync::Arc}; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; use super::*; use crate::{ @@ -330,7 +333,10 @@ mod tests { #[test] fn write_get_caller_address_response() { // Initialize a VM and syscall handler - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index 97dbf7cb8..da7e6cebf 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -1,5 +1,10 @@ #![allow(unused_imports)] -use std::{collections::HashMap, io::Bytes, path::Path, sync::Arc}; +use std::{ + collections::HashMap, + io::Bytes, + path::Path, + sync::{Arc, RwLock}, +}; use crate::{ call_contract, @@ -75,7 +80,10 @@ fn test_erc20_cairo2() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let name_ = Felt252::from_bytes_be(b"some-token"); let symbol_ = Felt252::from_bytes_be(b"my-super-awesome-token"); diff --git a/src/testing/mod.rs b/src/testing/mod.rs index 018082643..45be1b2e9 100644 --- a/src/testing/mod.rs +++ b/src/testing/mod.rs @@ -3,7 +3,10 @@ pub mod state; pub mod state_error; pub mod type_utils; -use std::{collections::HashMap, sync::Arc}; +use std::{ + collections::HashMap, + sync::{Arc, RwLock}, +}; use cairo_vm::felt::{felt_str, Felt252}; use lazy_static::lazy_static; @@ -158,7 +161,7 @@ pub fn create_account_tx_test_state( } Arc::new(state_reader) }, - HashMap::new(), + Arc::new(RwLock::new(HashMap::new())), ); Ok((block_context, cached_state)) diff --git a/src/testing/state.rs b/src/testing/state.rs index 8158786ce..3c7a18742 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -24,7 +24,7 @@ use crate::{ use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; use std::collections::HashMap; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; // --------------------------------------------------------------------- /// StarkNet testing object. Represents a state of a StarkNet network. @@ -41,7 +41,7 @@ impl StarknetState { let block_context = context.unwrap_or_default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, HashMap::new()); + let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let l2_to_l1_messages = HashMap::new(); let l2_to_l1_messages_log = Vec::new(); @@ -403,6 +403,8 @@ mod tests { starknet_state .state .contract_classes + .read() + .unwrap() .get(&class_hash) .unwrap() .to_owned(), @@ -451,7 +453,10 @@ mod tests { CompiledClass::Deprecated(Arc::new(contract_class.clone())), ); - let state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* -------------------------------------------- //* Create starknet state with previous data diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index ce93bc4b1..115a945ee 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -328,7 +328,11 @@ mod tests { vm::runners::cairo_runner::ExecutionResources, }; use num_traits::{One, Zero}; - use std::{collections::HashMap, path::PathBuf, sync::Arc}; + use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, + }; use crate::{ definitions::{ @@ -379,7 +383,10 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* --------------------------------------- //* Test declare with previous data @@ -539,7 +546,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let _state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); //* --------------------------------------- //* Test declare with previous data @@ -605,7 +612,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let _state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); //* --------------------------------------- //* Test declare with previous data @@ -670,7 +677,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); //* --------------------------------------- //* Test declare with previous data @@ -749,7 +756,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); //* --------------------------------------- //* Test declare with previous data @@ -796,7 +803,7 @@ mod tests { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, contract_class_cache); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(contract_class_cache))); // There are no account contracts in the state, so the transaction should fail let fib_contract_class = @@ -856,7 +863,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); //* --------------------------------------- //* Test declare with previous data diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 577c0738b..39a69769f 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -455,7 +455,7 @@ impl DeclareV2 { #[cfg(test)] mod tests { - use std::sync::Arc; + use std::sync::{Arc, RwLock}; use std::{collections::HashMap, fs::File, io::BufReader, path::PathBuf}; use super::DeclareV2; @@ -515,7 +515,10 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, casm_contract_class_cache); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(casm_contract_class_cache)), + ); // call compile and store assert!(internal_declare @@ -584,7 +587,10 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, casm_contract_class_cache); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(casm_contract_class_cache)), + ); // call compile and store assert!(internal_declare @@ -655,7 +661,10 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, casm_contract_class_cache); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(casm_contract_class_cache)), + ); // call compile and store assert!(internal_declare @@ -724,7 +733,10 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, casm_contract_class_cache); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(casm_contract_class_cache)), + ); // call compile and store assert!(internal_declare @@ -794,7 +806,10 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = HashMap::new(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, casm_contract_class_cache); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(casm_contract_class_cache)), + ); let expected_err = format!( "Invalid compiled class, expected class hash: {}, but received: {}", diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index b65e8559e..4862d4142 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -305,7 +305,10 @@ impl Deploy { #[cfg(test)] mod tests { - use std::{collections::HashMap, sync::Arc}; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; use super::*; use crate::{ @@ -317,7 +320,7 @@ mod tests { fn invoke_constructor_test() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); // Set contract_class let contract_class = @@ -365,7 +368,7 @@ mod tests { fn invoke_constructor_no_calldata_should_fail() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let contract_class = ContractClass::from_path("starknet_programs/constructor.json").unwrap(); @@ -394,7 +397,7 @@ mod tests { fn deploy_contract_without_constructor_should_fail() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); let contract_path = "starknet_programs/amm.json"; let contract_class = ContractClass::from_path(contract_path).unwrap(); diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index eccb34117..b9bdf6753 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -385,7 +385,11 @@ impl DeployAccount { #[cfg(test)] mod tests { - use std::{collections::HashMap, path::PathBuf, sync::Arc}; + use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, + }; use super::*; use crate::{ @@ -406,7 +410,10 @@ mod tests { let class_hash = felt_to_hash(&hash); let block_context = BlockContext::default(); - let mut _state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut _state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let internal_deploy = DeployAccount::new( class_hash, @@ -438,7 +445,10 @@ mod tests { let class_hash = felt_to_hash(&hash); let block_context = BlockContext::default(); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let internal_deploy = DeployAccount::new( class_hash, @@ -488,7 +498,10 @@ mod tests { let class_hash = felt_to_hash(&hash); let block_context = BlockContext::default(); - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let internal_deploy = DeployAccount::new( class_hash, diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 818c62a54..92806ba2e 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -185,7 +185,10 @@ pub fn charge_fee( #[cfg(test)] mod tests { - use std::{collections::HashMap, sync::Arc}; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; use crate::{ definitions::block_context::BlockContext, @@ -196,7 +199,10 @@ mod tests { #[test] fn test_charge_fee_v0_actual_fee_exceeds_max_fee_should_return_error() { - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut tx_execution_context = TransactionExecutionContext::default(); let mut block_context = BlockContext::default(); block_context.starknet_os_config.gas_price = 1; @@ -222,7 +228,10 @@ mod tests { #[test] fn test_charge_fee_v1_actual_fee_exceeds_max_fee_should_return_error() { - let mut state = CachedState::new(Arc::new(InMemoryStateReader::default()), HashMap::new()); + let mut state = CachedState::new( + Arc::new(InMemoryStateReader::default()), + Arc::new(RwLock::new(HashMap::new())), + ); let mut tx_execution_context = TransactionExecutionContext { version: 1.into(), ..Default::default() diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index ef707f510..c6840f4a4 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -410,7 +410,10 @@ mod tests { }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; use num_traits::Num; - use std::{collections::HashMap, sync::Arc}; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; #[test] fn test_invoke_apply_without_fees() { @@ -441,7 +444,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -452,10 +455,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -513,7 +521,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -524,10 +532,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -581,7 +594,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/amm.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -592,10 +605,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -643,7 +661,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -654,10 +672,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -711,7 +734,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/amm.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -722,10 +745,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -752,7 +780,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let nonce = Felt252::zero(); state_reader @@ -784,10 +812,15 @@ mod tests { skip_nonce_check: false, }; - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -833,7 +866,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -844,10 +877,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -894,7 +932,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -905,10 +943,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -960,7 +1003,7 @@ mod tests { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -971,10 +1014,15 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( @@ -1119,7 +1167,10 @@ mod tests { casm_contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state = CachedState::new(Arc::new(state_reader), casm_contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(casm_contract_class_cache)), + ); let state_before_execution = state.clone(); diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index 4f84c910d..c1382508e 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -208,7 +208,7 @@ impl L1Handler { mod test { use std::{ collections::{HashMap, HashSet}, - sync::Arc, + sync::{Arc, RwLock}, }; use crate::services::api::contract_classes::{ @@ -257,7 +257,7 @@ mod test { // Set contract_class let class_hash = [1; 32]; let contract_class = ContractClass::from_path("starknet_programs/l1l2.json").unwrap(); - // Set contact_state + // Set contract_state let contract_address = Address(0.into()); let nonce = Felt252::zero(); @@ -268,10 +268,15 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(HashMap::new())), + ); // Initialize state.contract_classes - state.set_contract_classes(HashMap::new()).unwrap(); + state + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); state .set_contract_class( diff --git a/starknet_programs/syscalls.cairo b/starknet_programs/syscalls.cairo index 010f8374c..930092240 100644 --- a/starknet_programs/syscalls.cairo +++ b/starknet_programs/syscalls.cairo @@ -72,10 +72,10 @@ func test_call_contract{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_ch let (value) = lib_state.read(); assert value = 10; - let (call_contact_address) = ISyscallsLib.stateful_get_contract_address( + let (call_contract_address) = ISyscallsLib.stateful_get_contract_address( contract_address=contract_address ); - assert call_contact_address = contract_address; + assert call_contract_address = contract_address; return (); } @@ -181,11 +181,11 @@ func test_library_call{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_che let (value) = lib_state.read(); assert value = 11; - let self_contact_address = get_contract_address(); - let call_contact_address = ISyscallsLib.library_call_stateful_get_contract_address( + let self_contract_address = get_contract_address(); + let call_contract_address = ISyscallsLib.library_call_stateful_get_contract_address( class_hash=0x0202020202020202020202020202020202020202020202020202020202020202 ); - assert self_contact_address = call_contact_address; + assert self_contract_address = call_contract_address; return (); } @@ -255,7 +255,7 @@ func test_deploy_with_constructor{syscall_ptr: felt*}( // Set constructor. let (ptr) = alloc(); assert [ptr] = constructor; - + let contract_address = deploy( class_hash, contract_address_salt, @@ -276,7 +276,7 @@ func test_deploy_and_call_contract{syscall_ptr: felt*, pedersen_ptr: HashBuiltin // Set constructor. let (ptr) = alloc(); assert [ptr] = constructor; - + // Deploy contract let (contract_address) = deploy( class_hash, diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index 9e7cc02a3..06a081bc1 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -1,6 +1,6 @@ use std::{ collections::{HashMap, HashSet}, - sync::Arc, + sync::{Arc, RwLock}, }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; @@ -75,7 +75,10 @@ fn storage_write_read() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -238,7 +241,10 @@ fn library_call() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -407,7 +413,10 @@ fn call_contract_storage_write_read() { .insert(simple_wallet_address.clone(), simple_wallet_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -563,7 +572,10 @@ fn emit_event() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [].to_vec(); @@ -680,7 +692,10 @@ fn deploy_cairo1_from_cairo1() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -780,7 +795,10 @@ fn deploy_cairo0_from_cairo1_without_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -879,7 +897,10 @@ fn deploy_cairo0_from_cairo1_with_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt, address.0.clone(), Felt252::zero()].to_vec(); @@ -979,7 +1000,10 @@ fn deploy_cairo0_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state: CachedState<_> = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state: CachedState<_> = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1099,7 +1123,10 @@ fn test_send_message_to_l1_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // RUN SEND_MSG // Create an execution entry point @@ -1192,7 +1219,10 @@ fn test_get_execution_info() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -1304,7 +1334,10 @@ fn replace_class_internal() { ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Run upgrade entrypoint and check that the storage was updated with the new contract class // Create an execution entry point @@ -1435,7 +1468,10 @@ fn replace_class_contract_call() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1610,7 +1646,10 @@ fn replace_class_contract_call_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1733,7 +1772,10 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1854,7 +1896,10 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1971,7 +2016,10 @@ fn call_contract_replace_class_cairo_0() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -2047,7 +2095,10 @@ fn test_out_of_gas_failure() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [].to_vec(); @@ -2124,7 +2175,10 @@ fn deploy_syscall_failure_uninitialized_class_hash() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [Felt252::zero()].to_vec(); @@ -2212,7 +2266,10 @@ fn deploy_syscall_failure_in_constructor() { ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [f_c_class_hash].to_vec(); @@ -2290,7 +2347,10 @@ fn storage_read_no_value() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2361,7 +2421,10 @@ fn storage_read_unavailable_address_domain() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2435,7 +2498,10 @@ fn storage_write_unavailable_address_domain() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2530,7 +2596,10 @@ fn library_call_failure() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -2642,7 +2711,10 @@ fn send_messages_to_l1_different_contract_calls() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2762,7 +2834,10 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2883,7 +2958,10 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2977,7 +3055,10 @@ fn keccak_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index 6f987ed64..ac178bbec 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -1,5 +1,5 @@ use std::collections::{HashMap, HashSet}; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; use cairo_vm::vm::runners::builtin_runner::HASH_BUILTIN_NAME; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; @@ -54,7 +54,10 @@ fn swap(calldata: &[Felt252], call_config: &mut CallConfig) -> Result CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); - CachedState::new(Arc::new(in_memory_state_reader), HashMap::new()) + CachedState::new( + Arc::new(in_memory_state_reader), + Arc::new(RwLock::new(HashMap::new())), + ) } fn expected_state_after_tx(fee: u128) -> CachedState { @@ -234,7 +237,7 @@ fn expected_state_after_tx(fee: u128) -> CachedState { CachedState::new_for_testing( Arc::new(in_memory_state_reader), state_cache_after_invoke_tx(fee), - contract_classes_cache, + Arc::new(RwLock::new(contract_classes_cache)), ) } @@ -525,8 +528,8 @@ fn test_create_account_tx_test_state() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - &state.contract_classes(), - &expected_initial_state.contract_classes() + *state.contract_classes().read().unwrap(), + *expected_initial_state.contract_classes().read().unwrap() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -871,8 +874,8 @@ fn test_declare_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - &state.contract_classes(), - &expected_initial_state.contract_classes() + *state.contract_classes().read().unwrap(), + *expected_initial_state.contract_classes().read().unwrap() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -955,8 +958,8 @@ fn test_declarev2_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - &state.contract_classes(), - &expected_initial_state.contract_classes() + *state.contract_classes().read().unwrap(), + *expected_initial_state.contract_classes().read().unwrap() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -1297,8 +1300,8 @@ fn test_invoke_tx_state() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - &state.contract_classes(), - &expected_initial_state.contract_classes() + *state.contract_classes().read().unwrap(), + *expected_initial_state.contract_classes().read().unwrap() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -1370,8 +1373,8 @@ fn test_invoke_with_declarev2_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - &state.contract_classes(), - &expected_initial_state.contract_classes() + *state.contract_classes().read().unwrap(), + *expected_initial_state.contract_classes().read().unwrap() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -1467,7 +1470,10 @@ fn test_deploy_account() { let (state_before, state_after) = expected_deploy_account_states(); assert_eq!(&state.cache(), &state_before.cache()); - assert_eq!(&state.contract_classes(), &state_before.contract_classes()); + assert_eq!( + *state.contract_classes().read().unwrap(), + *state_before.contract_classes().read().unwrap() + ); let tx_info = deploy_account_tx .execute(&mut state, &block_context) @@ -1590,7 +1596,7 @@ fn expected_deploy_account_states() -> ( ]), HashMap::new(), )), - HashMap::new(), + Arc::new(RwLock::new(HashMap::new())), ); state_before.set_storage_at( &( diff --git a/tests/multi_syscall_test.rs b/tests/multi_syscall_test.rs index 9f75e7925..bcc271b9b 100644 --- a/tests/multi_syscall_test.rs +++ b/tests/multi_syscall_test.rs @@ -14,6 +14,7 @@ use starknet_in_rust::{ state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{Address, ClassHash}, }; +use std::sync::RwLock; use std::{collections::HashMap, sync::Arc, vec}; #[test] @@ -39,7 +40,10 @@ fn test_multiple_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache.clone()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache.clone())), + ); // Create an execution entry point let calldata = [].to_vec(); @@ -60,7 +64,7 @@ fn test_multiple_syscall() { assert_eq!(call_info.retdata, vec![caller_address.clone().0]) } - // Block for get_contact_address. + // Block for get_contract_address. { let call_info = test_syscall( "contract_address", diff --git a/tests/storage.rs b/tests/storage.rs index f13bc141c..5565d536f 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -13,7 +13,7 @@ use starknet_in_rust::{ state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{calculate_sn_keccak, Address}, }; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; use std::{ collections::{HashMap, HashSet}, path::PathBuf, @@ -70,7 +70,10 @@ fn integration_storage_test() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* ------------------------------------ //* Create execution entry point diff --git a/tests/syscalls.rs b/tests/syscalls.rs index 03bfd188f..58d0b7ad3 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -34,7 +34,7 @@ use std::{ collections::{HashMap, HashSet}, iter::empty, path::{Path, PathBuf}, - sync::Arc, + sync::{Arc, RwLock}, }; #[allow(clippy::too_many_arguments)] @@ -121,7 +121,10 @@ fn test_contract<'a>( contract_class_cache }; - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); storage_entries .into_iter() .for_each(|(a, b, c)| state.set_storage_at(&(a, b), c)); @@ -1109,7 +1112,10 @@ fn deploy_cairo1_from_cairo0_with_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt, Felt252::one()].to_vec(); @@ -1211,7 +1217,10 @@ fn deploy_cairo1_from_cairo0_without_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1315,7 +1324,10 @@ fn deploy_cairo1_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1455,7 +1467,10 @@ fn send_messages_to_l1_different_contract_calls() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); diff --git a/tests/syscalls_errors.rs b/tests/syscalls_errors.rs index 1e9433e93..a1f0043b0 100644 --- a/tests/syscalls_errors.rs +++ b/tests/syscalls_errors.rs @@ -15,7 +15,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, Address, ClassHash}, }; use std::path::Path; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; use assert_matches::assert_matches; use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; @@ -101,7 +101,10 @@ fn test_contract<'a>( contract_class_cache }; - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); storage_entries .into_iter() .for_each(|(a, b, c)| state.set_storage_at(&(a, b), c)); From 08506e0b9246e2682e27a331706c310ff1321d1f Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 15:58:47 +0200 Subject: [PATCH 06/56] Minor fixes. --- src/syscalls/business_logic_syscall_handler.rs | 4 ++-- src/syscalls/deprecated_business_logic_syscall_handler.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index 61baaf6aa..b5a27da59 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -336,7 +336,7 @@ impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { if self.constructor_entry_points_empty(compiled_class)? { if !constructor_calldata.is_empty() { - return Err(StateError::ConstructorCalldataEmpty()); + return Err(StateError::ConstructorCalldataEmpty); } let call_info = CallInfo::empty_constructor_call( @@ -373,7 +373,7 @@ impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { self.support_reverted, self.block_context.invoke_tx_max_n_steps, ) - .map_err(|_| StateError::ExecutionEntryPoint())?; + .map_err(|_| StateError::ExecutionEntryPoint)?; let call_info = call_info.ok_or(StateError::CustomError( revert_error.unwrap_or("Execution error".to_string()), diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 25e473abf..6c8054065 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -208,7 +208,7 @@ impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { if self.constructor_entry_points_empty(contract_class)? { if !constructor_calldata.is_empty() { - return Err(StateError::ConstructorCalldataEmpty()); + return Err(StateError::ConstructorCalldataEmpty); } let call_info = CallInfo::empty_constructor_call( @@ -241,7 +241,7 @@ impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { false, self.block_context.invoke_tx_max_n_steps, ) - .map_err(|_| StateError::ExecutionEntryPoint())?; + .map_err(|_| StateError::ExecutionEntryPoint)?; Ok(()) } } From 01e01646b516784c41318e9fca18b62aeb0af611 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 18:16:44 +0200 Subject: [PATCH 07/56] Fix testing state generation to make it work with shared caches. --- tests/internals.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/internals.rs b/tests/internals.rs index 5631249cb..559f2ced8 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -1607,6 +1607,13 @@ fn expected_deploy_account_states() -> ( ); let mut state_after = state_before.clone(); + + // Make the contract cache independent (otherwise tests will fail because the initial state's + // cache will not be empty anymore). + state_after + .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) + .unwrap(); + state_after.cache_mut().nonce_initial_values_mut().insert( Address(felt_str!( "386181506763903095743576862849245034886954647214831045800703908858571591162" From 3ec883bee934a2175a58930ab8cef55718e918fc Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 18:58:48 +0200 Subject: [PATCH 08/56] Fix formatting. --- src/state/cached_state.rs | 31 +++++++++++++++++++++++++++++++ src/transaction/declare.rs | 25 ++++++++++++++++++++----- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 58db2546f..b3c6188bc 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -13,6 +13,7 @@ use getset::{Getters, MutGetters}; use num_traits::Zero; use std::{ collections::{HashMap, HashSet}, + mem, sync::{Arc, RwLock}, }; @@ -427,6 +428,36 @@ impl State for CachedState { } } +pub fn merge_caches( + shared: &RwLock>, + mut private: HashMap, +) { + // FIXME: Parallel invocation of `merge_caches()` may cause data loss. Example: + // - Thread A: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. + // - Thread B: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. + // - Thread A: Updates the shared cache. It now contains A's specific entries. + // - Thread B: Updates the shared cache. It now contains only B's specific entries, since it + // lost A's ones. + + // Extend private to contain all of shared's entries. Using a readonly lock will avoid blocking + // the other potential cache readers. + { + let shared_lock = shared.read().unwrap(); + private.extend(shared_lock.iter().map(|(k, v)| (*k, v.clone()))); + } + + // Swap the active cache to apply the changes. This will delay `private`'s destructor, which + // will run after the write lock has been dropped. + { + let mut shared_lock = shared.write().unwrap(); + mem::swap(&mut *shared_lock, &mut private); + } +} + +pub fn take_cache() { + todo!() +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index 115a945ee..cdbb9519d 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -546,7 +546,10 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); + let _state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* --------------------------------------- //* Test declare with previous data @@ -612,7 +615,10 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); + let _state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* --------------------------------------- //* Test declare with previous data @@ -677,7 +683,10 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* --------------------------------------- //* Test declare with previous data @@ -756,7 +765,10 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* --------------------------------------- //* Test declare with previous data @@ -863,7 +875,10 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache))); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(RwLock::new(contract_class_cache)), + ); //* --------------------------------------- //* Test declare with previous data From 1847cf1ef2ede5d5335452238067e3d283ad0f6b Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 19:39:26 +0200 Subject: [PATCH 09/56] Add cache diff. --- src/state/cached_state.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index b3c6188bc..76acbfc15 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -29,6 +29,7 @@ pub struct CachedState { pub(crate) cache: StateCache, #[get = "pub"] pub(crate) contract_classes: ContractClassesCache, + pub(crate) contract_classes_private: HashMap, } impl CachedState { @@ -38,6 +39,7 @@ impl CachedState { cache: StateCache::default(), state_reader, contract_classes, + contract_classes_private: HashMap::new(), } } @@ -49,8 +51,9 @@ impl CachedState { ) -> Self { Self { cache, - contract_classes, state_reader, + contract_classes, + contract_classes_private: HashMap::new(), } } @@ -59,9 +62,6 @@ impl CachedState { &mut self, contract_classes: ContractClassesCache, ) -> Result<(), StateError> { - // if !self.contract_classes.is_empty() { - // return Err(StateError::AssignedContractClassCache); - // } self.contract_classes = contract_classes; Ok(()) } @@ -153,7 +153,9 @@ impl StateReader for CachedState { } // I: FETCHING FROM CACHE - if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { + if let Some(compiled_class) = self.contract_classes_private.get(class_hash) { + return Ok(compiled_class.clone()); + } else if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { return Ok(compiled_class.clone()); } @@ -161,7 +163,9 @@ impl StateReader for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self + if let Some(casm_class) = self.contract_classes_private.get(compiled_class_hash) { + return Ok(casm_class.clone()); + } else if let Some(casm_class) = self .contract_classes .read() .unwrap() @@ -183,9 +187,7 @@ impl State for CachedState { class_hash: &ClassHash, contract_class: &CompiledClass, ) -> Result<(), StateError> { - self.contract_classes - .write() - .unwrap() + self.contract_classes_private .insert(*class_hash, contract_class.clone()); Ok(()) @@ -391,7 +393,9 @@ impl State for CachedState { // I: FETCHING FROM CACHE // deprecated contract classes dont have compiled class hashes, so we only have one case - if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { + if let Some(compiled_class) = self.contract_classes_private.get(class_hash) { + return Ok(compiled_class.clone()); + } else if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { return Ok(compiled_class.clone()); } @@ -399,7 +403,9 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self + if let Some(casm_class) = self.contract_classes_private.get(compiled_class_hash) { + return Ok(casm_class.clone()); + } else if let Some(casm_class) = self .contract_classes .read() .unwrap() @@ -454,8 +460,11 @@ pub fn merge_caches( } } -pub fn take_cache() { - todo!() +pub fn take_cache(state: CachedState) -> HashMap +where + T: StateReader, +{ + state.contract_classes_private } #[cfg(test)] From a8e7c0d874e324e97abaa46fc757d6b91285856e Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 24 Aug 2023 19:43:35 +0200 Subject: [PATCH 10/56] Add suggestion. --- src/state/cached_state.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 76acbfc15..c448a3fa4 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -29,6 +29,8 @@ pub struct CachedState { pub(crate) cache: StateCache, #[get = "pub"] pub(crate) contract_classes: ContractClassesCache, + // TODO: Should the private cache be updated with the contracts that already exist in the shared + // level? It should keep the contracts used by the transaction closer. pub(crate) contract_classes_private: HashMap, } From a4e493d12e7bafb00020a837ffecede5300d966b Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 29 Aug 2023 12:07:04 +0200 Subject: [PATCH 11/56] Fix stuff. --- src/execution/execution_entry_point.rs | 8 ++++---- src/state/cached_state.rs | 6 ++++-- src/testing/state.rs | 8 ++------ tests/internals.rs | 5 +++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index b16b500a9..1ddeb6846 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -305,10 +305,10 @@ impl ExecutionEntryPoint { /// Returns the hash of the executed contract class. fn get_code_class_hash(&self, state: &mut S) -> Result<[u8; 32], TransactionError> { if self.class_hash.is_some() { - match self.call_type { - CallType::Delegate => return Ok(self.class_hash.unwrap()), - _ => return Err(TransactionError::CallTypeIsNotDelegate), - } + return match self.call_type { + CallType::Delegate => Ok(self.class_hash.unwrap()), + _ => Err(TransactionError::CallTypeIsNotDelegate), + }; } let code_address = match self.call_type { CallType::Call => Some(self.contract_address.clone()), diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index c448a3fa4..c24fb8c30 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -29,8 +29,6 @@ pub struct CachedState { pub(crate) cache: StateCache, #[get = "pub"] pub(crate) contract_classes: ContractClassesCache, - // TODO: Should the private cache be updated with the contracts that already exist in the shared - // level? It should keep the contracts used by the transaction closer. pub(crate) contract_classes_private: HashMap, } @@ -398,6 +396,8 @@ impl State for CachedState { if let Some(compiled_class) = self.contract_classes_private.get(class_hash) { return Ok(compiled_class.clone()); } else if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { + self.contract_classes_private + .insert(*class_hash, compiled_class.clone()); return Ok(compiled_class.clone()); } @@ -413,6 +413,8 @@ impl State for CachedState { .unwrap() .get(compiled_class_hash) { + self.contract_classes_private + .insert(*class_hash, casm_class.clone()); return Ok(casm_class.clone()); } } diff --git a/src/testing/state.rs b/src/testing/state.rs index 3c7a18742..f34718c93 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -402,12 +402,8 @@ mod tests { assert_eq!( starknet_state .state - .contract_classes - .read() - .unwrap() - .get(&class_hash) - .unwrap() - .to_owned(), + .get_contract_class(&class_hash) + .unwrap(), CompiledClass::Deprecated(Arc::new(contract_class)) ); } diff --git a/tests/internals.rs b/tests/internals.rs index 559f2ced8..cd80ea00a 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -2049,12 +2049,13 @@ fn test_library_call_with_declare_v2() { let casm_contract_hash; #[cfg(not(feature = "cairo_1_tests"))] { - casm_contract_hash = TEST_FIB_COMPILED_CONTRACT_CLASS_HASH_CAIRO2.clone() + casm_contract_hash = TEST_FIB_COMPILED_CONTRACT_CLASS_HASH_CAIRO2.clone(); } #[cfg(feature = "cairo_1_tests")] { - casm_contract_hash = TEST_FIB_COMPILED_CONTRACT_CLASS_HASH_CAIRO1.clone() + casm_contract_hash = TEST_FIB_COMPILED_CONTRACT_CLASS_HASH_CAIRO1.clone(); } + // Create an execution entry point let calldata = vec![ casm_contract_hash, From a91efdc762db9ba738064148b0e3a4d7ab75b6f9 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 30 Aug 2023 19:56:16 +0200 Subject: [PATCH 12/56] Implement cache trait. Add a null and a permanent cache. Fix everything that breaks using the permanent cache (should mimic the previous behaviour). --- bench/internals.rs | 26 +- cli/src/main.rs | 20 +- fuzzer/src/main.rs | 40 +-- rpc_state_reader/src/lib.rs | 12 +- src/bin/fibonacci.rs | 23 +- src/bin/invoke.rs | 23 +- src/bin/invoke_with_cachedstate.rs | 8 +- src/execution/execution_entry_point.rs | 68 ++--- src/lib.rs | 234 ++++++++++-------- src/runner/mod.rs | 26 +- src/state/cached_state.rs | 176 ++++++------- src/state/contract_class_cache.rs | 105 ++++++++ src/state/contract_storage_state.rs | 9 +- src/state/mod.rs | 68 +++-- .../business_logic_syscall_handler.rs | 16 +- ...precated_business_logic_syscall_handler.rs | 32 +-- src/syscalls/deprecated_syscall_handler.rs | 104 ++++---- src/syscalls/deprecated_syscall_response.rs | 14 +- src/syscalls/syscall_handler.rs | 20 +- src/testing/erc20.rs | 8 +- src/testing/mod.rs | 41 +-- src/testing/state.rs | 35 +-- src/transaction/declare.rs | 93 ++++--- src/transaction/declare_v2.rs | 40 +-- src/transaction/deploy.rs | 72 +++--- src/transaction/deploy_account.rs | 64 ++--- src/transaction/fee.rs | 45 ++-- src/transaction/invoke_function.rs | 108 +++----- src/transaction/l1_handler.rs | 45 ++-- src/transaction/mod.rs | 37 +-- tests/cairo_1_syscalls.rs | 194 ++++++++------- tests/complex_contracts/amm_contracts/amm.rs | 22 +- .../amm_contracts/amm_proxy.rs | 32 +-- tests/complex_contracts/nft/erc721.rs | 31 +-- tests/complex_contracts/utils.rs | 11 +- tests/delegate_call.rs | 27 +- tests/delegate_l1_handler.rs | 23 +- tests/deploy_account.rs | 31 +-- tests/fibonacci.rs | 40 +-- tests/increase_balance.rs | 27 +- tests/internal_calls.rs | 32 ++- tests/internals.rs | 202 +++++++++------ tests/multi_syscall_test.rs | 25 +- tests/storage.rs | 23 +- tests/syscalls.rs | 42 ++-- tests/syscalls_errors.rs | 33 +-- 46 files changed, 1353 insertions(+), 1054 deletions(-) create mode 100644 src/state/contract_class_cache.rs diff --git a/bench/internals.rs b/bench/internals.rs index 0780b932f..5d811df55 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -14,13 +14,15 @@ use starknet_in_rust::{ services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, - state::in_memory_state_reader::InMemoryStateReader, state::{cached_state::CachedState, state_api::State}, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, transaction::{declare::Declare, Deploy, DeployAccount, InvokeFunction}, utils::Address, }; use std::{ - collections::HashMap, hint::black_box, sync::{Arc, RwLock}, }; @@ -67,7 +69,10 @@ fn deploy_account() { const RUNS: usize = 500; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); state .set_contract_class( @@ -106,7 +111,10 @@ fn declare() { const RUNS: usize = 5; let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let block_context = &Default::default(); @@ -138,7 +146,10 @@ fn deploy() { const RUNS: usize = 8; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); state .set_contract_class( @@ -176,7 +187,10 @@ fn invoke() { const RUNS: usize = 100; let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); state .set_contract_class( diff --git a/cli/src/main.rs b/cli/src/main.rs index 5f37e400a..847c326fd 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -27,12 +27,14 @@ use starknet_in_rust::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, state::{cached_state::CachedState, state_api::State}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager, + }, transaction::{error::TransactionError, InvokeFunction}, utils::{felt_to_hash, string_to_hash, Address}, }; use std::{ - collections::HashMap, path::PathBuf, sync::{Arc, Mutex, RwLock}, }; @@ -102,11 +104,11 @@ struct DevnetArgs { } struct AppState { - cached_state: Mutex>, + cached_state: Mutex>, } fn declare_parser( - cached_state: &mut CachedState, + cached_state: &mut CachedState, args: &DeclareArgs, ) -> Result<(Felt252, Felt252), ParserError> { let contract_class = @@ -129,7 +131,7 @@ fn declare_parser( } fn deploy_parser( - cached_state: &mut CachedState, + cached_state: &mut CachedState, args: &DeployArgs, ) -> Result<(Felt252, Felt252), ParserError> { let constructor_calldata = match &args.inputs { @@ -155,7 +157,7 @@ fn deploy_parser( } fn invoke_parser( - cached_state: &mut CachedState, + cached_state: &mut CachedState, args: &InvokeArgs, ) -> Result<(Felt252, Felt252), ParserError> { let contract_address = Address( @@ -217,7 +219,7 @@ fn invoke_parser( } fn call_parser( - cached_state: &mut CachedState, + cached_state: &mut CachedState, args: &CallArgs, ) -> Result, ParserError> { let contract_address = Address( @@ -316,9 +318,9 @@ async fn call_req(data: web::Data, args: web::Json) -> HttpR pub async fn start_devnet(port: u16) -> Result<(), std::io::Error> { let cached_state = web::Data::new(AppState { - cached_state: Mutex::new(CachedState::::new( + cached_state: Mutex::new(CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), )), }); diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 0f579d265..3f3839c26 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -3,34 +3,36 @@ #[macro_use] extern crate honggfuzz; -use cairo_vm::felt::Felt252; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; use num_traits::Zero; -use starknet_in_rust::execution::execution_entry_point::ExecutionResult; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, CallType, TransactionExecutionContext, + }, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + ExecutionResourcesManager, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{calculate_sn_keccak, Address}, + EntryPointType, }; - -use std::sync::{Arc, RwLock}; use std::{ - collections::{HashMap, HashSet}, + collections::HashSet, + fs, path::PathBuf, + process::Command, + sync::{Arc, RwLock}, + thread, + time::Duration, }; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use std::fs; -use std::process::Command; -use std::thread; -use std::time::Duration; - fn main() { println!("Starting fuzzer"); let mut iteration = 0; @@ -110,14 +112,14 @@ fn main() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let address = Address(1111.into()); let class_hash = [1; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 1b918fae2..58b380035 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -739,12 +739,9 @@ mod transaction_tests { }, execution::TransactionExecutionInfo, felt::felt_str, - state::cached_state::CachedState, - }; - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, + state::{cached_state::CachedState, contract_class_cache::PermanentContractClassCache}, }; + use std::sync::{Arc, RwLock}; fn test_tx( tx_hash: &str, @@ -757,7 +754,10 @@ mod transaction_tests { // Instantiate the RPC StateReader and the CachedState let block = BlockValue::Number(serde_json::to_value(block_number).unwrap()); let rpc_state = Arc::new(RpcState::new(network, block)); - let mut state = CachedState::new(rpc_state.clone(), Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + rpc_state.clone(), + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let fee_token_address = Address(felt_str!( "049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", diff --git a/src/bin/fibonacci.rs b/src/bin/fibonacci.rs index 165f1a29a..221623606 100644 --- a/src/bin/fibonacci.rs +++ b/src/bin/fibonacci.rs @@ -1,22 +1,21 @@ -use std::{ - collections::HashMap, - path::PathBuf, - sync::{Arc, RwLock}, -}; - use cairo_vm::felt::{felt_str, Felt252}; -use num_traits::Zero; - use lazy_static::lazy_static; +use num_traits::Zero; use starknet_in_rust::{ services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, - state::cached_state::CachedState, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, testing::state::StarknetState, utils::Address, }; +use std::{ + path::PathBuf, + sync::{Arc, RwLock}, +}; #[cfg(feature = "with_mimalloc")] use mimalloc::MiMalloc; @@ -75,7 +74,7 @@ fn main() { } } -fn create_initial_state() -> CachedState { +fn create_initial_state() -> CachedState { let cached_state = CachedState::new( { let mut state_reader = InMemoryStateReader::default(); @@ -96,7 +95,7 @@ fn create_initial_state() -> CachedState { .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); cached_state diff --git a/src/bin/invoke.rs b/src/bin/invoke.rs index f30a68a0a..cce8d469b 100644 --- a/src/bin/invoke.rs +++ b/src/bin/invoke.rs @@ -1,23 +1,22 @@ -use std::{ - collections::HashMap, - path::PathBuf, - sync::{Arc, RwLock}, -}; - use cairo_vm::felt::{felt_str, Felt252}; +use lazy_static::lazy_static; use num_traits::Zero; - use starknet_in_rust::{ services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, state::cached_state::CachedState, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, testing::state::StarknetState, utils::Address, }; - -use lazy_static::lazy_static; +use std::{ + path::PathBuf, + sync::{Arc, RwLock}, +}; #[cfg(feature = "with_mimalloc")] use mimalloc::MiMalloc; @@ -89,7 +88,7 @@ fn main() { } } -fn create_initial_state() -> CachedState { +fn create_initial_state() -> CachedState { let cached_state = CachedState::new( { let mut state_reader = InMemoryStateReader::default(); @@ -110,7 +109,7 @@ fn create_initial_state() -> CachedState { .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); cached_state diff --git a/src/bin/invoke_with_cachedstate.rs b/src/bin/invoke_with_cachedstate.rs index 435e90249..ad7c99feb 100644 --- a/src/bin/invoke_with_cachedstate.rs +++ b/src/bin/invoke_with_cachedstate.rs @@ -16,7 +16,9 @@ use starknet_in_rust::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, state::in_memory_state_reader::InMemoryStateReader, - state::{cached_state::CachedState, BlockInfo}, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, BlockInfo, + }, transaction::InvokeFunction, utils::Address, }; @@ -94,7 +96,7 @@ fn main() { } } -fn create_initial_state() -> CachedState { +fn create_initial_state() -> CachedState { let cached_state = CachedState::new( { let mut state_reader = InMemoryStateReader::default(); @@ -115,7 +117,7 @@ fn create_initial_state() -> CachedState { .insert((CONTRACT_ADDRESS.clone(), [0; 32]), Felt252::zero()); Arc::new(state_reader) }, - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); cached_state diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 1ddeb6846..4847a27d8 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -1,19 +1,20 @@ -use std::sync::Arc; - -use crate::services::api::contract_classes::deprecated_contract_class::{ - ContractEntryPoint, EntryPointType, +use super::{ + CallInfo, CallResult, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, }; -use crate::state::cached_state::CachedState; -use crate::state::StateDiff; use crate::{ definitions::{block_context::BlockContext, constants::DEFAULT_ENTRY_POINT_SELECTOR}, runner::StarknetRunner, services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, ContractEntryPoint, EntryPointType}, + }, + state::{ + cached_state::CachedState, + contract_class_cache::ContractClassCache, + contract_storage_state::ContractStorageState, + state_api::{State, StateReader}, + ExecutionResourcesManager, StateDiff, }, - state::state_api::State, - state::ExecutionResourcesManager, - state::{contract_storage_state::ContractStorageState, state_api::StateReader}, syscalls::{ business_logic_syscall_handler::BusinessLogicSyscallHandler, deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler, @@ -38,10 +39,7 @@ use cairo_vm::{ vm_core::VirtualMachine, }, }; - -use super::{ - CallInfo, CallResult, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, -}; +use std::sync::Arc; #[derive(Debug, Default)] pub struct ExecutionResult { @@ -94,9 +92,9 @@ impl ExecutionEntryPoint { /// The information collected from this run (number of steps required, modifications to the /// contract storage, etc.) is saved on the resources manager. /// Returns a CallInfo object that represents the execution. - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, resources_manager: &mut ExecutionResourcesManager, tx_execution_context: &mut TransactionExecutionContext, @@ -105,6 +103,7 @@ impl ExecutionEntryPoint { ) -> Result where T: StateReader, + C: ContractClassCache, { // lookup the compiled class from the state. let class_hash = self.get_code_class_hash(state)?; @@ -128,9 +127,12 @@ impl ExecutionEntryPoint { }) } CompiledClass::Casm(contract_class) => { - let mut tmp_state = - CachedState::new(state.state_reader.clone(), state.contract_classes.clone()); + let mut tmp_state = CachedState::new( + state.state_reader.clone(), + state.contract_class_cache.clone(), + ); tmp_state.cache = state.cache.clone(); + tmp_state.contract_class_cache_private = state.contract_class_cache_private.clone(); match self._execute( &mut tmp_state, @@ -142,8 +144,14 @@ impl ExecutionEntryPoint { support_reverted, ) { Ok(call_info) => { + state + .contract_class_cache_private + .get_mut() + .extend(tmp_state.contract_class_cache_private.get_mut().drain()); + let state_diff = StateDiff::from_cached_state(tmp_state)?; state.apply_state_update(&state_diff)?; + Ok(ExecutionResult { call_info: Some(call_info), revert_error: None, @@ -232,11 +240,11 @@ impl ExecutionEntryPoint { .ok_or(TransactionError::EntryPointNotFound) } - fn build_call_info_deprecated( + fn build_call_info_deprecated( &self, previous_cairo_usage: ExecutionResources, resources_manager: &ExecutionResourcesManager, - starknet_storage_state: ContractStorageState, + starknet_storage_state: ContractStorageState, events: Vec, l2_to_l1_messages: Vec, internal_calls: Vec, @@ -265,11 +273,11 @@ impl ExecutionEntryPoint { }) } - fn build_call_info( + fn build_call_info( &self, previous_cairo_usage: ExecutionResources, resources_manager: &ExecutionResourcesManager, - starknet_storage_state: ContractStorageState, + starknet_storage_state: ContractStorageState, events: Vec, l2_to_l1_messages: Vec, internal_calls: Vec, @@ -324,9 +332,9 @@ impl ExecutionEntryPoint { get_deployed_address_class_hash_at_address(state, &code_address.unwrap()) } - fn _execute_version0_class( + fn _execute_version0_class( &self, - state: &mut CachedState, + state: &mut CachedState, resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, tx_execution_context: &mut TransactionExecutionContext, @@ -347,7 +355,7 @@ impl ExecutionEntryPoint { // prepare OS context //let os_context = runner.prepare_os_context(); let os_context = - StarknetRunner::>::prepare_os_context_cairo0( + StarknetRunner::>::prepare_os_context_cairo0( &cairo_runner, &mut vm, ); @@ -418,7 +426,7 @@ impl ExecutionEntryPoint { let retdata = runner.get_return_values()?; - self.build_call_info_deprecated::( + self.build_call_info_deprecated::( previous_cairo_usage, resources_manager, runner.hint_processor.syscall_handler.starknet_storage_state, @@ -429,9 +437,9 @@ impl ExecutionEntryPoint { ) } - fn _execute( + fn _execute( &self, - state: &mut CachedState, + state: &mut CachedState, resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, tx_execution_context: &mut TransactionExecutionContext, @@ -457,7 +465,7 @@ impl ExecutionEntryPoint { )?; validate_contract_deployed(state, &self.contract_address)?; // prepare OS context - let os_context = StarknetRunner::>::prepare_os_context_cairo1( + let os_context = StarknetRunner::>::prepare_os_context_cairo1( &cairo_runner, &mut vm, self.initial_gas.into(), @@ -568,7 +576,7 @@ impl ExecutionEntryPoint { resources_manager.cairo_usage += &runner.get_execution_resources()?; let call_result = runner.get_call_result(self.initial_gas)?; - self.build_call_info::( + self.build_call_info::( previous_cairo_usage, resources_manager, runner.hint_processor.syscall_handler.starknet_storage_state, diff --git a/src/lib.rs b/src/lib.rs index ee647d886..aded66d9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,29 +1,24 @@ #![deny(warnings)] #![forbid(unsafe_code)] #![cfg_attr(coverage_nightly, feature(no_coverage))] -use std::{ - collections::HashMap, - sync::{Arc, RwLock}, -}; use crate::{ + definitions::block_context::BlockContext, execution::{ - execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, - TransactionExecutionInfo, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallType, TransactionExecutionContext, TransactionExecutionInfo, }, state::{ + cached_state::CachedState, + contract_class_cache::ContractClassCache, state_api::{State, StateReader}, ExecutionResourcesManager, }, - transaction::{error::TransactionError, Transaction}, + transaction::{error::TransactionError, fee::calculate_tx_fee, L1Handler, Transaction}, + utils::Address, }; - use cairo_vm::felt::Felt252; -use definitions::block_context::BlockContext; -use execution::execution_entry_point::ExecutionResult; -use state::cached_state::CachedState; -use transaction::{fee::calculate_tx_fee, L1Handler}; -use utils::Address; +use std::sync::{Arc, RwLock}; #[cfg(test)] #[macro_use] @@ -33,9 +28,10 @@ extern crate assert_matches; pub use crate::services::api::contract_classes::deprecated_contract_class::{ ContractEntryPoint, EntryPointType, }; -pub use cairo_lang_starknet::casm_contract_class::CasmContractClass; -pub use cairo_lang_starknet::contract_class::ContractClass; -pub use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; +pub use cairo_lang_starknet::{ + casm_contract_class::CasmContractClass, contract_class::ContractClass, + contract_class::ContractClass as SierraContractClass, +}; pub use cairo_vm::felt; pub mod core; @@ -53,9 +49,10 @@ pub mod transaction; pub mod utils; #[allow(clippy::too_many_arguments)] -pub fn simulate_transaction( +pub fn simulate_transaction( transactions: &[&Transaction], state: S, + contract_class_cache: Arc>, block_context: &BlockContext, remaining_gas: u128, skip_validate: bool, @@ -64,7 +61,7 @@ pub fn simulate_transaction( ignore_max_fee: bool, skip_nonce_check: bool, ) -> Result, TransactionError> { - let mut cache_state = CachedState::new(Arc::new(state), Arc::new(RwLock::new(HashMap::new()))); + let mut cache_state = CachedState::new(Arc::new(state), contract_class_cache); let mut result = Vec::with_capacity(transactions.len()); for transaction in transactions { let tx_for_simulation = transaction.create_for_simulation( @@ -83,17 +80,18 @@ pub fn simulate_transaction( } /// Estimate the fee associated with transaction -pub fn estimate_fee( +pub fn estimate_fee( transactions: &[Transaction], state: T, + contract_class_cache: Arc>, block_context: &BlockContext, ) -> Result, TransactionError> where T: StateReader, + C: ContractClassCache, { // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = - CachedState::::new(Arc::new(state), Arc::new(RwLock::new(HashMap::new()))); + let mut cached_state = CachedState::::new(Arc::new(state), contract_class_cache); let mut result = Vec::with_capacity(transactions.len()); for transaction in transactions { @@ -118,11 +116,11 @@ where Ok(result) } -pub fn call_contract( +pub fn call_contract( contract_address: Felt252, entrypoint_selector: Felt252, calldata: Vec, - state: &mut CachedState, + state: &mut CachedState, block_context: BlockContext, caller_address: Address, ) -> Result, TransactionError> { @@ -172,17 +170,18 @@ pub fn call_contract( } /// Estimate the fee associated with L1Handler -pub fn estimate_message_fee( +pub fn estimate_message_fee( l1_handler: &L1Handler, state: T, + contract_class_cache: Arc>, block_context: &BlockContext, ) -> Result<(u128, usize), TransactionError> where T: StateReader, + C: ContractClassCache, { // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = - CachedState::::new(Arc::new(state), Arc::new(RwLock::new(HashMap::new()))); + let mut cached_state = CachedState::::new(Arc::new(state), contract_class_cache); // Check if the contract is deployed. cached_state.get_class_hash_at(l1_handler.contract_address())?; @@ -201,9 +200,9 @@ where } } -pub fn execute_transaction( +pub fn execute_transaction( tx: Transaction, - state: &mut CachedState, + state: &mut CachedState, block_context: BlockContext, remaining_gas: u128, ) -> Result { @@ -212,52 +211,51 @@ pub fn execute_transaction( #[cfg(test)] mod test { - use std::collections::HashMap; - use std::path::PathBuf; - use std::sync::{Arc, RwLock}; - - use crate::core::contract_address::{compute_deprecated_class_hash, compute_sierra_class_hash}; - use crate::definitions::constants::INITIAL_GAS_COST; - use crate::definitions::{ - block_context::StarknetChainId, - constants::{ - EXECUTE_ENTRY_POINT_SELECTOR, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, - VALIDATE_ENTRY_POINT_SELECTOR, - }, - transaction_type::TransactionType, - }; - use crate::estimate_fee; - use crate::estimate_message_fee; - use crate::hash_utils::calculate_contract_address; - use crate::services::api::contract_classes::deprecated_contract_class::ContractClass; - use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; - use crate::state::state_api::State; - use crate::testing::{ - create_account_tx_test_state, TEST_ACCOUNT_CONTRACT_ADDRESS, TEST_CONTRACT_ADDRESS, - TEST_CONTRACT_PATH, TEST_FIB_COMPILED_CONTRACT_CLASS_HASH, - }; - use crate::transaction::{ - Declare, DeclareV2, Deploy, DeployAccount, InvokeFunction, L1Handler, Transaction, - }; - use crate::utils::felt_to_hash; - use cairo_lang_starknet::casm_contract_class::CasmContractClass; - use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; - use cairo_vm::felt::{felt_str, Felt252}; - use num_traits::{Num, One, Zero}; - use crate::{ call_contract, - definitions::block_context::BlockContext, + core::contract_address::{compute_deprecated_class_hash, compute_sierra_class_hash}, + definitions::{ + block_context::{BlockContext, StarknetChainId}, + constants::{ + EXECUTE_ENTRY_POINT_SELECTOR, INITIAL_GAS_COST, + VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, VALIDATE_ENTRY_POINT_SELECTOR, + }, + transaction_type::TransactionType, + }, + estimate_fee, estimate_message_fee, + hash_utils::calculate_contract_address, + services::api::contract_classes::{ + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, EntryPointType}, + }, simulate_transaction, state::{ - cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + state_api::State, ExecutionResourcesManager, }, - utils::{Address, ClassHash}, + testing::{ + create_account_tx_test_state, TEST_ACCOUNT_CONTRACT_ADDRESS, TEST_CONTRACT_ADDRESS, + TEST_CONTRACT_PATH, TEST_FIB_COMPILED_CONTRACT_CLASS_HASH, + }, + transaction::{ + Declare, DeclareV2, Deploy, DeployAccount, InvokeFunction, L1Handler, Transaction, + }, + utils::{felt_to_hash, Address, ClassHash}, }; - - use crate::services::api::contract_classes::compiled_class::CompiledClass; + use cairo_lang_starknet::{ + casm_contract_class::CasmContractClass, + contract_class::ContractClass as SierraContractClass, + }; + use cairo_vm::felt::{felt_str, Felt252}; use lazy_static::lazy_static; + use num_traits::{Num, One, Zero}; + use std::{ + path::PathBuf, + sync::{Arc, RwLock}, + }; lazy_static! { // include_str! doesn't seem to work in CI @@ -302,7 +300,13 @@ mod test { .unwrap(); let transaction = Transaction::InvokeFunction(invoke_function); - let estimated_fee = estimate_fee(&[transaction], state, &block_context).unwrap(); + let estimated_fee = estimate_fee( + &[transaction], + state, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + &block_context, + ) + .unwrap(); assert_eq!(estimated_fee[0], (2483, 2448)); } @@ -317,13 +321,14 @@ mod test { let entrypoints = contract_class.clone().entry_points_by_type; let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -387,24 +392,31 @@ mod test { .address_to_nonce .insert(contract_address, nonce); - let mut state = CachedState::new( + let state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Initialize state.contract_classes - let contract_classes = HashMap::from([( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - )]); state - .set_contract_classes(Arc::new(RwLock::new(contract_classes))) - .unwrap(); + .contract_class_cache() + .write() + .unwrap() + .set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut block_context = BlockContext::default(); block_context.starknet_os_config.gas_price = 1; - let estimated_fee = estimate_message_fee(&l1_handler, state, &block_context).unwrap(); + let estimated_fee = estimate_message_fee( + &l1_handler, + state.clone(), + state.contract_class_cache().clone(), + &block_context, + ) + .unwrap(); assert_eq!(estimated_fee, (19708, 19695)); } @@ -418,13 +430,14 @@ mod test { let entrypoints = contract_class.clone().entry_points_by_type; let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -577,6 +590,7 @@ mod test { let context = simulate_transaction( &[&invoke_1, &invoke_2, &invoke_3], state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), &block_context, 1000, false, @@ -679,6 +693,7 @@ mod test { let context = simulate_transaction( &[&invoke], state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), &block_context, 1000, true, @@ -697,7 +712,10 @@ mod test { #[test] fn test_simulate_deploy() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); state .set_contract_class( @@ -724,7 +742,8 @@ mod test { simulate_transaction( &[&internal_deploy], - state, + state.clone(), + state.contract_class_cache().clone(), block_context, 100_000_000, false, @@ -739,7 +758,10 @@ mod test { #[test] fn test_simulate_declare() { let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let block_context = &Default::default(); @@ -761,7 +783,8 @@ mod test { simulate_transaction( &[&declare_tx], - state, + state.clone(), + state.contract_class_cache().clone(), block_context, 100_000_000, false, @@ -776,7 +799,10 @@ mod test { #[test] fn test_simulate_invoke() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); state .set_contract_class( @@ -825,7 +851,8 @@ mod test { simulate_transaction( &[&invoke_tx], - state, + state.clone(), + state.contract_class_cache().clone(), &block_context, 100_000_000, false, @@ -840,7 +867,10 @@ mod test { #[test] fn test_simulate_deploy_account() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); state .set_contract_class( @@ -868,7 +898,8 @@ mod test { simulate_transaction( &[&deploy_account_tx], - state, + state.clone(), + state.contract_class_cache().clone(), block_context, 100_000_000, false, @@ -913,7 +944,8 @@ mod test { simulate_transaction( &[&declare_tx], - state, + state.clone(), + state.contract_class_cache().clone(), &block_context, 100_000_000, false, @@ -966,14 +998,9 @@ mod test { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -986,7 +1013,8 @@ mod test { simulate_transaction( &[&l1_handler_tx], - state, + state.clone(), + state.contract_class_cache().clone(), &block_context, 100_000_000, false, @@ -1001,7 +1029,10 @@ mod test { #[test] fn test_deploy_and_invoke_simulation() { let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let block_context = &Default::default(); @@ -1044,6 +1075,7 @@ mod test { simulate_transaction( &[&deploy, &invoke_tx], state.clone(), + state.contract_class_cache().clone(), block_context, 100_000_000, false, @@ -1055,7 +1087,13 @@ mod test { .unwrap(); assert_eq!( - estimate_fee(&[deploy, invoke_tx], state, block_context,).unwrap(), + estimate_fee( + &[deploy, invoke_tx], + state.clone(), + state.contract_class_cache().clone(), + block_context + ) + .unwrap(), [(0, 3672), (0, 2448)] ); } diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 4788a49f5..be5b44eb5 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -426,7 +426,10 @@ mod test { use super::StarknetRunner; use crate::{ state::cached_state::CachedState, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, syscalls::{ deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler, deprecated_syscall_handler::DeprecatedSyscallHintProcessor, @@ -448,7 +451,12 @@ mod test { let cairo_runner = CairoRunner::new(&program, "starknet", false).unwrap(); let mut vm = VirtualMachine::new(true); - let os_context = StarknetRunner::>>::prepare_os_context_cairo0(&cairo_runner, &mut vm); + let os_context = StarknetRunner::< + SyscallHintProcessor< + CachedState, + PermanentContractClassCache, + >, + >::prepare_os_context_cairo0(&cairo_runner, &mut vm); // is expected to return a pointer to the first segment as there is nothing more in the vm let expected = Vec::from([MaybeRelocatable::from((0, 0))]); @@ -462,7 +470,7 @@ mod test { let cairo_runner = CairoRunner::new(&program, "starknet", false).unwrap(); let vm = VirtualMachine::new(true); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -478,7 +486,7 @@ mod test { let cairo_runner = CairoRunner::new(&program, "starknet", false).unwrap(); let vm = VirtualMachine::new(true); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -497,7 +505,7 @@ mod test { let cairo_runner = CairoRunner::new(&program, "starknet", false).unwrap(); let vm = VirtualMachine::new(true); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -519,7 +527,7 @@ mod test { let cairo_runner = CairoRunner::new(&program, "starknet", false).unwrap(); let vm = VirtualMachine::new(true); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -541,7 +549,7 @@ mod test { let cairo_runner = CairoRunner::new(&program, "starknet", false).unwrap(); let vm = VirtualMachine::new(true); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -563,7 +571,7 @@ mod test { vm.add_memory_segment(); vm.compute_segments_effective_sizes(); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -586,7 +594,7 @@ mod test { vm.add_memory_segment(); vm.compute_segments_effective_sizes(); - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let hint_processor = DeprecatedSyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index c24fb8c30..35927f32a 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -1,4 +1,5 @@ use super::{ + contract_class_cache::ContractClassCache, state_api::{State, StateReader}, state_cache::{StateCache, StorageEntry}, }; @@ -12,34 +13,33 @@ use cairo_vm::felt::Felt252; use getset::{Getters, MutGetters}; use num_traits::Zero; use std::{ + cell::RefCell, collections::{HashMap, HashSet}, - mem, sync::{Arc, RwLock}, }; -type ContractClassesCache = Arc>>; - pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; /// Represents a cached state of contract classes with optional caches. #[derive(Default, Clone, Debug, Getters, MutGetters)] -pub struct CachedState { +pub struct CachedState { pub state_reader: Arc, #[getset(get = "pub", get_mut = "pub")] pub(crate) cache: StateCache, - #[get = "pub"] - pub(crate) contract_classes: ContractClassesCache, - pub(crate) contract_classes_private: HashMap, + + #[getset(get = "pub", get_mut = "pub")] + pub(crate) contract_class_cache: Arc>, + pub(crate) contract_class_cache_private: RefCell>, } -impl CachedState { +impl CachedState { /// Constructor, creates a new cached state. - pub fn new(state_reader: Arc, contract_classes: ContractClassesCache) -> Self { + pub fn new(state_reader: Arc, contract_classes: Arc>) -> Self { Self { cache: StateCache::default(), state_reader, - contract_classes, - contract_classes_private: HashMap::new(), + contract_class_cache: contract_classes, + contract_class_cache_private: RefCell::new(HashMap::new()), } } @@ -47,27 +47,18 @@ impl CachedState { pub fn new_for_testing( state_reader: Arc, cache: StateCache, - contract_classes: ContractClassesCache, + contract_classes: Arc>, ) -> Self { Self { cache, state_reader, - contract_classes, - contract_classes_private: HashMap::new(), + contract_class_cache: contract_classes, + contract_class_cache_private: RefCell::new(HashMap::new()), } } - - /// Sets the contract classes cache. - pub fn set_contract_classes( - &mut self, - contract_classes: ContractClassesCache, - ) -> Result<(), StateError> { - self.contract_classes = contract_classes; - Ok(()) - } } -impl StateReader for CachedState { +impl StateReader for CachedState { /// Returns the class hash for a given contract address. fn get_class_hash_at(&self, contract_address: &Address) -> Result { if self.cache.get_class_hash(contract_address).is_none() { @@ -153,25 +144,39 @@ impl StateReader for CachedState { } // I: FETCHING FROM CACHE - if let Some(compiled_class) = self.contract_classes_private.get(class_hash) { - return Ok(compiled_class.clone()); - } else if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { + let mut private_cache = self.contract_class_cache_private.borrow_mut(); + if let Some(compiled_class) = private_cache.get(class_hash) { return Ok(compiled_class.clone()); + } else if let Some(compiled_class) = self + .contract_class_cache + .read() + .unwrap() + .get_contract_class(*class_hash) + { + private_cache.insert(*class_hash, compiled_class.clone()); + return Ok(compiled_class); } // I: CASM CONTRACT CLASS : CLASS_HASH if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self.contract_classes_private.get(compiled_class_hash) { + if let Some(casm_class) = self + .contract_class_cache_private + .borrow() + .get(compiled_class_hash) + { return Ok(casm_class.clone()); } else if let Some(casm_class) = self - .contract_classes + .contract_class_cache .read() .unwrap() - .get(compiled_class_hash) + .get_contract_class(*compiled_class_hash) { - return Ok(casm_class.clone()); + self.contract_class_cache_private + .borrow_mut() + .insert(*class_hash, casm_class.clone()); + return Ok(casm_class); } } @@ -180,14 +185,15 @@ impl StateReader for CachedState { } } -impl State for CachedState { +impl State for CachedState { /// Stores a contract class in the cache. fn set_contract_class( &mut self, class_hash: &ClassHash, contract_class: &CompiledClass, ) -> Result<(), StateError> { - self.contract_classes_private + self.contract_class_cache_private + .get_mut() .insert(*class_hash, contract_class.clone()); Ok(()) @@ -393,29 +399,40 @@ impl State for CachedState { // I: FETCHING FROM CACHE // deprecated contract classes dont have compiled class hashes, so we only have one case - if let Some(compiled_class) = self.contract_classes_private.get(class_hash) { + if let Some(compiled_class) = self.contract_class_cache_private.get_mut().get(class_hash) { return Ok(compiled_class.clone()); - } else if let Some(compiled_class) = self.contract_classes.read().unwrap().get(class_hash) { - self.contract_classes_private + } else if let Some(compiled_class) = self + .contract_class_cache + .read() + .unwrap() + .get_contract_class(*class_hash) + { + self.contract_class_cache_private + .get_mut() .insert(*class_hash, compiled_class.clone()); - return Ok(compiled_class.clone()); + return Ok(compiled_class); } // I: CASM CONTRACT CLASS : CLASS_HASH if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self.contract_classes_private.get(compiled_class_hash) { + if let Some(casm_class) = self + .contract_class_cache_private + .get_mut() + .get(compiled_class_hash) + { return Ok(casm_class.clone()); } else if let Some(casm_class) = self - .contract_classes + .contract_class_cache .read() .unwrap() - .get(compiled_class_hash) + .get_contract_class(*compiled_class_hash) { - self.contract_classes_private + self.contract_class_cache_private + .get_mut() .insert(*class_hash, casm_class.clone()); - return Ok(casm_class.clone()); + return Ok(casm_class); } } @@ -438,49 +455,18 @@ impl State for CachedState { } } -pub fn merge_caches( - shared: &RwLock>, - mut private: HashMap, -) { - // FIXME: Parallel invocation of `merge_caches()` may cause data loss. Example: - // - Thread A: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. - // - Thread B: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. - // - Thread A: Updates the shared cache. It now contains A's specific entries. - // - Thread B: Updates the shared cache. It now contains only B's specific entries, since it - // lost A's ones. - - // Extend private to contain all of shared's entries. Using a readonly lock will avoid blocking - // the other potential cache readers. - { - let shared_lock = shared.read().unwrap(); - private.extend(shared_lock.iter().map(|(k, v)| (*k, v.clone()))); - } - - // Swap the active cache to apply the changes. This will delay `private`'s destructor, which - // will run after the write lock has been dropped. - { - let mut shared_lock = shared.write().unwrap(); - mem::swap(&mut *shared_lock, &mut private); - } -} - -pub fn take_cache(state: CachedState) -> HashMap -where - T: StateReader, -{ - state.contract_classes_private -} - #[cfg(test)] mod tests { use super::*; - use crate::{ services::api::contract_classes::deprecated_contract_class::ContractClass, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, }; - use num_traits::One; + use std::collections::HashMap; /// Test checks if class hashes and nonces are correctly fetched from the state reader. /// It also tests the increment_nonce method. @@ -512,7 +498,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); assert_eq!( @@ -545,15 +531,11 @@ mod tests { .class_hash_to_compiled_class .insert([1; 32], CompiledClass::Deprecated(Arc::new(contract_class))); - let mut cached_state = CachedState::new( + let cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - cached_state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - assert_eq!( cached_state.get_contract_class(&[1; 32]).unwrap(), cached_state @@ -568,7 +550,7 @@ mod tests { fn cached_state_storage_test() { let mut cached_state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let storage_entry: StorageEntry = (Address(31.into()), [0; 32]); @@ -591,8 +573,10 @@ mod tests { let contract_address = Address(32123.into()); - let mut cached_state = - CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut cached_state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); assert!(cached_state .deploy_contract(contract_address, [10; 32]) @@ -608,8 +592,10 @@ mod tests { let storage_key = [18; 32]; let value = Felt252::new(912); - let mut cached_state = - CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut cached_state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); // set storage_key cached_state.set_storage_at(&(contract_address.clone(), storage_key), value.clone()); @@ -642,7 +628,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let result = cached_state @@ -670,7 +656,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); cached_state @@ -701,7 +687,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); cached_state @@ -733,7 +719,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let state_diff = StateDiff { @@ -771,7 +757,7 @@ mod tests { let state_reader = InMemoryStateReader::default(); let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let address_one = Address(1.into()); diff --git a/src/state/contract_class_cache.rs b/src/state/contract_class_cache.rs new file mode 100644 index 000000000..20bd7756d --- /dev/null +++ b/src/state/contract_class_cache.rs @@ -0,0 +1,105 @@ +use crate::{services::api::contract_classes::compiled_class::CompiledClass, utils::ClassHash}; +use std::collections::HashMap; + +pub trait ContractClassCache { + fn get_contract_class(&self, class_hash: ClassHash) -> Option; + fn set_contract_class(&mut self, class_hash: ClassHash, compiled_class: CompiledClass); + + fn merge_with(&mut self, other: I) + where + I: IntoIterator; +} + +// pub(crate) fn merge_caches( +// shared: &RwLock>, +// mut private: HashMap, +// ) { +// // FIXME: Parallel invocation of `merge_caches()` may cause data loss. Example: +// // - Thread A: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. +// // - Thread B: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. +// // - Thread A: Updates the shared cache. It now contains A's specific entries. +// // - Thread B: Updates the shared cache. It now contains only B's specific entries, since it +// // lost A's ones. + +// // Extend private to contain all of shared's entries. Using a readonly lock will avoid blocking +// // the other potential cache readers. +// { +// let shared_lock = shared.read().unwrap(); +// private.extend(shared_lock.iter().map(|(k, v)| (*k, v.clone()))); +// } + +// // Swap the active cache to apply the changes. This will delay `private`'s destructor, which +// // will run after the write lock has been dropped. +// { +// let mut shared_lock = shared.write().unwrap(); +// mem::swap(&mut *shared_lock, &mut private); +// } +// } + +// pub(crate) fn take_cache(state: CachedState) -> HashMap +// where +// T: StateReader, +// C: ContractClassCache, +// { +// state.contract_class_cache_private +// } + +#[derive(Clone, Copy, Debug, Default, Hash)] +pub struct NullContractClassCache; + +impl ContractClassCache for NullContractClassCache { + fn get_contract_class(&self, _class_hash: ClassHash) -> Option { + None + } + + fn set_contract_class(&mut self, _class_hash: ClassHash, _compiled_class: CompiledClass) { + // Nothing needs to be done here. + } + + fn merge_with(&mut self, _other: I) + where + I: IntoIterator, + { + // Nothing needs to be done here. + } +} + +#[derive(Clone, Debug, Default)] +pub struct PermanentContractClassCache { + storage: HashMap, +} + +impl ContractClassCache for PermanentContractClassCache { + fn get_contract_class(&self, class_hash: ClassHash) -> Option { + self.storage.get(&class_hash).cloned() + } + + fn set_contract_class(&mut self, class_hash: ClassHash, compiled_class: CompiledClass) { + self.storage.insert(class_hash, compiled_class); + } + + fn merge_with(&mut self, other: I) + where + I: IntoIterator, + { + self.storage.extend(other); + } +} + +impl IntoIterator for PermanentContractClassCache { + type Item = (ClassHash, CompiledClass); + type IntoIter = as IntoIterator>::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.storage.into_iter() + } +} + +impl IntoIterator for &PermanentContractClassCache { + type Item = (ClassHash, CompiledClass); + type IntoIter = as IntoIterator>::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.storage.clone().into_iter() + } +} diff --git a/src/state/contract_storage_state.rs b/src/state/contract_storage_state.rs index 795bc339a..cc6fbae06 100644 --- a/src/state/contract_storage_state.rs +++ b/src/state/contract_storage_state.rs @@ -1,5 +1,6 @@ use super::{ cached_state::CachedState, + contract_class_cache::ContractClassCache, state_api::{State, StateReader}, }; use crate::{ @@ -10,16 +11,16 @@ use cairo_vm::felt::Felt252; use std::collections::HashSet; #[derive(Debug)] -pub(crate) struct ContractStorageState<'a, S: StateReader> { - pub(crate) state: &'a mut CachedState, +pub(crate) struct ContractStorageState<'a, S: StateReader, C: ContractClassCache> { + pub(crate) state: &'a mut CachedState, pub(crate) contract_address: Address, /// Maintain all read request values in chronological order pub(crate) read_values: Vec, pub(crate) accessed_keys: HashSet, } -impl<'a, S: StateReader> ContractStorageState<'a, S> { - pub(crate) fn new(state: &'a mut CachedState, contract_address: Address) -> Self { +impl<'a, S: StateReader, C: ContractClassCache> ContractStorageState<'a, S, C> { + pub(crate) fn new(state: &'a mut CachedState, contract_address: Address) -> Self { Self { state, contract_address, diff --git a/src/state/mod.rs b/src/state/mod.rs index c92f20b1d..2a85c7cc1 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -1,14 +1,13 @@ -pub mod cached_state; -pub(crate) mod contract_storage_state; -pub mod in_memory_state_reader; -pub mod state_api; -pub mod state_cache; - +use self::{ + cached_state::CachedState, contract_class_cache::ContractClassCache, state_api::StateReader, +}; use crate::{ core::errors::state_errors::StateError, services::api::contract_classes::compiled_class::CompiledClass, + transaction::error::TransactionError, utils::{ get_keys, subtract_mappings, to_cache_state_storage_mapping, to_state_diff_storage_mapping, + Address, ClassHash, }, }; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; @@ -18,12 +17,12 @@ use std::{ sync::{Arc, RwLock}, }; -use crate::{ - transaction::error::TransactionError, - utils::{Address, ClassHash}, -}; - -use self::{cached_state::CachedState, state_api::StateReader}; +pub mod cached_state; +pub mod contract_class_cache; +pub(crate) mod contract_storage_state; +pub mod in_memory_state_reader; +pub mod state_api; +pub mod state_cache; #[derive(Clone, Debug, PartialEq, Eq)] pub struct BlockInfo { @@ -129,9 +128,10 @@ impl StateDiff { } } - pub fn from_cached_state(cached_state: CachedState) -> Result + pub fn from_cached_state(cached_state: CachedState) -> Result where T: StateReader, + C: ContractClassCache, { let state_cache = cached_state.cache().to_owned(); @@ -165,11 +165,16 @@ impl StateDiff { }) } - pub fn to_cached_state(&self, state_reader: Arc) -> Result, StateError> + pub fn to_cached_state( + &self, + state_reader: Arc, + contract_class_cache: Arc>, + ) -> Result, StateError> where T: StateReader + Clone, + C: ContractClassCache, { - let mut cache_state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut cache_state = CachedState::new(state_reader, contract_class_cache); let cache_storage_mapping = to_cache_state_storage_mapping(&self.storage_updates); cache_state.cache_mut().set_initial_values( @@ -237,22 +242,22 @@ fn test_validate_legal_progress() { #[cfg(test)] mod test { - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; - use super::StateDiff; use crate::{ - state::in_memory_state_reader::InMemoryStateReader, state::{ cached_state::CachedState, + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::StateReader, state_cache::{StateCache, StorageEntry}, }, utils::Address, }; use cairo_vm::felt::Felt252; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; #[test] fn test_from_cached_state_without_updates() { @@ -271,7 +276,7 @@ mod test { let cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let diff = StateDiff::from_cached_state(cached_state).unwrap(); @@ -334,16 +339,25 @@ mod test { let cached_state_original = CachedState::new( Arc::new(state_reader.clone()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); - let cached_state = diff.to_cached_state(Arc::new(state_reader)).unwrap(); + let cached_state = diff + .to_cached_state::<_, PermanentContractClassCache>( + Arc::new(state_reader), + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ) + .unwrap(); assert_eq!( - *cached_state_original.contract_classes().read().unwrap(), - *cached_state.contract_classes().read().unwrap() + (&*cached_state_original.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*cached_state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>() ); assert_eq!( cached_state_original @@ -385,7 +399,7 @@ mod test { let cached_state = CachedState::new_for_testing( Arc::new(state_reader), cache, - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut diff = StateDiff::from_cached_state(cached_state).unwrap(); diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index b5a27da59..1a240e6d4 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -55,6 +55,7 @@ use cairo_vm::{ use lazy_static::lazy_static; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; +use crate::state::contract_class_cache::ContractClassCache; use num_traits::{One, ToPrimitive, Zero}; const STEP: u128 = 100; @@ -118,7 +119,7 @@ lazy_static! { } #[derive(Debug)] -pub struct BusinessLogicSyscallHandler<'a, S: StateReader> { +pub struct BusinessLogicSyscallHandler<'a, S: StateReader, C: ContractClassCache> { pub(crate) events: Vec, pub(crate) expected_syscall_ptr: Relocatable, pub(crate) resources_manager: ExecutionResourcesManager, @@ -129,7 +130,7 @@ pub struct BusinessLogicSyscallHandler<'a, S: StateReader> { pub(crate) read_only_segments: Vec<(Relocatable, MaybeRelocatable)>, pub(crate) internal_calls: Vec, pub(crate) block_context: BlockContext, - pub(crate) starknet_storage_state: ContractStorageState<'a, S>, + pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, pub(crate) support_reverted: bool, pub(crate) entry_point_selector: Felt252, pub(crate) selector_to_syscall: &'a HashMap, @@ -137,11 +138,11 @@ pub struct BusinessLogicSyscallHandler<'a, S: StateReader> { // TODO: execution entry point may no be a parameter field, but there is no way to generate a default for now -impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, S, C> { #[allow(clippy::too_many_arguments)] pub fn new( tx_execution_context: TransactionExecutionContext, - state: &'a mut CachedState, + state: &'a mut CachedState, resources_manager: ExecutionResourcesManager, caller_address: Address, contract_address: Address, @@ -173,7 +174,8 @@ impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { selector_to_syscall: &SELECTOR_TO_SYSCALL, } } - pub fn default_with_state(state: &'a mut CachedState) -> Self { + + pub fn default_with_state(state: &'a mut CachedState) -> Self { BusinessLogicSyscallHandler::new_for_testing( BlockInfo::default(), Default::default(), @@ -184,7 +186,7 @@ impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { pub fn new_for_testing( block_info: BlockInfo, _contract_address: Address, - state: &'a mut CachedState, + state: &'a mut CachedState, ) -> Self { let syscalls = Vec::from([ "emit_event".to_string(), @@ -553,7 +555,7 @@ impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { } } -impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, S, C> { fn emit_event( &mut self, vm: &VirtualMachine, diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 6c8054065..7b43f7269 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -26,6 +26,7 @@ use crate::{ }, state::ExecutionResourcesManager, state::{ + contract_class_cache::ContractClassCache, contract_storage_state::ContractStorageState, state_api::{State, StateReader}, BlockInfo, @@ -49,7 +50,7 @@ use num_traits::{One, ToPrimitive, Zero}; //* ----------------------------------- /// Deprecated version of BusinessLogicSyscallHandler. #[derive(Debug)] -pub struct DeprecatedBLSyscallHandler<'a, S: StateReader> { +pub struct DeprecatedBLSyscallHandler<'a, S: StateReader, C: ContractClassCache> { pub(crate) tx_execution_context: TransactionExecutionContext, /// Events emitted by the current contract call. pub(crate) events: Vec, @@ -61,15 +62,15 @@ pub struct DeprecatedBLSyscallHandler<'a, S: StateReader> { pub(crate) l2_to_l1_messages: Vec, pub(crate) block_context: BlockContext, pub(crate) tx_info_ptr: Option, - pub(crate) starknet_storage_state: ContractStorageState<'a, S>, + pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, pub(crate) internal_calls: Vec, pub(crate) expected_syscall_ptr: Relocatable, } -impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S, C> { pub fn new( tx_execution_context: TransactionExecutionContext, - state: &'a mut CachedState, + state: &'a mut CachedState, resources_manager: ExecutionResourcesManager, caller_address: Address, contract_address: Address, @@ -100,7 +101,7 @@ impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { } } - pub fn default_with(state: &'a mut CachedState) -> Self { + pub fn default_with(state: &'a mut CachedState) -> Self { DeprecatedBLSyscallHandler::new_for_testing(BlockInfo::default(), Default::default(), state) } @@ -113,7 +114,7 @@ impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { pub fn new_for_testing( block_info: BlockInfo, _contract_address: Address, - state: &'a mut CachedState, + state: &'a mut CachedState, ) -> Self { let syscalls = Vec::from([ "emit_event".to_string(), @@ -246,7 +247,7 @@ impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { } } -impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S, C> { pub(crate) fn emit_event( &mut self, vm: &VirtualMachine, @@ -918,7 +919,10 @@ impl<'a, S: StateReader> DeprecatedBLSyscallHandler<'a, S> { mod tests { use crate::{ state::cached_state::CachedState, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, syscalls::syscall_handler_errors::SyscallHandlerError, utils::{test_utils::*, Address}, }; @@ -939,7 +943,7 @@ mod tests { use std::{any::Any, borrow::Cow, collections::HashMap}; type DeprecatedBLSyscallHandler<'a> = - super::DeprecatedBLSyscallHandler<'a, InMemoryStateReader>; + super::DeprecatedBLSyscallHandler<'a, InMemoryStateReader, PermanentContractClassCache>; #[test] fn run_alloc_hint_ap_is_not_empty() { @@ -960,7 +964,7 @@ mod tests { #[test] fn deploy_from_zero_error() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); @@ -986,7 +990,7 @@ mod tests { #[test] fn can_allocate_segment() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); let data = vec![MaybeRelocatable::Int(7.into())]; @@ -1002,7 +1006,7 @@ mod tests { #[test] fn test_get_block_number() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); @@ -1022,7 +1026,7 @@ mod tests { #[test] fn test_get_contract_address_ok() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); @@ -1039,7 +1043,7 @@ mod tests { #[test] fn test_storage_read_empty() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler = DeprecatedBLSyscallHandler::default_with(&mut state); assert_matches!( diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index dfc2cd27b..9b44e8329 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -2,38 +2,41 @@ use super::{ deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler, hint_code::*, other_syscalls, syscall_handler::HintProcessorPostRun, }; -use crate::{state::state_api::StateReader, syscalls::syscall_handler_errors::SyscallHandlerError}; -use cairo_vm::{ - felt::Felt252, - hint_processor::hint_processor_definition::HintProcessorLogic, - vm::runners::cairo_runner::{ResourceTracker, RunResources}, +use crate::{ + state::{contract_class_cache::ContractClassCache, state_api::StateReader}, + syscalls::syscall_handler_errors::SyscallHandlerError, }; use cairo_vm::{ + felt::Felt252, hint_processor::{ builtin_hint_processor::{ builtin_hint_processor_definition::{BuiltinHintProcessor, HintProcessorData}, hint_utils::get_relocatable_from_var_name, }, - hint_processor_definition::HintReference, + hint_processor_definition::{HintProcessorLogic, HintReference}, }, serde::deserialize_program::ApTracking, types::{exec_scope::ExecutionScopes, relocatable::Relocatable}, - vm::{errors::hint_errors::HintError, vm_core::VirtualMachine}, + vm::{ + errors::hint_errors::HintError, + runners::cairo_runner::{ResourceTracker, RunResources}, + vm_core::VirtualMachine, + }, }; use std::{any::Any, collections::HashMap}; /// Definition of the deprecated syscall hint processor with associated structs -pub(crate) struct DeprecatedSyscallHintProcessor<'a, S: StateReader> { +pub(crate) struct DeprecatedSyscallHintProcessor<'a, S: StateReader, C: ContractClassCache> { pub(crate) builtin_hint_processor: BuiltinHintProcessor, - pub(crate) syscall_handler: DeprecatedBLSyscallHandler<'a, S>, + pub(crate) syscall_handler: DeprecatedBLSyscallHandler<'a, S, C>, run_resources: RunResources, } /// Implementations and methods for DeprecatedSyscallHintProcessor -impl<'a, S: StateReader> DeprecatedSyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> DeprecatedSyscallHintProcessor<'a, S, C> { /// Constructor for DeprecatedSyscallHintProcessor pub fn new( - syscall_handler: DeprecatedBLSyscallHandler<'a, S>, + syscall_handler: DeprecatedBLSyscallHandler<'a, S, C>, run_resources: RunResources, ) -> Self { DeprecatedSyscallHintProcessor { @@ -156,7 +159,9 @@ impl<'a, S: StateReader> DeprecatedSyscallHintProcessor<'a, S> { } /// Implement the HintProcessorLogic trait for DeprecatedSyscallHintProcessor -impl<'a, S: StateReader> HintProcessorLogic for DeprecatedSyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> HintProcessorLogic + for DeprecatedSyscallHintProcessor<'a, S, C> +{ /// Executes the received hint fn execute_hint( &mut self, @@ -180,7 +185,9 @@ impl<'a, S: StateReader> HintProcessorLogic for DeprecatedSyscallHintProcessor<' } /// Implement the ResourceTracker trait for DeprecatedSyscallHintProcessor -impl<'a, S: StateReader> ResourceTracker for DeprecatedSyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> ResourceTracker + for DeprecatedSyscallHintProcessor<'a, S, C> +{ fn consumed(&self) -> bool { self.run_resources.consumed() } @@ -199,7 +206,9 @@ impl<'a, S: StateReader> ResourceTracker for DeprecatedSyscallHintProcessor<'a, } /// Implement the HintProcessorPostRun trait for DeprecatedSyscallHintProcessor -impl<'a, S: StateReader> HintProcessorPostRun for DeprecatedSyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> HintProcessorPostRun + for DeprecatedSyscallHintProcessor<'a, S, C> +{ /// Validates the execution post run fn post_run( &self, @@ -224,11 +233,7 @@ fn get_syscall_ptr( /// Unit tests for this module #[cfg(test)] mod tests { - use std::sync::{Arc, RwLock}; - use super::*; - use crate::services::api::contract_classes::compiled_class::CompiledClass; - use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use crate::{ add_segments, allocate_selector, any_box, definitions::{ @@ -237,9 +242,14 @@ mod tests { }, execution::{OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext}, memory_insert, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::in_memory_state_reader::InMemoryStateReader, - state::{cached_state::CachedState, state_api::State}, + services::api::contract_classes::{ + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, EntryPointType}, + }, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::State, + }, syscalls::deprecated_syscall_request::{ DeprecatedDeployRequest, DeprecatedSendMessageToL1SysCallRequest, DeprecatedSyscallRequest, @@ -253,18 +263,20 @@ mod tests { }; use cairo_vm::relocatable; use num_traits::Num; + use std::sync::{Arc, RwLock}; type DeprecatedBLSyscallHandler<'a> = crate::syscalls::deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler< 'a, InMemoryStateReader, + PermanentContractClassCache, >; - type SyscallHintProcessor<'a, T> = super::DeprecatedSyscallHintProcessor<'a, T>; + type SyscallHintProcessor<'a, T, C> = super::DeprecatedSyscallHintProcessor<'a, T, C>; /// Test checks if the send_message_to_l1 syscall is read correctly. #[test] fn read_send_message_to_l1_request() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); add_segments!(vm, 3); @@ -287,7 +299,7 @@ mod tests { /// Test verifies if the read syscall can correctly read a deploy request. #[test] fn read_deploy_syscall_request() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); add_segments!(vm, 2); @@ -320,7 +332,7 @@ mod tests { /// Test checks the get block timestamp for business logic. #[test] fn get_block_timestamp_for_business_logic() { - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); add_segments!(vm, 2); @@ -338,7 +350,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_BLOCK_TIMESTAMP.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -372,7 +384,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_SEQUENCER_ADDRESS.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -426,7 +438,7 @@ mod tests { let hint_data = HintProcessorData::new_default(EMIT_EVENT_CODE.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -485,7 +497,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_TX_INFO.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -593,7 +605,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_TX_INFO.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -634,7 +646,7 @@ mod tests { let hint_data = HintProcessorData::new_default(GET_CALLER_ADDRESS.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -682,7 +694,7 @@ mod tests { let hint_data = HintProcessorData::new_default(SEND_MESSAGE_TO_L1.to_string(), ids_data); // invoke syscall - let mut state = CachedState::::default(); + let mut state = CachedState::::default(); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), @@ -733,7 +745,7 @@ mod tests { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -772,7 +784,7 @@ mod tests { // invoke syscall let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -817,7 +829,7 @@ mod tests { // invoke syscall let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -888,7 +900,7 @@ mod tests { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -956,7 +968,7 @@ mod tests { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -1033,19 +1045,12 @@ mod tests { // Create SyscallHintProcessor let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), ); - // Initialize state.set_contract_classes - syscall_handler_hint_processor - .syscall_handler - .starknet_storage_state - .state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); // Set contract class let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); @@ -1137,19 +1142,12 @@ mod tests { // Create SyscallHintProcessor let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), RunResources::default(), ); - // Initialize state.set_contract_classes - syscall_handler_hint_processor - .syscall_handler - .starknet_storage_state - .state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); // Set contract class let contract_class = diff --git a/src/syscalls/deprecated_syscall_response.rs b/src/syscalls/deprecated_syscall_response.rs index 8ee64896d..2093d772c 100644 --- a/src/syscalls/deprecated_syscall_response.rs +++ b/src/syscalls/deprecated_syscall_response.rs @@ -309,24 +309,24 @@ impl DeprecatedWriteSyscallResponse for DeprecatedStorageReadResponse { #[cfg(test)] mod tests { - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; - use super::*; use crate::{ add_segments, state::cached_state::CachedState, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, utils::{get_integer, test_utils::vm}, }; use cairo_vm::relocatable; + use std::sync::{Arc, RwLock}; type DeprecatedBLSyscallHandler<'a> = crate::syscalls::deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler< 'a, InMemoryStateReader, + PermanentContractClassCache, >; /// Unit test to check the write_get_caller_address_response function @@ -335,7 +335,7 @@ mod tests { // Initialize a VM and syscall handler let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); diff --git a/src/syscalls/syscall_handler.rs b/src/syscalls/syscall_handler.rs index 67db9ebad..b62fb9b64 100644 --- a/src/syscalls/syscall_handler.rs +++ b/src/syscalls/syscall_handler.rs @@ -1,5 +1,5 @@ use super::business_logic_syscall_handler::BusinessLogicSyscallHandler; -use crate::state::state_api::StateReader; +use crate::state::{contract_class_cache::ContractClassCache, state_api::StateReader}; use crate::transaction::error::TransactionError; use cairo_lang_casm::{ hints::{Hint, StarknetHint}, @@ -32,15 +32,15 @@ pub(crate) trait HintProcessorPostRun { } #[allow(unused)] -pub(crate) struct SyscallHintProcessor<'a, S: StateReader> { +pub(crate) struct SyscallHintProcessor<'a, S: StateReader, C: ContractClassCache> { pub(crate) cairo1_hint_processor: Cairo1HintProcessor, - pub(crate) syscall_handler: BusinessLogicSyscallHandler<'a, S>, + pub(crate) syscall_handler: BusinessLogicSyscallHandler<'a, S, C>, pub(crate) run_resources: RunResources, } -impl<'a, S: StateReader> SyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> SyscallHintProcessor<'a, S, C> { pub fn new( - syscall_handler: BusinessLogicSyscallHandler<'a, S>, + syscall_handler: BusinessLogicSyscallHandler<'a, S, C>, hints: &[(usize, Vec)], run_resources: RunResources, ) -> Self { @@ -52,7 +52,9 @@ impl<'a, S: StateReader> SyscallHintProcessor<'a, S> { } } -impl<'a, S: StateReader> HintProcessorLogic for SyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> HintProcessorLogic + for SyscallHintProcessor<'a, S, C> +{ fn execute_hint( &mut self, vm: &mut VirtualMachine, @@ -111,7 +113,7 @@ impl<'a, S: StateReader> HintProcessorLogic for SyscallHintProcessor<'a, S> { } } -impl<'a, S: StateReader> ResourceTracker for SyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> ResourceTracker for SyscallHintProcessor<'a, S, C> { fn consumed(&self) -> bool { self.run_resources.consumed() } @@ -129,7 +131,9 @@ impl<'a, S: StateReader> ResourceTracker for SyscallHintProcessor<'a, S> { } } -impl<'a, S: StateReader> HintProcessorPostRun for SyscallHintProcessor<'a, S> { +impl<'a, S: StateReader, C: ContractClassCache> HintProcessorPostRun + for SyscallHintProcessor<'a, S, C> +{ fn post_run( &self, runner: &mut VirtualMachine, diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index da7e6cebf..2c7357f39 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -20,6 +20,7 @@ use crate::{ }, state::{ cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, in_memory_state_reader::InMemoryStateReader, state_api::{State, StateReader}, ExecutionResourcesManager, @@ -59,14 +60,15 @@ fn test_erc20_cairo2() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - contract_class_cache.insert( + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.set_contract_class( erc20_class_hash, CompiledClass::Casm(Arc::new(test_contract_class)), ); diff --git a/src/testing/mod.rs b/src/testing/mod.rs index 45be1b2e9..479168bc8 100644 --- a/src/testing/mod.rs +++ b/src/testing/mod.rs @@ -1,17 +1,3 @@ -pub mod erc20; -pub mod state; -pub mod state_error; -pub mod type_utils; - -use std::{ - collections::HashMap, - sync::{Arc, RwLock}, -}; - -use cairo_vm::felt::{felt_str, Felt252}; -use lazy_static::lazy_static; -use num_traits::Zero; - use crate::{ definitions::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, @@ -21,12 +7,24 @@ use crate::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, state::{ - cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, - state_cache::StorageEntry, BlockInfo, + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_cache::StorageEntry, BlockInfo, }, utils::{felt_to_hash, Address, ClassHash}, }; +use lazy_static::lazy_static; +use num_traits::Zero; +use std::{ + collections::HashMap, + sync::{Arc, RwLock}, +}; +pub mod erc20; +pub mod state; +pub mod state_error; +pub mod type_utils; + +use cairo_vm::felt::{felt_str, Felt252}; pub const ACCOUNT_CONTRACT_PATH: &str = "starknet_programs/account_without_validation.json"; pub const ERC20_CONTRACT_PATH: &str = "starknet_programs/ERC20.json"; pub const TEST_CONTRACT_PATH: &str = "starknet_programs/fibonacci.json"; @@ -84,8 +82,13 @@ pub fn new_starknet_block_context_for_testing() -> BlockContext { ) } -pub fn create_account_tx_test_state( -) -> Result<(BlockContext, CachedState), Box> { +pub fn create_account_tx_test_state() -> Result< + ( + BlockContext, + CachedState, + ), + Box, +> { let block_context = new_starknet_block_context_for_testing(); let test_contract_class_hash = felt_to_hash(&TEST_CLASS_HASH.clone()); @@ -161,7 +164,7 @@ pub fn create_account_tx_test_state( } Arc::new(state_reader) }, - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); Ok((block_context, cached_state)) diff --git a/src/testing/state.rs b/src/testing/state.rs index f34718c93..58b56859d 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -1,18 +1,20 @@ use super::{state_error::StarknetStateError, type_utils::ExecutionInfo}; -use crate::execution::execution_entry_point::ExecutionResult; -use crate::services::api::contract_classes::compiled_class::CompiledClass; -use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use crate::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, Event, TransactionExecutionContext, - TransactionExecutionInfo, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, Event, TransactionExecutionContext, TransactionExecutionInfo, }, services::api::{ - contract_classes::deprecated_contract_class::ContractClass, messages::StarknetMessageToL1, + contract_classes::{ + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, EntryPointType}, + }, + messages::StarknetMessageToL1, }, state::{ cached_state::CachedState, + contract_class_cache::PermanentContractClassCache, state_api::{State, StateReader}, }, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, @@ -23,13 +25,13 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; -use std::collections::HashMap; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; +use std::{collections::HashMap, sync::RwLock}; // --------------------------------------------------------------------- /// StarkNet testing object. Represents a state of a StarkNet network. pub struct StarknetState { - pub state: CachedState, + pub state: CachedState, pub(crate) block_context: BlockContext, l2_to_l1_messages: HashMap, usize>, l2_to_l1_messages_log: Vec, @@ -41,7 +43,10 @@ impl StarknetState { let block_context = context.unwrap_or_default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let l2_to_l1_messages = HashMap::new(); let l2_to_l1_messages_log = Vec::new(); @@ -58,7 +63,7 @@ impl StarknetState { pub fn new_with_states( block_context: Option, - state: CachedState, + state: CachedState, ) -> Self { let block_context = block_context.unwrap_or_default(); let l2_to_l1_messages = HashMap::new(); @@ -334,7 +339,7 @@ mod tests { execution::{CallType, OrderedL2ToL1Message}, hash_utils::calculate_contract_address, services::api::contract_classes::compiled_class::CompiledClass, - state::state_cache::StorageEntry, + state::{contract_class_cache::ContractClassCache, state_cache::StorageEntry}, utils::{calculate_sn_keccak, felt_to_hash}, }; @@ -414,13 +419,13 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- // hack store account contract let hash = compute_deprecated_class_hash(&contract_class).unwrap(); - let class_hash = felt_to_hash(&hash); - contract_class_cache.insert( + let class_hash: [u8; 32] = felt_to_hash(&hash); + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class.clone())), ); diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index cdbb9519d..100ab67b1 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -1,23 +1,29 @@ -use crate::definitions::constants::QUERY_VERSION_BASE; -use crate::execution::execution_entry_point::ExecutionResult; -use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; -use crate::state::cached_state::CachedState; +use super::fee::charge_fee; +use super::{verify_version, Transaction}; +use crate::state::contract_class_cache::ContractClassCache; use crate::{ core::{ contract_address::compute_deprecated_class_hash, transaction_hash::calculate_declare_transaction_hash, }, definitions::{ - block_context::BlockContext, constants::VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, + block_context::BlockContext, + constants::{QUERY_VERSION_BASE, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR}, transaction_type::TransactionType, }, execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, TransactionExecutionContext, - TransactionExecutionInfo, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, TransactionExecutionContext, TransactionExecutionInfo, + }, + services::api::contract_classes::{ + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, EntryPointType}, + }, + state::{ + cached_state::CachedState, + state_api::{State, StateReader}, + ExecutionResourcesManager, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::state_api::{State, StateReader}, - state::ExecutionResourcesManager, transaction::error::TransactionError, utils::{ calculate_tx_resources, felt_to_hash, verify_no_calls_to_other_contracts, Address, @@ -26,10 +32,6 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::Zero; - -use super::fee::charge_fee; -use super::{verify_version, Transaction}; -use crate::services::api::contract_classes::compiled_class::CompiledClass; use std::sync::Arc; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -154,9 +156,9 @@ impl Declare { /// Executes a call to the cairo-vm using the accounts_validation.cairo contract to validate /// the contract that is being declared. Then it returns the transaction execution info of the run. - pub fn apply( + pub fn apply( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; @@ -203,9 +205,9 @@ impl Declare { ) } - pub fn run_validate_entrypoint( + pub fn run_validate_entrypoint( &self, - state: &mut CachedState, + state: &mut CachedState, resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, ) -> Result, TransactionError> { @@ -264,9 +266,9 @@ impl Declare { /// Calculates actual fee used by the transaction using the execution /// info returned by apply(), then updates the transaction execution info with the data of the fee. - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { self.handle_nonce(state)?; @@ -323,17 +325,6 @@ impl Declare { #[cfg(test)] mod tests { use super::*; - use cairo_vm::{ - felt::{felt_str, Felt252}, - vm::runners::cairo_runner::ExecutionResources, - }; - use num_traits::{One, Zero}; - use std::{ - collections::HashMap, - path::PathBuf, - sync::{Arc, RwLock}, - }; - use crate::{ definitions::{ block_context::{BlockContext, StarknetChainId}, @@ -344,12 +335,20 @@ mod tests { services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, + state::{cached_state::CachedState, contract_class_cache::PermanentContractClassCache}, utils::{felt_to_hash, Address}, }; - - use super::Declare; + use cairo_vm::{ + felt::{felt_str, Felt252}, + vm::runners::cairo_runner::ExecutionResources, + }; + use num_traits::{One, Zero}; + use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, + }; #[test] fn declare_fibonacci() { @@ -358,13 +357,13 @@ mod tests { ContractClass::from_path("starknet_programs/account_without_validation.json").unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = hash.to_be_bytes(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class.clone())), ); @@ -521,13 +520,13 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -590,13 +589,13 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -658,13 +657,13 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -740,13 +739,13 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -811,7 +810,7 @@ mod tests { #[test] fn validate_transaction_should_fail() { // Instantiate CachedState - let contract_class_cache = HashMap::new(); + let contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); @@ -850,13 +849,13 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 39a69769f..5e1eb3b70 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -7,6 +7,7 @@ use crate::services::api::contract_classes::deprecated_contract_class::EntryPoin use crate::services::api::contract_classes::compiled_class::CompiledClass; use crate::state::cached_state::CachedState; +use crate::state::contract_class_cache::ContractClassCache; use crate::{ core::transaction_hash::calculate_declare_v2_transaction_hash, definitions::{ @@ -297,9 +298,9 @@ impl DeclareV2 { /// ## Parameter: /// - state: An state that implements the State and StateReader traits. /// - block_context: The block that contains the execution context - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; @@ -382,10 +383,10 @@ impl DeclareV2 { Ok(()) } - fn run_validate_entrypoint( + fn run_validate_entrypoint( &self, mut remaining_gas: u128, - state: &mut CachedState, + state: &mut CachedState, resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, ) -> Result<(ExecutionResult, u128), TransactionError> { @@ -455,21 +456,26 @@ impl DeclareV2 { #[cfg(test)] mod tests { - use std::sync::{Arc, RwLock}; - use std::{collections::HashMap, fs::File, io::BufReader, path::PathBuf}; - use super::DeclareV2; - use crate::core::contract_address::{compute_casm_class_hash, compute_sierra_class_hash}; - use crate::definitions::constants::QUERY_VERSION_BASE; - use crate::services::api::contract_classes::compiled_class::CompiledClass; - use crate::state::state_api::StateReader; use crate::{ - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, + core::contract_address::{compute_casm_class_hash, compute_sierra_class_hash}, + definitions::constants::QUERY_VERSION_BASE, + services::api::contract_classes::compiled_class::CompiledClass, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::StateReader, + }, utils::Address, }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; + use std::{ + fs::File, + io::BufReader, + path::PathBuf, + sync::{Arc, RwLock}, + }; #[test] fn create_declare_v2_without_casm_contract_class_test() { @@ -513,7 +519,7 @@ mod tests { .unwrap(); // crate state to store casm contract class - let casm_contract_class_cache = HashMap::new(); + let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, @@ -585,7 +591,7 @@ mod tests { .unwrap(); // crate state to store casm contract class - let casm_contract_class_cache = HashMap::new(); + let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, @@ -659,7 +665,7 @@ mod tests { .unwrap(); // crate state to store casm contract class - let casm_contract_class_cache = HashMap::new(); + let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, @@ -731,7 +737,7 @@ mod tests { .unwrap(); // crate state to store casm contract class - let casm_contract_class_cache = HashMap::new(); + let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, @@ -804,7 +810,7 @@ mod tests { .unwrap(); // crate state to store casm contract class - let casm_contract_class_cache = HashMap::new(); + let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index 4862d4142..d42d80ff1 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -1,11 +1,4 @@ -use std::sync::Arc; - -use crate::execution::execution_entry_point::ExecutionResult; -use crate::services::api::contract_classes::deprecated_contract_class::{ - ContractClass, EntryPointType, -}; -use crate::state::cached_state::CachedState; -use crate::syscalls::syscall_handler_errors::SyscallHandlerError; +use super::Transaction; use crate::{ core::{ contract_address::compute_deprecated_class_hash, errors::hash_errors::HashError, @@ -16,22 +9,30 @@ use crate::{ transaction_type::TransactionType, }, execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, TransactionExecutionContext, - TransactionExecutionInfo, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, TransactionExecutionContext, TransactionExecutionInfo, }, hash_utils::calculate_contract_address, services::api::{ - contract_class_errors::ContractClassError, contract_classes::compiled_class::CompiledClass, + contract_class_errors::ContractClassError, + contract_classes::{ + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, EntryPointType}, + }, + }, + state::{ + cached_state::CachedState, + contract_class_cache::ContractClassCache, + state_api::{State, StateReader}, + ExecutionResourcesManager, }, - state::state_api::{State, StateReader}, - state::ExecutionResourcesManager, + syscalls::syscall_handler_errors::SyscallHandlerError, transaction::error::TransactionError, utils::{calculate_tx_resources, felt_to_hash, Address, ClassHash}, }; use cairo_vm::felt::Felt252; use num_traits::Zero; - -use super::Transaction; +use std::sync::Arc; /// Represents a Deploy Transaction in the starknet network #[derive(Debug, Clone)] @@ -146,9 +147,9 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. - pub fn apply( + pub fn apply( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { state.set_contract_class(&self.contract_hash, &self.contract_class)?; @@ -205,9 +206,9 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. - pub fn invoke_constructor( + pub fn invoke_constructor( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { let call = ExecutionEntryPoint::new( @@ -269,9 +270,9 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { let mut tx_exec_info = self.apply(state, block_context)?; @@ -305,22 +306,27 @@ impl Deploy { #[cfg(test)] mod tests { - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; - use super::*; use crate::{ - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, utils::calculate_sn_keccak, }; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; #[test] fn invoke_constructor_test() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); // Set contract_class let contract_class = @@ -368,7 +374,10 @@ mod tests { fn invoke_constructor_no_calldata_should_fail() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let contract_class = ContractClass::from_path("starknet_programs/constructor.json").unwrap(); @@ -397,7 +406,10 @@ mod tests { fn deploy_contract_without_constructor_should_fail() { // Instantiate CachedState let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let contract_path = "starknet_programs/amm.json"; let contract_class = ContractClass::from_path(contract_path).unwrap(); diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index b9bdf6753..c41d1d175 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -1,9 +1,4 @@ -use super::fee::charge_fee; -use super::{invoke_function::verify_no_calls_to_other_contracts, Transaction}; -use crate::definitions::constants::QUERY_VERSION_BASE; -use crate::execution::execution_entry_point::ExecutionResult; -use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; -use crate::state::cached_state::CachedState; +use super::{fee::charge_fee, invoke_function::verify_no_calls_to_other_contracts, Transaction}; use crate::{ core::{ errors::state_errors::StateError, @@ -12,21 +7,28 @@ use crate::{ definitions::{ block_context::BlockContext, constants::{ - CONSTRUCTOR_ENTRY_POINT_SELECTOR, INITIAL_GAS_COST, + CONSTRUCTOR_ENTRY_POINT_SELECTOR, INITIAL_GAS_COST, QUERY_VERSION_BASE, VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR, }, transaction_type::TransactionType, }, execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, TransactionExecutionContext, - TransactionExecutionInfo, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, TransactionExecutionContext, TransactionExecutionInfo, }, hash_utils::calculate_contract_address, services::api::{ - contract_class_errors::ContractClassError, contract_classes::compiled_class::CompiledClass, + contract_class_errors::ContractClassError, + contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::EntryPointType, + }, + }, + state::{ + cached_state::CachedState, + contract_class_cache::ContractClassCache, + state_api::{State, StateReader}, + ExecutionResourcesManager, }, - state::state_api::{State, StateReader}, - state::ExecutionResourcesManager, syscalls::syscall_handler_errors::SyscallHandlerError, transaction::error::TransactionError, utils::{calculate_tx_resources, Address, ClassHash}, @@ -150,9 +152,9 @@ impl DeployAccount { } } - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { self.handle_nonce(state)?; @@ -190,9 +192,9 @@ impl DeployAccount { /// Execute a call to the cairo-vm using the accounts_validation.cairo contract to validate /// the contract that is being declared. Then it returns the transaction execution info of the run. - fn apply( + fn apply( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, ) -> Result { let contract_class = state.get_contract_class(&self.class_hash)?; @@ -228,10 +230,10 @@ impl DeployAccount { )) } - pub fn handle_constructor( + pub fn handle_constructor( &self, contract_class: CompiledClass, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, resources_manager: &mut ExecutionResourcesManager, ) -> Result { @@ -267,9 +269,9 @@ impl DeployAccount { Ok(()) } - pub fn run_constructor_entrypoint( + pub fn run_constructor_entrypoint( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, resources_manager: &mut ExecutionResourcesManager, ) -> Result { @@ -314,9 +316,9 @@ impl DeployAccount { ) } - pub fn run_validate_entrypoint( + pub fn run_validate_entrypoint( &self, - state: &mut CachedState, + state: &mut CachedState, resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, ) -> Result, TransactionError> { @@ -385,21 +387,19 @@ impl DeployAccount { #[cfg(test)] mod tests { - use std::{ - collections::HashMap, - path::PathBuf, - sync::{Arc, RwLock}, - }; - use super::*; use crate::{ core::{contract_address::compute_deprecated_class_hash, errors::state_errors::StateError}, definitions::block_context::StarknetChainId, services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, state::in_memory_state_reader::InMemoryStateReader, + state::{cached_state::CachedState, contract_class_cache::PermanentContractClassCache}, utils::felt_to_hash, }; + use std::{ + path::PathBuf, + sync::{Arc, RwLock}, + }; #[test] fn get_state_selector() { @@ -412,7 +412,7 @@ mod tests { let block_context = BlockContext::default(); let mut _state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let internal_deploy = DeployAccount::new( @@ -447,7 +447,7 @@ mod tests { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let internal_deploy = DeployAccount::new( @@ -500,7 +500,7 @@ mod tests { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let internal_deploy = DeployAccount::new( diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 92806ba2e..98062b931 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -1,19 +1,20 @@ use super::error::TransactionError; -use crate::definitions::constants::{FEE_FACTOR, QUERY_VERSION_BASE}; -use crate::execution::execution_entry_point::ExecutionResult; -use crate::execution::CallType; -use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; -use crate::state::cached_state::CachedState; use crate::{ definitions::{ block_context::BlockContext, - constants::{INITIAL_GAS_COST, TRANSFER_ENTRY_POINT_SELECTOR}, + constants::{ + FEE_FACTOR, INITIAL_GAS_COST, QUERY_VERSION_BASE, TRANSFER_ENTRY_POINT_SELECTOR, + }, }, execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, TransactionExecutionContext, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, CallType, TransactionExecutionContext, + }, + services::api::contract_classes::deprecated_contract_class::EntryPointType, + state::{ + cached_state::CachedState, contract_class_cache::ContractClassCache, + state_api::StateReader, ExecutionResourcesManager, }, - state::state_api::StateReader, - state::ExecutionResourcesManager, }; use cairo_vm::felt::Felt252; use num_traits::{ToPrimitive, Zero}; @@ -25,8 +26,8 @@ pub type FeeInfo = (Option, u128); /// Transfers the amount actual_fee from the caller account to the sequencer. /// Returns the resulting CallInfo of the transfer call. -pub(crate) fn execute_fee_transfer( - state: &mut CachedState, +pub(crate) fn execute_fee_transfer( + state: &mut CachedState, block_context: &BlockContext, tx_execution_context: &mut TransactionExecutionContext, actual_fee: u128, @@ -136,8 +137,8 @@ fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap( - state: &mut CachedState, +pub fn charge_fee( + state: &mut CachedState, resources: &HashMap, block_context: &BlockContext, max_fee: u128, @@ -185,23 +186,25 @@ pub fn charge_fee( #[cfg(test)] mod tests { - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; - use crate::{ definitions::block_context::BlockContext, execution::TransactionExecutionContext, - state::{cached_state::CachedState, in_memory_state_reader::InMemoryStateReader}, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, transaction::{error::TransactionError, fee::charge_fee}, }; + use std::{ + collections::HashMap, + sync::{Arc, RwLock}, + }; #[test] fn test_charge_fee_v0_actual_fee_exceeds_max_fee_should_return_error() { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut tx_execution_context = TransactionExecutionContext::default(); let mut block_context = BlockContext::default(); @@ -230,7 +233,7 @@ mod tests { fn test_charge_fee_v1_actual_fee_exceeds_max_fee_should_return_error() { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let mut tx_execution_context = TransactionExecutionContext { version: 1.into(), diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index c6840f4a4..51dc7e5fb 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -1,3 +1,4 @@ +use super::{fee::charge_fee, Transaction}; use crate::{ core::transaction_hash::{calculate_transaction_hash_common, TransactionHashPrefix}, definitions::{ @@ -11,19 +12,20 @@ use crate::{ execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, CallInfo, TransactionExecutionContext, TransactionExecutionInfo, }, - state::state_api::{State, StateReader}, - state::{cached_state::CachedState, ExecutionResourcesManager}, + services::api::contract_classes::deprecated_contract_class::EntryPointType, + state::{ + cached_state::CachedState, + contract_class_cache::ContractClassCache, + state_api::{State, StateReader}, + ExecutionResourcesManager, + }, transaction::error::TransactionError, utils::{calculate_tx_resources, Address}, }; - -use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; -use super::{fee::charge_fee, Transaction}; - /// Represents an InvokeFunction transaction in the starknet network. #[derive(Debug, Getters, Clone)] pub struct InvokeFunction { @@ -144,9 +146,9 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - resources_manager: the resources that are in use by the contract /// - block_context: The block's execution context - pub(crate) fn run_validate_entrypoint( + pub(crate) fn run_validate_entrypoint( &self, - state: &mut CachedState, + state: &mut CachedState, resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, ) -> Result, TransactionError> { @@ -188,9 +190,9 @@ impl InvokeFunction { /// Builds the transaction execution context and executes the entry point. /// Returns the CallInfo. - fn run_execute_entrypoint( + fn run_execute_entrypoint( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, resources_manager: &mut ExecutionResourcesManager, remaining_gas: u128, @@ -221,9 +223,9 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. /// - remaining_gas: The amount of gas that the transaction disposes. - pub fn apply( + pub fn apply( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, remaining_gas: u128, ) -> Result { @@ -270,9 +272,9 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. /// - remaining_gas: The amount of gas that the transaction disposes. - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, remaining_gas: u128, ) -> Result { @@ -405,15 +407,15 @@ mod tests { compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, state::cached_state::CachedState, - state::in_memory_state_reader::InMemoryStateReader, + state::{ + contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, + }, utils::calculate_sn_keccak, }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; use num_traits::Num; - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; + use std::sync::{Arc, RwLock}; #[test] fn test_invoke_apply_without_fees() { @@ -457,14 +459,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -534,14 +531,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -607,14 +599,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -674,14 +661,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -747,14 +729,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -814,14 +791,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -879,14 +851,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -945,14 +912,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -1016,14 +978,9 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, @@ -1163,9 +1120,10 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut casm_contract_class_cache = HashMap::new(); + let mut casm_contract_class_cache = PermanentContractClassCache::default(); - casm_contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + casm_contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state = CachedState::new( Arc::new(state_reader), diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index c1382508e..b12178aa7 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -1,7 +1,7 @@ use crate::{ execution::execution_entry_point::ExecutionResult, services::api::contract_classes::deprecated_contract_class::EntryPointType, - state::cached_state::CachedState, + state::{cached_state::CachedState, contract_class_cache::ContractClassCache}, }; use cairo_vm::felt::Felt252; use getset::Getters; @@ -93,9 +93,9 @@ impl L1Handler { } /// Applies self to 'state' by executing the L1-handler entry point. - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, remaining_gas: u128, ) -> Result { @@ -206,31 +206,29 @@ impl L1Handler { #[cfg(test)] mod test { - use std::{ - collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, - }; - - use crate::services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::EntryPointType, - }; - use cairo_vm::{ - felt::{felt_str, Felt252}, - vm::runners::cairo_runner::ExecutionResources, - }; - use num_traits::{Num, Zero}; - use crate::{ definitions::{block_context::BlockContext, transaction_type::TransactionType}, execution::{CallInfo, TransactionExecutionInfo}, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, + deprecated_contract_class::{ContractClass, EntryPointType}, + }, state::{ - cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, - state_api::State, + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::State, }, transaction::l1_handler::L1Handler, utils::Address, }; + use cairo_vm::{ + felt::{felt_str, Felt252}, + vm::runners::cairo_runner::ExecutionResources, + }; + use num_traits::{Num, Zero}; + use std::{ + collections::{HashMap, HashSet}, + sync::{Arc, RwLock}, + }; #[test] fn test_execute_l1_handler() { @@ -270,14 +268,9 @@ mod test { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); - // Initialize state.contract_classes - state - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); - state .set_contract_class( &class_hash, diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index 645a08b8f..5584aa940 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -1,3 +1,20 @@ +use crate::{ + definitions::block_context::BlockContext, + execution::TransactionExecutionInfo, + state::{ + cached_state::CachedState, contract_class_cache::ContractClassCache, state_api::StateReader, + }, + utils::Address, +}; +pub use declare::Declare; +pub use declare_v2::DeclareV2; +pub use deploy::Deploy; +pub use deploy_account::DeployAccount; +use error::TransactionError; +pub use invoke_function::InvokeFunction; +pub use l1_handler::L1Handler; +pub use verify_version::verify_version; + pub mod declare; pub mod declare_v2; pub mod deploy; @@ -8,22 +25,6 @@ pub mod invoke_function; pub mod l1_handler; mod verify_version; -pub use declare::Declare; -pub use declare_v2::DeclareV2; -pub use deploy::Deploy; -pub use deploy_account::DeployAccount; -pub use invoke_function::InvokeFunction; -pub use l1_handler::L1Handler; -pub use verify_version::verify_version; - -use crate::{ - definitions::block_context::BlockContext, - execution::TransactionExecutionInfo, - state::{cached_state::CachedState, state_api::StateReader}, - utils::Address, -}; -use error::TransactionError; - /// Represents a transaction inside the starknet network. /// The transaction are actions that may modified the state of the network. /// it can be one of: @@ -66,9 +67,9 @@ impl Transaction { ///- state: a structure that implements State and StateReader traits. ///- block_context: The block context of the transaction that is about to be executed. ///- remaining_gas: The gas supplied to execute the transaction. - pub fn execute( + pub fn execute( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, remaining_gas: u128, ) -> Result { diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index 06a081bc1..2c931724e 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -1,8 +1,3 @@ -use std::{ - collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, -}; - use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::{ felt::{felt_str, Felt252}, @@ -10,7 +5,6 @@ use cairo_vm::{ }; use num_bigint::BigUint; use num_traits::{Num, One, Zero}; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ @@ -20,9 +14,19 @@ use starknet_in_rust::{ services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, - state::{cached_state::CachedState, state_api::StateReader}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + state_api::StateReader, + ExecutionResourcesManager, + }, utils::{Address, ClassHash}, + EntryPointType, +}; +use std::{ + collections::{HashMap, HashSet}, + sync::{Arc, RwLock}, }; fn create_execute_extrypoint( @@ -59,13 +63,14 @@ fn storage_write_read() { let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -201,13 +206,14 @@ fn library_call() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -229,7 +235,7 @@ fn library_call() { let lib_class_hash: ClassHash = [2; 32]; let lib_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( lib_class_hash, CompiledClass::Casm(Arc::new(lib_contract_class)), ); @@ -364,13 +370,14 @@ fn call_contract_storage_write_read() { let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -401,7 +408,7 @@ fn call_contract_storage_write_read() { let simple_wallet_class_hash: ClassHash = [2; 32]; let simple_wallet_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( simple_wallet_class_hash, CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), ); @@ -556,13 +563,14 @@ fn emit_event() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -671,14 +679,15 @@ fn deploy_cairo1_from_cairo1() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - contract_class_cache.insert( + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Casm(Arc::new(test_contract_class.clone())), ); @@ -774,14 +783,15 @@ fn deploy_cairo0_from_cairo1_without_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - contract_class_cache.insert( + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Deprecated(Arc::new(test_contract_class.clone())), ); @@ -875,15 +885,16 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); // simulate contract declare - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - contract_class_cache.insert( + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Deprecated(Arc::new(test_contract_class.clone())), ); @@ -979,14 +990,15 @@ fn deploy_cairo0_and_invoke() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - contract_class_cache.insert( + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Deprecated(Arc::new(test_contract_class.clone())), ); @@ -1000,7 +1012,7 @@ fn deploy_cairo0_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state: CachedState<_> = CachedState::new( + let mut state: CachedState<_, _> = CachedState::new( Arc::new(state_reader), Arc::new(RwLock::new(contract_class_cache)), ); @@ -1106,13 +1118,14 @@ fn test_send_message_to_l1_syscall() { let external_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader @@ -1203,13 +1216,14 @@ fn test_get_execution_info() { let external_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -1301,13 +1315,13 @@ fn replace_class_internal() { let upgrade_selector = &entrypoints_a.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_a, CompiledClass::Casm(Arc::new(contract_class_a)), ); @@ -1328,7 +1342,7 @@ fn replace_class_internal() { let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_b, CompiledClass::Casm(Arc::new(contract_class_b.clone())), ); @@ -1406,13 +1420,13 @@ fn replace_class_contract_call() { let contract_class_a: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_a, CompiledClass::Casm(Arc::new(contract_class_a)), ); @@ -1436,7 +1450,7 @@ fn replace_class_contract_call() { let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_b, CompiledClass::Casm(Arc::new(contract_class_b)), ); @@ -1456,7 +1470,7 @@ fn replace_class_contract_call() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( wrapper_class_hash, CompiledClass::Casm(Arc::new(wrapper_contract_class)), ); @@ -1585,13 +1599,13 @@ fn replace_class_contract_call_same_transaction() { let contract_class_a: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_a, CompiledClass::Casm(Arc::new(contract_class_a)), ); @@ -1615,7 +1629,7 @@ fn replace_class_contract_call_same_transaction() { let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_b, CompiledClass::Casm(Arc::new(contract_class_b)), ); @@ -1634,7 +1648,7 @@ fn replace_class_contract_call_same_transaction() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( wrapper_class_hash, CompiledClass::Casm(Arc::new(wrapper_contract_class)), ); @@ -1711,13 +1725,13 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_c, CompiledClass::Deprecated(Arc::new(contract_class_c)), ); @@ -1741,7 +1755,7 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let class_hash_b: ClassHash = Felt252::from(2).to_be_bytes(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_b, CompiledClass::Casm(Arc::new(contract_class_b)), ); @@ -1760,7 +1774,7 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( wrapper_class_hash, CompiledClass::Casm(Arc::new(wrapper_contract_class)), ); @@ -1835,13 +1849,13 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_c, CompiledClass::Deprecated(Arc::new(contract_class_c)), ); @@ -1858,7 +1872,7 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let class_hash_b: ClassHash = Felt252::from(2).to_be_bytes(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_b, CompiledClass::Casm(Arc::new(contract_class_b)), ); @@ -1884,7 +1898,7 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( wrapper_class_hash, CompiledClass::Casm(Arc::new(wrapper_contract_class)), ); @@ -1959,13 +1973,13 @@ fn call_contract_replace_class_cairo_0() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_c, CompiledClass::Deprecated(Arc::new(contract_class_c)), ); @@ -1978,7 +1992,7 @@ fn call_contract_replace_class_cairo_0() { let class_hash_d: ClassHash = Felt252::from(2).to_be_bytes(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_d, CompiledClass::Deprecated(Arc::new(contract_class_d)), ); @@ -2004,7 +2018,7 @@ fn call_contract_replace_class_cairo_0() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( wrapper_class_hash, CompiledClass::Casm(Arc::new(wrapper_contract_class)), ); @@ -2079,13 +2093,14 @@ fn test_out_of_gas_failure() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2159,13 +2174,14 @@ fn deploy_syscall_failure_uninitialized_class_hash() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2238,13 +2254,14 @@ fn deploy_syscall_failure_in_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2260,7 +2277,7 @@ fn deploy_syscall_failure_in_constructor() { let f_c_program_data = include_bytes!("../starknet_programs/cairo1/failing_constructor.casm"); let f_c_contract_class: CasmContractClass = serde_json::from_slice(f_c_program_data).unwrap(); let f_c_class_hash = Felt252::one(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( f_c_class_hash.to_be_bytes(), CompiledClass::Casm(Arc::new(f_c_contract_class)), ); @@ -2331,13 +2348,14 @@ fn storage_read_no_value() { let get_balance_entrypoint_selector = &entrypoints.external.get(1).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2405,13 +2423,14 @@ fn storage_read_unavailable_address_domain() { let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2482,13 +2501,14 @@ fn storage_write_unavailable_address_domain() { let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2557,13 +2577,14 @@ fn library_call_failure() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2584,7 +2605,7 @@ fn library_call_failure() { let lib_class_hash: ClassHash = [2; 32]; let lib_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( lib_class_hash, CompiledClass::Casm(Arc::new(lib_contract_class)), ); @@ -2672,13 +2693,14 @@ fn send_messages_to_l1_different_contract_calls() { .clone(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2699,7 +2721,7 @@ fn send_messages_to_l1_different_contract_calls() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( send_msg_class_hash, CompiledClass::Casm(Arc::new(send_msg_contract_class)), ); @@ -2798,13 +2820,14 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { .clone(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -2822,7 +2845,7 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( send_msg_class_hash, CompiledClass::Deprecated(Arc::new(send_msg_contract_class)), ); @@ -2916,13 +2939,13 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { .to_owned(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -2946,7 +2969,7 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( send_msg_class_hash, CompiledClass::Casm(Arc::new(send_msg_contract_class)), ); @@ -3039,13 +3062,14 @@ fn keccak_syscall() { let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index ac178bbec..b05d72bcb 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -10,13 +10,15 @@ use starknet_in_rust::EntryPointType; use starknet_in_rust::{ execution::{CallInfo, CallType}, services::api::contract_classes::deprecated_contract_class::ContractClass, - state::{cached_state::CachedState, state_api::StateReader}, + state::cached_state::CachedState, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, transaction::error::TransactionError, utils::{calculate_sn_keccak, Address}, }; use crate::complex_contracts::utils::*; +use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; +use starknet_in_rust::state::state_api::StateReader; fn init_pool( calldata: &[Felt252], @@ -56,7 +58,7 @@ fn amm_init_pool_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -125,7 +127,7 @@ fn amm_add_demo_tokens_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -203,7 +205,7 @@ fn amm_get_pool_token_balance() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -278,7 +280,7 @@ fn amm_swap_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -379,7 +381,7 @@ fn amm_init_pool_should_fail_with_amount_out_of_bounds() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -418,7 +420,7 @@ fn amm_swap_should_fail_with_unexistent_token() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -457,7 +459,7 @@ fn amm_swap_should_fail_with_amount_out_of_bounds() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -496,7 +498,7 @@ fn amm_swap_should_fail_when_user_does_not_have_enough_funds() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -538,7 +540,7 @@ fn amm_get_account_token_balance_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, class_hash) = deploy( diff --git a/tests/complex_contracts/amm_contracts/amm_proxy.rs b/tests/complex_contracts/amm_contracts/amm_proxy.rs index 2174551e8..a959f06e4 100644 --- a/tests/complex_contracts/amm_contracts/amm_proxy.rs +++ b/tests/complex_contracts/amm_contracts/amm_proxy.rs @@ -1,25 +1,29 @@ use crate::complex_contracts::utils::*; -use cairo_vm::felt::Felt252; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; use starknet_crypto::FieldElement; -use starknet_in_rust::definitions::block_context::BlockContext; -use starknet_in_rust::services::api::contract_classes::deprecated_contract_class::ContractClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ + definitions::block_context::BlockContext, execution::{CallInfo, CallType}, - state::{cached_state::CachedState, state_api::StateReader}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::deprecated_contract_class::ContractClass, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::StateReader, + ExecutionResourcesManager, + }, utils::{calculate_sn_keccak, Address}, + EntryPointType, +}; +use std::{ + collections::{HashMap, HashSet}, + sync::{Arc, RwLock}, }; -use std::collections::{HashMap, HashSet}; -use std::sync::{Arc, RwLock}; #[test] fn amm_proxy_init_pool_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -119,7 +123,7 @@ fn amm_proxy_get_pool_token_balance_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -226,7 +230,7 @@ fn amm_proxy_add_demo_token_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -339,7 +343,7 @@ fn amm_proxy_get_account_token_balance() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -465,7 +469,7 @@ fn amm_proxy_swap() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( diff --git a/tests/complex_contracts/nft/erc721.rs b/tests/complex_contracts/nft/erc721.rs index d42c79886..77ba9a3e9 100644 --- a/tests/complex_contracts/nft/erc721.rs +++ b/tests/complex_contracts/nft/erc721.rs @@ -14,19 +14,20 @@ use starknet_in_rust::transaction::error::TransactionError; use starknet_in_rust::EntryPointType; use starknet_in_rust::{ execution::{CallInfo, CallType, OrderedEvent}, - state::state_api::StateReader, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{calculate_sn_keccak, Address}, }; use crate::complex_contracts::utils::*; +use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; +use starknet_in_rust::state::state_api::StateReader; #[test] fn erc721_constructor_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be(b"some-nft"); @@ -72,7 +73,7 @@ fn erc721_balance_of_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -162,7 +163,7 @@ fn erc721_test_owner_of() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -244,7 +245,7 @@ fn erc721_test_get_approved() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -343,7 +344,7 @@ fn erc721_test_is_approved_for_all() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -445,7 +446,7 @@ fn erc721_test_approve() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -549,7 +550,7 @@ fn erc721_set_approval_for_all() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -647,7 +648,7 @@ fn erc721_transfer_from_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -787,7 +788,7 @@ fn erc721_transfer_from_and_get_owner_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -878,7 +879,7 @@ fn erc721_safe_transfer_from_should_fail_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -945,7 +946,7 @@ fn erc721_calling_constructor_twice_should_fail_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -994,7 +995,7 @@ fn erc721_constructor_should_fail_with_to_equal_zero() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -1021,7 +1022,7 @@ fn erc721_transfer_fail_to_zero_address() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -1075,7 +1076,7 @@ fn erc721_transfer_fail_not_owner() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); diff --git a/tests/complex_contracts/utils.rs b/tests/complex_contracts/utils.rs index 1deeba647..1367d5226 100644 --- a/tests/complex_contracts/utils.rs +++ b/tests/complex_contracts/utils.rs @@ -15,19 +15,22 @@ use starknet_in_rust::{ services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, - state::{cached_state::CachedState, state_api::State}, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + state_api::State, + }, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, transaction::{error::TransactionError, Deploy}, utils::{calculate_sn_keccak, Address}, + ContractEntryPoint, EntryPointType, }; -use starknet_in_rust::{ContractEntryPoint, EntryPointType}; use std::{ collections::{HashMap, HashSet}, sync::Arc, }; pub struct CallConfig<'a> { - pub state: &'a mut CachedState, + pub state: &'a mut CachedState, pub caller_address: &'a Address, pub address: &'a Address, pub class_hash: &'a [u8; 32], @@ -136,7 +139,7 @@ pub fn execute_entry_point( } pub fn deploy( - state: &mut CachedState, + state: &mut CachedState, path: &str, calldata: &[Felt252], block_context: &BlockContext, diff --git a/tests/delegate_call.rs b/tests/delegate_call.rs index 95d5280f0..f1186dad9 100644 --- a/tests/delegate_call.rs +++ b/tests/delegate_call.rs @@ -2,20 +2,27 @@ use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + ExecutionResourcesManager, + }, utils::Address, + EntryPointType, +}; +use std::{ + path::PathBuf, + sync::{Arc, RwLock}, }; -use std::sync::{Arc, RwLock}; -use std::{collections::HashMap, path::PathBuf}; #[test] fn delegate_call() { @@ -23,7 +30,7 @@ fn delegate_call() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let nonce = Felt252::zero(); // Add get_number.cairo contract to the state @@ -34,7 +41,7 @@ fn delegate_call() { let address = Address(Felt252::one()); // const CONTRACT_ADDRESS = 1; let class_hash = [2; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -68,7 +75,7 @@ fn delegate_call() { let address = Address(1111.into()); let class_hash = [1; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); diff --git a/tests/delegate_l1_handler.rs b/tests/delegate_l1_handler.rs index 504c9b411..5cc217bb5 100644 --- a/tests/delegate_l1_handler.rs +++ b/tests/delegate_l1_handler.rs @@ -2,29 +2,34 @@ use cairo_vm::felt::{felt_str, Felt252}; use num_traits::{One, Zero}; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{ - cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager, }, utils::Address, + EntryPointType, +}; +use std::{ + path::PathBuf, + sync::{Arc, RwLock}, }; -use std::sync::{Arc, RwLock}; -use std::{collections::HashMap, path::PathBuf}; #[test] fn delegate_l1_handler() { //* -------------------------------------------- //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let nonce = Felt252::zero(); // Add get_number.cairo contract to the state @@ -35,7 +40,7 @@ fn delegate_l1_handler() { let address = Address(Felt252::one()); // const CONTRACT_ADDRESS = 1; let class_hash = [2; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -63,7 +68,7 @@ fn delegate_l1_handler() { let address = Address(1111.into()); let class_hash = [1; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index c1a5467d9..f491bbd53 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -12,18 +12,19 @@ use starknet_in_rust::{ }, execution::{CallInfo, CallType, TransactionExecutionInfo}, hash_utils::calculate_contract_address, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::in_memory_state_reader::InMemoryStateReader, - state::{cached_state::CachedState, state_api::State}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::State, + }, transaction::DeployAccount, utils::Address, - CasmContractClass, -}; -use starknet_in_rust::{ - services::api::contract_classes::compiled_class::CompiledClass, EntryPointType, + CasmContractClass, EntryPointType, }; use std::{ - collections::{HashMap, HashSet}, + collections::HashSet, sync::{Arc, RwLock}, }; @@ -34,9 +35,10 @@ lazy_static! { #[test] fn internal_deploy_account() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::new()))); - - state.set_contract_classes(Default::default()).unwrap(); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); let contract_class = ContractClass::from_path("starknet_programs/account_without_validation.json").unwrap(); @@ -117,9 +119,10 @@ fn internal_deploy_account() { #[test] fn internal_deploy_account_cairo1() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(HashMap::default()))); - - state.set_contract_classes(Default::default()).unwrap(); + let mut state = CachedState::new( + state_reader, + Arc::new(RwLock::new(PermanentContractClassCache::default())), + ); #[cfg(not(feature = "cairo_1_tests"))] let program_data = include_bytes!("../starknet_programs/cairo2/hello_world_account.casm"); diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index 6e344c209..4a102a162 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -2,24 +2,33 @@ #![deny(warnings)] use cairo_lang_starknet::casm_contract_class::CasmContractClass; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; -use cairo_vm::{felt::Felt252, vm::runners::builtin_runner::RANGE_CHECK_BUILTIN_NAME}; +use cairo_vm::{ + felt::Felt252, + vm::runners::{builtin_runner::RANGE_CHECK_BUILTIN_NAME, cairo_runner::ExecutionResources}, +}; use num_traits::Zero; -use starknet_in_rust::definitions::block_context::BlockContext; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ - definitions::constants::TRANSACTION_VERSION, + definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + ExecutionResourcesManager, + }, utils::{Address, ClassHash}, + EntryPointType, +}; +use std::{ + collections::HashMap, + path::PathBuf, + sync::{Arc, RwLock}, }; -use std::sync::{Arc, RwLock}; -use std::{collections::HashMap, path::PathBuf}; #[test] fn integration_test() { @@ -43,7 +52,7 @@ fn integration_test() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- @@ -51,7 +60,7 @@ fn integration_test() { let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -152,13 +161,14 @@ fn integration_test_cairo1() { let fib_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index c9c04d4cf..bb2efad9a 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -1,24 +1,29 @@ #![deny(warnings)] -use cairo_vm::felt::Felt252; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; use num_traits::Zero; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::{cached_state::CachedState, state_cache::StorageEntry}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + state_cache::StorageEntry, + ExecutionResourcesManager, + }, utils::{calculate_sn_keccak, Address}, + EntryPointType, }; -use std::sync::{Arc, RwLock}; use std::{ - collections::{HashMap, HashSet}, + collections::HashSet, path::PathBuf, + sync::{Arc, RwLock}, }; #[test] @@ -44,7 +49,7 @@ fn hello_starknet_increase_balance() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- @@ -54,7 +59,7 @@ fn hello_starknet_increase_balance() { let storage_entry: StorageEntry = (address.clone(), [1; 32]); let storage = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); diff --git a/tests/internal_calls.rs b/tests/internal_calls.rs index e1e458aff..bfb3656e4 100644 --- a/tests/internal_calls.rs +++ b/tests/internal_calls.rs @@ -1,22 +1,26 @@ #![deny(warnings)] -use std::sync::{Arc, RwLock}; - use cairo_vm::felt::Felt252; use num_traits::Zero; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::{cached_state::CachedState, state_cache::StorageEntry}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + state_cache::StorageEntry, + ExecutionResourcesManager, + }, utils::{calculate_sn_keccak, Address, ClassHash}, + EntryPointType, }; -use std::collections::HashMap; +use std::sync::{Arc, RwLock}; #[test] fn test_internal_calls() { @@ -49,10 +53,14 @@ fn test_internal_calls() { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(HashMap::from([( - [0x01; 32], - CompiledClass::Deprecated(Arc::new(contract_class)), - )]))), + Arc::new(RwLock::new({ + let mut cache = PermanentContractClassCache::default(); + cache.set_contract_class( + [0x01; 32], + CompiledClass::Deprecated(Arc::new(contract_class)), + ); + cache + })), ); let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"a")); diff --git a/tests/internals.rs b/tests/internals.rs index cd80ea00a..86a9eb59f 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -1,61 +1,61 @@ // This module tests our code against the blockifier to ensure they work in the same way. use assert_matches::assert_matches; use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; -use cairo_vm::felt::{felt_str, Felt252}; -use cairo_vm::vm::runners::builtin_runner::{HASH_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME}; -use cairo_vm::vm::{ - errors::{ - cairo_run_errors::CairoRunError, vm_errors::VirtualMachineError, vm_exception::VmException, +use cairo_vm::{ + felt::{felt_str, Felt252}, + vm::runners::builtin_runner::{HASH_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME}, + vm::{ + errors::{ + cairo_run_errors::CairoRunError, vm_errors::VirtualMachineError, + vm_exception::VmException, + }, + runners::cairo_runner::ExecutionResources, }, - runners::cairo_runner::ExecutionResources, }; use lazy_static::lazy_static; use num_bigint::BigUint; use num_traits::{FromPrimitive, Num, One, Zero}; -use starknet_in_rust::core::contract_address::{ - compute_casm_class_hash, compute_sierra_class_hash, -}; -use starknet_in_rust::core::errors::state_errors::StateError; -use starknet_in_rust::definitions::constants::{ - DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS, VALIDATE_ENTRY_POINT_SELECTOR, -}; -use starknet_in_rust::execution::execution_entry_point::ExecutionEntryPoint; -use starknet_in_rust::execution::TransactionExecutionContext; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::services::api::contract_classes::deprecated_contract_class::ContractClass; -use starknet_in_rust::state::ExecutionResourcesManager; -use starknet_in_rust::transaction::fee::calculate_tx_fee; -use starknet_in_rust::transaction::{DeclareV2, Deploy}; -use starknet_in_rust::CasmContractClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ + core::{ + contract_address::{compute_casm_class_hash, compute_sierra_class_hash}, + errors::state_errors::StateError, + }, definitions::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, constants::{ - CONSTRUCTOR_ENTRY_POINT_SELECTOR, EXECUTE_ENTRY_POINT_SELECTOR, TRANSACTION_VERSION, - TRANSFER_ENTRY_POINT_SELECTOR, TRANSFER_EVENT_SELECTOR, - VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR, + CONSTRUCTOR_ENTRY_POINT_SELECTOR, DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS, + EXECUTE_ENTRY_POINT_SELECTOR, TRANSACTION_VERSION, TRANSFER_ENTRY_POINT_SELECTOR, + TRANSFER_EVENT_SELECTOR, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, + VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR, VALIDATE_ENTRY_POINT_SELECTOR, }, transaction_type::TransactionType, }, - execution::{CallInfo, CallType, OrderedEvent, TransactionExecutionInfo}, - state::in_memory_state_reader::InMemoryStateReader, + execution::{ + execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, OrderedEvent, + TransactionExecutionContext, TransactionExecutionInfo, + }, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{ cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, state_api::{State, StateReader}, - state_cache::StateCache, - state_cache::StorageEntry, - BlockInfo, + state_cache::{StateCache, StorageEntry}, + BlockInfo, ExecutionResourcesManager, }, transaction::{ - error::TransactionError, - DeployAccount, - {invoke_function::InvokeFunction, Declare}, + error::TransactionError, fee::calculate_tx_fee, invoke_function::InvokeFunction, Declare, + DeclareV2, Deploy, DeployAccount, }, utils::{calculate_sn_keccak, felt_to_hash, Address, ClassHash}, + CasmContractClass, EntryPointType, +}; +use std::{ + collections::{HashMap, HashSet}, + sync::{Arc, RwLock}, }; -use std::collections::{HashMap, HashSet}; -use std::sync::{Arc, RwLock}; const ACCOUNT_CONTRACT_PATH: &str = "starknet_programs/account_without_validation.json"; const ERC20_CONTRACT_PATH: &str = "starknet_programs/ERC20.json"; @@ -118,8 +118,13 @@ pub fn new_starknet_block_context_for_testing() -> BlockContext { ) } -fn create_account_tx_test_state( -) -> Result<(BlockContext, CachedState), Box> { +fn create_account_tx_test_state() -> Result< + ( + BlockContext, + CachedState, + ), + Box, +> { let block_context = new_starknet_block_context_for_testing(); let test_contract_class_hash = felt_to_hash(&TEST_CLASS_HASH.clone()); @@ -195,44 +200,45 @@ fn create_account_tx_test_state( } Arc::new(state_reader) }, - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); Ok((block_context, cached_state)) } -fn expected_state_before_tx() -> CachedState { +fn expected_state_before_tx() -> CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); CachedState::new( Arc::new(in_memory_state_reader), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ) } -fn expected_state_after_tx(fee: u128) -> CachedState { +fn expected_state_after_tx( + fee: u128, +) -> CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); - let contract_classes_cache = HashMap::from([ - ( - felt_to_hash(&TEST_CLASS_HASH.clone()), - CompiledClass::Deprecated(Arc::new( - ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), - )), - ), - ( - felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH.clone()), - CompiledClass::Deprecated(Arc::new( - ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), - )), - ), - ( - felt_to_hash(&TEST_ERC20_CONTRACT_CLASS_HASH.clone()), - CompiledClass::Deprecated(Arc::new( - ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), - )), - ), - ]); + let mut contract_classes_cache = PermanentContractClassCache::default(); + contract_classes_cache.set_contract_class( + felt_to_hash(&TEST_CLASS_HASH.clone()), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(TEST_CONTRACT_PATH).unwrap(), + )), + ); + contract_classes_cache.set_contract_class( + felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH.clone()), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ACCOUNT_CONTRACT_PATH).unwrap(), + )), + ); + contract_classes_cache.set_contract_class( + felt_to_hash(&TEST_ERC20_CONTRACT_CLASS_HASH.clone()), + CompiledClass::Deprecated(Arc::new( + ContractClass::from_path(ERC20_CONTRACT_PATH).unwrap(), + )), + ); CachedState::new_for_testing( Arc::new(in_memory_state_reader), @@ -528,8 +534,15 @@ fn test_create_account_tx_test_state() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - *state.contract_classes().read().unwrap(), - *expected_initial_state.contract_classes().read().unwrap() + (&*state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*expected_initial_state + .contract_class_cache() + .read() + .unwrap()) + .into_iter() + .collect::>() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -874,8 +887,15 @@ fn test_declare_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - *state.contract_classes().read().unwrap(), - *expected_initial_state.contract_classes().read().unwrap() + (&*state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*expected_initial_state + .contract_class_cache() + .read() + .unwrap()) + .into_iter() + .collect::>() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -958,8 +978,15 @@ fn test_declarev2_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - *state.contract_classes().read().unwrap(), - *expected_initial_state.contract_classes().read().unwrap() + (&*state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*expected_initial_state + .contract_class_cache() + .read() + .unwrap()) + .into_iter() + .collect::>() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -1300,8 +1327,15 @@ fn test_invoke_tx_state() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - *state.contract_classes().read().unwrap(), - *expected_initial_state.contract_classes().read().unwrap() + (&*state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*expected_initial_state + .contract_class_cache() + .read() + .unwrap()) + .into_iter() + .collect::>() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -1373,8 +1407,15 @@ fn test_invoke_with_declarev2_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - *state.contract_classes().read().unwrap(), - *expected_initial_state.contract_classes().read().unwrap() + (&*state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*expected_initial_state + .contract_class_cache() + .read() + .unwrap()) + .into_iter() + .collect::>() ); assert_eq!( &state.state_reader.address_to_class_hash, @@ -1471,8 +1512,12 @@ fn test_deploy_account() { assert_eq!(&state.cache(), &state_before.cache()); assert_eq!( - *state.contract_classes().read().unwrap(), - *state_before.contract_classes().read().unwrap() + (&*state.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>(), + (&*state_before.contract_class_cache().read().unwrap()) + .into_iter() + .collect::>() ); let tx_info = deploy_account_tx @@ -1551,8 +1596,8 @@ fn test_deploy_account() { } fn expected_deploy_account_states() -> ( - CachedState, - CachedState, + CachedState, + CachedState, ) { let fee = Felt252::from(6157); let mut state_before = CachedState::new( @@ -1596,7 +1641,7 @@ fn expected_deploy_account_states() -> ( ]), HashMap::new(), )), - Arc::new(RwLock::new(HashMap::new())), + Arc::new(RwLock::new(PermanentContractClassCache::default())), ); state_before.set_storage_at( &( @@ -1610,9 +1655,8 @@ fn expected_deploy_account_states() -> ( // Make the contract cache independent (otherwise tests will fail because the initial state's // cache will not be empty anymore). - state_after - .set_contract_classes(Arc::new(RwLock::new(HashMap::new()))) - .unwrap(); + *state_after.contract_class_cache_mut() = + Arc::new(RwLock::new(PermanentContractClassCache::default())); state_after.cache_mut().nonce_initial_values_mut().insert( Address(felt_str!( diff --git a/tests/multi_syscall_test.rs b/tests/multi_syscall_test.rs index bcc271b9b..e76944fa1 100644 --- a/tests/multi_syscall_test.rs +++ b/tests/multi_syscall_test.rs @@ -1,21 +1,23 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::felt::Felt252; use num_traits::{Num, Zero}; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::utils::calculate_sn_keccak; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, }, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, - utils::{Address, ClassHash}, + services::api::contract_classes::compiled_class::CompiledClass, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + ExecutionResourcesManager, + }, + utils::{calculate_sn_keccak, Address, ClassHash}, + EntryPointType, }; -use std::sync::RwLock; -use std::{collections::HashMap, sync::Arc, vec}; +use std::{sync::Arc, sync::RwLock, vec}; #[test] fn test_multiple_syscall() { @@ -24,13 +26,14 @@ fn test_multiple_syscall() { let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache: HashMap<[u8; 32], _> = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); let mut state_reader = InMemoryStateReader::default(); state_reader .address_to_class_hash_mut() @@ -221,7 +224,7 @@ fn test_syscall( caller_address: Address, entry_point_type: EntryPointType, class_hash: [u8; 32], - state: &mut CachedState, + state: &mut CachedState, ) -> CallInfo { let entrypoint_selector = Felt252::from_bytes_be(&calculate_sn_keccak(entrypoint_selector.as_bytes())); diff --git a/tests/storage.rs b/tests/storage.rs index 5565d536f..6ea67a80b 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -1,22 +1,27 @@ use cairo_vm::felt::Felt252; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use num_traits::Zero; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + ExecutionResourcesManager, + }, utils::{calculate_sn_keccak, Address}, + EntryPointType, }; -use std::sync::{Arc, RwLock}; use std::{ - collections::{HashMap, HashSet}, + collections::HashSet, path::PathBuf, + sync::{Arc, RwLock}, }; #[test] @@ -41,7 +46,7 @@ fn integration_storage_test() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- @@ -51,7 +56,7 @@ fn integration_storage_test() { let storage_entry = (address.clone(), [90; 32]); let storage_value = Felt252::new(10902); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); diff --git a/tests/syscalls.rs b/tests/syscalls.rs index 58d0b7ad3..b525853a8 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -19,16 +19,18 @@ use starknet_in_rust::{ execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, L2toL1MessageInfo, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, state::{ cached_state::CachedState, - state_api::{State, StateReader}, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + state_api::State, + ExecutionResourcesManager, }, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{calculate_sn_keccak, felt_to_hash, Address, ClassHash}, -}; -use starknet_in_rust::{ - services::api::contract_classes::compiled_class::CompiledClass, EntryPointType, + EntryPointType, }; use std::{ collections::{HashMap, HashSet}, @@ -92,13 +94,13 @@ fn test_contract<'a>( let mut storage_entries = Vec::new(); let contract_class_cache = { - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); for (class_hash, contract_path, contract_address) in extra_contracts { let contract_class = ContractClass::from_path(contract_path) .expect("Could not load extra contract from JSON"); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class.clone())), ); @@ -1087,18 +1089,18 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); // simulate contract declare - contract_class_cache.insert( + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Casm(Arc::new(test_contract_class.clone())), ); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -1192,18 +1194,18 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); // simulate contract declare - contract_class_cache.insert( + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Casm(Arc::new(test_contract_class.clone())), ); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -1299,18 +1301,18 @@ fn deploy_cairo1_and_invoke() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); // simulate contract declare - contract_class_cache.insert( + contract_class_cache.set_contract_class( test_class_hash, CompiledClass::Casm(Arc::new(test_contract_class.clone())), ); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -1428,13 +1430,13 @@ fn send_messages_to_l1_different_contract_calls() { .to_owned(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), ); @@ -1455,7 +1457,7 @@ fn send_messages_to_l1_different_contract_calls() { let send_msg_class_hash: ClassHash = [2; 32]; let send_msg_nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( send_msg_class_hash, CompiledClass::Deprecated(Arc::new(send_msg_contract_class)), ); diff --git a/tests/syscalls_errors.rs b/tests/syscalls_errors.rs index a1f0043b0..b6fa07ac8 100644 --- a/tests/syscalls_errors.rs +++ b/tests/syscalls_errors.rs @@ -1,25 +1,30 @@ #![deny(warnings)] +use assert_matches::assert_matches; use cairo_vm::felt::Felt252; -use starknet_in_rust::utils::felt_to_hash; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ core::errors::state_errors::StateError, definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, - services::api::contract_classes::deprecated_contract_class::ContractClass, - state::{cached_state::CachedState, state_api::State}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, - utils::{calculate_sn_keccak, Address, ClassHash}, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + state_api::State, + ExecutionResourcesManager, + }, + utils::{calculate_sn_keccak, felt_to_hash, Address, ClassHash}, + EntryPointType, +}; +use std::{ + path::Path, + sync::{Arc, RwLock}, }; -use std::path::Path; -use std::sync::{Arc, RwLock}; - -use assert_matches::assert_matches; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use std::collections::HashMap; #[allow(clippy::too_many_arguments)] fn test_contract<'a>( @@ -69,13 +74,13 @@ fn test_contract<'a>( let mut storage_entries = Vec::new(); let contract_class_cache = { - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); for (class_hash, contract_path, contract_address) in extra_contracts { let contract_class = ContractClass::from_path(contract_path) .expect("Could not load extra contract from JSON"); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class.clone())), ); From 661a76a283c115fb5d5db48a26baf68f85cadb69 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 12:30:46 +0200 Subject: [PATCH 13/56] Add documentation. --- src/state/contract_class_cache.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/state/contract_class_cache.rs b/src/state/contract_class_cache.rs index 20bd7756d..55c6d0346 100644 --- a/src/state/contract_class_cache.rs +++ b/src/state/contract_class_cache.rs @@ -1,11 +1,31 @@ +//! # Contract cache system +//! +//! The contract caches allow the application to keep some contracts within itself, providing them +//! efficiently when they are needed. +//! +//! The trait `ContractClassCache` provides methods for retrieving and inserting elements into the +//! cache. It also contains a method to extend the shared cache from an iterator so that it can be +//! used with the private caches. +//! +//! TODO: Right now, it's impossible to implement the issue's `merge_caches` because +//! `ContractClassCache::extend` will be called already with the write lock in place. To solve +//! this, the lock may be pushed into the cache, but the methods will not be able to have +//! `&mut self` as the object. + use crate::{services::api::contract_classes::compiled_class::CompiledClass, utils::ClassHash}; use std::collections::HashMap; +/// The contract class cache trait, which must be implemented by all caches. pub trait ContractClassCache { + /// Provides the stored contract class associated with a specific class hash, or `None` if not + /// present. fn get_contract_class(&self, class_hash: ClassHash) -> Option; + /// Inserts or replaces a contract class associated with a specific class hash. fn set_contract_class(&mut self, class_hash: ClassHash, compiled_class: CompiledClass); - fn merge_with(&mut self, other: I) + /// Performs a bulk insert of contract classes from an iterator over pairs of the class hash and + /// its contract class. + fn extend(&mut self, other: I) where I: IntoIterator; } @@ -44,6 +64,8 @@ pub trait ContractClassCache { // state.contract_class_cache_private // } +/// A contract class cache which stores nothing. In other words, using this as a cache means there's +/// effectively no cache. #[derive(Clone, Copy, Debug, Default, Hash)] pub struct NullContractClassCache; @@ -56,7 +78,7 @@ impl ContractClassCache for NullContractClassCache { // Nothing needs to be done here. } - fn merge_with(&mut self, _other: I) + fn extend(&mut self, _other: I) where I: IntoIterator, { @@ -64,6 +86,8 @@ impl ContractClassCache for NullContractClassCache { } } +/// A contract class cache which stores everything. This cache is useful for testing but will +/// probably end up taking all the memory available if the application is long running. #[derive(Clone, Debug, Default)] pub struct PermanentContractClassCache { storage: HashMap, @@ -78,7 +102,7 @@ impl ContractClassCache for PermanentContractClassCache { self.storage.insert(class_hash, compiled_class); } - fn merge_with(&mut self, other: I) + fn extend(&mut self, other: I) where I: IntoIterator, { From c9687170322416fdc26569a4632282426e109b74 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 12:50:10 +0200 Subject: [PATCH 14/56] Convert the cache trait into immutable (aka. move the lock into them). --- fuzzer/src/main.rs | 2 +- src/lib.rs | 4 +-- src/state/contract_class_cache.rs | 39 +++++++++++++-------- src/testing/erc20.rs | 2 +- src/testing/state.rs | 2 +- src/transaction/declare.rs | 19 ++++++----- src/transaction/invoke_function.rs | 2 +- tests/cairo_1_syscalls.rs | 54 +++++++++++++++--------------- tests/delegate_call.rs | 2 +- tests/delegate_l1_handler.rs | 2 +- tests/fibonacci.rs | 4 +-- tests/increase_balance.rs | 2 +- tests/internal_calls.rs | 2 +- tests/internals.rs | 2 +- tests/multi_syscall_test.rs | 2 +- tests/storage.rs | 2 +- tests/syscalls.rs | 10 +++--- tests/syscalls_errors.rs | 2 +- 18 files changed, 84 insertions(+), 70 deletions(-) diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 3f3839c26..25b1e8b8f 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -112,7 +112,7 @@ fn main() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- diff --git a/src/lib.rs b/src/lib.rs index aded66d9e..64822344b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,7 +321,7 @@ mod test { let entrypoints = contract_class.clone().entry_points_by_type; let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -430,7 +430,7 @@ mod test { let entrypoints = contract_class.clone().entry_points_by_type; let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; diff --git a/src/state/contract_class_cache.rs b/src/state/contract_class_cache.rs index 55c6d0346..ddbd3bfd2 100644 --- a/src/state/contract_class_cache.rs +++ b/src/state/contract_class_cache.rs @@ -13,7 +13,7 @@ //! `&mut self` as the object. use crate::{services::api::contract_classes::compiled_class::CompiledClass, utils::ClassHash}; -use std::collections::HashMap; +use std::{collections::HashMap, sync::RwLock}; /// The contract class cache trait, which must be implemented by all caches. pub trait ContractClassCache { @@ -21,11 +21,11 @@ pub trait ContractClassCache { /// present. fn get_contract_class(&self, class_hash: ClassHash) -> Option; /// Inserts or replaces a contract class associated with a specific class hash. - fn set_contract_class(&mut self, class_hash: ClassHash, compiled_class: CompiledClass); + fn set_contract_class(&self, class_hash: ClassHash, compiled_class: CompiledClass); /// Performs a bulk insert of contract classes from an iterator over pairs of the class hash and /// its contract class. - fn extend(&mut self, other: I) + fn extend(&self, other: I) where I: IntoIterator; } @@ -74,11 +74,11 @@ impl ContractClassCache for NullContractClassCache { None } - fn set_contract_class(&mut self, _class_hash: ClassHash, _compiled_class: CompiledClass) { + fn set_contract_class(&self, _class_hash: ClassHash, _compiled_class: CompiledClass) { // Nothing needs to be done here. } - fn extend(&mut self, _other: I) + fn extend(&self, _other: I) where I: IntoIterator, { @@ -88,25 +88,36 @@ impl ContractClassCache for NullContractClassCache { /// A contract class cache which stores everything. This cache is useful for testing but will /// probably end up taking all the memory available if the application is long running. -#[derive(Clone, Debug, Default)] +#[derive(Debug, Default)] pub struct PermanentContractClassCache { - storage: HashMap, + storage: RwLock>, } impl ContractClassCache for PermanentContractClassCache { fn get_contract_class(&self, class_hash: ClassHash) -> Option { - self.storage.get(&class_hash).cloned() + self.storage.read().unwrap().get(&class_hash).cloned() } - fn set_contract_class(&mut self, class_hash: ClassHash, compiled_class: CompiledClass) { - self.storage.insert(class_hash, compiled_class); + fn set_contract_class(&self, class_hash: ClassHash, compiled_class: CompiledClass) { + self.storage + .write() + .unwrap() + .insert(class_hash, compiled_class); } - fn extend(&mut self, other: I) + fn extend(&self, other: I) where I: IntoIterator, { - self.storage.extend(other); + self.storage.write().unwrap().extend(other); + } +} + +impl Clone for PermanentContractClassCache { + fn clone(&self) -> Self { + Self { + storage: RwLock::new(self.storage.read().unwrap().clone()), + } } } @@ -115,7 +126,7 @@ impl IntoIterator for PermanentContractClassCache { type IntoIter = as IntoIterator>::IntoIter; fn into_iter(self) -> Self::IntoIter { - self.storage.into_iter() + self.storage.into_inner().unwrap().into_iter() } } @@ -124,6 +135,6 @@ impl IntoIterator for &PermanentContractClassCache { type IntoIter = as IntoIterator>::IntoIter; fn into_iter(self) -> Self::IntoIter { - self.storage.clone().into_iter() + self.storage.read().unwrap().clone().into_iter() } } diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index 2c7357f39..2022ac284 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -60,7 +60,7 @@ fn test_erc20_cairo2() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; diff --git a/src/testing/state.rs b/src/testing/state.rs index 5bd45e4be..faed53ea0 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -419,7 +419,7 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- // hack store account contract diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index 100ab67b1..d5b08accb 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -357,7 +357,7 @@ mod tests { ContractClass::from_path("starknet_programs/account_without_validation.json").unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); @@ -473,13 +473,16 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = HashMap::new(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); let class_hash = felt_to_hash(&hash); - contract_class_cache.insert(class_hash, contract_class); + contract_class_cache.set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); //* --------------------------------------- //* Test declare with previous data @@ -520,7 +523,7 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); @@ -589,7 +592,7 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); @@ -657,7 +660,7 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); @@ -739,7 +742,7 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); @@ -849,7 +852,7 @@ mod tests { let contract_class = ContractClass::from_path(path).unwrap(); // Instantiate CachedState - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- let hash = compute_deprecated_class_hash(&contract_class).unwrap(); diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 51dc7e5fb..dc5602f2d 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -1120,7 +1120,7 @@ mod tests { .address_to_nonce .insert(contract_address, nonce); - let mut casm_contract_class_cache = PermanentContractClassCache::default(); + let casm_contract_class_cache = PermanentContractClassCache::default(); casm_contract_class_cache .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index 2c931724e..00fcb42e4 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -63,7 +63,7 @@ fn storage_write_read() { let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -206,7 +206,7 @@ fn library_call() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -370,7 +370,7 @@ fn call_contract_storage_write_read() { let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -563,7 +563,7 @@ fn emit_event() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -679,7 +679,7 @@ fn deploy_cairo1_from_cairo1() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -783,7 +783,7 @@ fn deploy_cairo0_from_cairo1_without_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -885,7 +885,7 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -990,7 +990,7 @@ fn deploy_cairo0_and_invoke() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -1118,7 +1118,7 @@ fn test_send_message_to_l1_syscall() { let external_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -1216,7 +1216,7 @@ fn test_get_execution_info() { let external_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -1315,7 +1315,7 @@ fn replace_class_internal() { let upgrade_selector = &entrypoints_a.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash_a: ClassHash = [1; 32]; @@ -1420,7 +1420,7 @@ fn replace_class_contract_call() { let contract_class_a: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_a: ClassHash = [1; 32]; @@ -1599,7 +1599,7 @@ fn replace_class_contract_call_same_transaction() { let contract_class_a: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_a: ClassHash = [1; 32]; @@ -1725,7 +1725,7 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); @@ -1849,7 +1849,7 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); @@ -1973,7 +1973,7 @@ fn call_contract_replace_class_cairo_0() { let contract_class_c = ContractClass::from_path("starknet_programs/get_number_c.json").unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_c: ClassHash = Felt252::one().to_be_bytes(); @@ -2093,7 +2093,7 @@ fn test_out_of_gas_failure() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2174,7 +2174,7 @@ fn deploy_syscall_failure_uninitialized_class_hash() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2254,7 +2254,7 @@ fn deploy_syscall_failure_in_constructor() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2348,7 +2348,7 @@ fn storage_read_no_value() { let get_balance_entrypoint_selector = &entrypoints.external.get(1).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2423,7 +2423,7 @@ fn storage_read_unavailable_address_domain() { let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2501,7 +2501,7 @@ fn storage_write_unavailable_address_domain() { let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2577,7 +2577,7 @@ fn library_call_failure() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2693,7 +2693,7 @@ fn send_messages_to_l1_different_contract_calls() { .clone(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2820,7 +2820,7 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { .clone(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -2939,7 +2939,7 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { .to_owned(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -3062,7 +3062,7 @@ fn keccak_syscall() { let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; diff --git a/tests/delegate_call.rs b/tests/delegate_call.rs index f1186dad9..2f28219bd 100644 --- a/tests/delegate_call.rs +++ b/tests/delegate_call.rs @@ -30,7 +30,7 @@ fn delegate_call() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let nonce = Felt252::zero(); // Add get_number.cairo contract to the state diff --git a/tests/delegate_l1_handler.rs b/tests/delegate_l1_handler.rs index 5cc217bb5..0dd5d7def 100644 --- a/tests/delegate_l1_handler.rs +++ b/tests/delegate_l1_handler.rs @@ -29,7 +29,7 @@ fn delegate_l1_handler() { //* -------------------------------------------- //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let nonce = Felt252::zero(); // Add get_number.cairo contract to the state diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index 4a102a162..60655f1d0 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -52,7 +52,7 @@ fn integration_test() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- @@ -161,7 +161,7 @@ fn integration_test_cairo1() { let fib_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index bb2efad9a..54ee5b5d2 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -49,7 +49,7 @@ fn hello_starknet_increase_balance() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- diff --git a/tests/internal_calls.rs b/tests/internal_calls.rs index bfb3656e4..610736ae3 100644 --- a/tests/internal_calls.rs +++ b/tests/internal_calls.rs @@ -54,7 +54,7 @@ fn test_internal_calls() { let mut state = CachedState::new( Arc::new(state_reader), Arc::new(RwLock::new({ - let mut cache = PermanentContractClassCache::default(); + let cache = PermanentContractClassCache::default(); cache.set_contract_class( [0x01; 32], CompiledClass::Deprecated(Arc::new(contract_class)), diff --git a/tests/internals.rs b/tests/internals.rs index 86a9eb59f..4fd197d06 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -220,7 +220,7 @@ fn expected_state_after_tx( ) -> CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); - let mut contract_classes_cache = PermanentContractClassCache::default(); + let contract_classes_cache = PermanentContractClassCache::default(); contract_classes_cache.set_contract_class( felt_to_hash(&TEST_CLASS_HASH.clone()), CompiledClass::Deprecated(Arc::new( diff --git a/tests/multi_syscall_test.rs b/tests/multi_syscall_test.rs index e76944fa1..97882a10c 100644 --- a/tests/multi_syscall_test.rs +++ b/tests/multi_syscall_test.rs @@ -26,7 +26,7 @@ fn test_multiple_syscall() { let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; diff --git a/tests/storage.rs b/tests/storage.rs index 6ea67a80b..29e9744b5 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -46,7 +46,7 @@ fn integration_storage_test() { //* Create state reader with class hash data //* -------------------------------------------- - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); // ------------ contract data -------------------- diff --git a/tests/syscalls.rs b/tests/syscalls.rs index b525853a8..f036d5ac4 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -94,7 +94,7 @@ fn test_contract<'a>( let mut storage_entries = Vec::new(); let contract_class_cache = { - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); for (class_hash, contract_path, contract_address) in extra_contracts { let contract_class = ContractClass::from_path(contract_path) @@ -1089,7 +1089,7 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -1194,7 +1194,7 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -1301,7 +1301,7 @@ fn deploy_cairo1_and_invoke() { let test_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; @@ -1430,7 +1430,7 @@ fn send_messages_to_l1_different_contract_calls() { .to_owned(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; diff --git a/tests/syscalls_errors.rs b/tests/syscalls_errors.rs index b6fa07ac8..e578ec94b 100644 --- a/tests/syscalls_errors.rs +++ b/tests/syscalls_errors.rs @@ -74,7 +74,7 @@ fn test_contract<'a>( let mut storage_entries = Vec::new(); let contract_class_cache = { - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); for (class_hash, contract_path, contract_address) in extra_contracts { let contract_class = ContractClass::from_path(contract_path) From f10bb1da530fe85c7e270eb8df7283b6e49e2628 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 13:06:10 +0200 Subject: [PATCH 15/56] Remove external cache lock (no longer needed). --- bench/internals.rs | 13 +- cli/src/main.rs | 4 +- fuzzer/src/main.rs | 14 +- rpc_state_reader/src/lib.rs | 4 +- src/bin/fibonacci.rs | 7 +- src/bin/invoke.rs | 7 +- src/bin/invoke_with_cachedstate.rs | 13 +- src/lib.rs | 45 +++--- src/state/cached_state.rs | 50 +++---- src/state/mod.rs | 24 ++- src/syscalls/deprecated_syscall_handler.rs | 16 +- src/syscalls/deprecated_syscall_response.rs | 4 +- src/testing/erc20.rs | 5 +- src/testing/mod.rs | 7 +- src/testing/state.rs | 9 +- src/transaction/declare.rs | 38 +---- src/transaction/declare_v2.rs | 32 +--- src/transaction/deploy.rs | 11 +- src/transaction/deploy_account.rs | 11 +- src/transaction/fee.rs | 9 +- src/transaction/invoke_function.rs | 26 ++-- src/transaction/l1_handler.rs | 4 +- tests/cairo_1_syscalls.rs | 138 ++++-------------- tests/complex_contracts/amm_contracts/amm.rs | 49 ++++--- .../amm_contracts/amm_proxy.rs | 12 +- tests/complex_contracts/nft/erc721.rs | 65 +++++---- tests/delegate_call.rs | 10 +- tests/delegate_l1_handler.rs | 10 +- tests/deploy_account.rs | 9 +- tests/fibonacci.rs | 4 +- tests/increase_balance.rs | 11 +- tests/internal_calls.rs | 6 +- tests/internals.rs | 52 +++---- tests/multi_syscall_test.rs | 7 +- tests/storage.rs | 11 +- tests/syscalls.rs | 10 +- tests/syscalls_errors.rs | 10 +- 37 files changed, 259 insertions(+), 498 deletions(-) diff --git a/bench/internals.rs b/bench/internals.rs index 5d811df55..abb10cd2e 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -22,10 +22,7 @@ use starknet_in_rust::{ transaction::{declare::Declare, Deploy, DeployAccount, InvokeFunction}, utils::Address, }; -use std::{ - hint::black_box, - sync::{Arc, RwLock}, -}; +use std::{hint::black_box, sync::Arc}; lazy_static! { // include_str! doesn't seem to work in CI @@ -71,7 +68,7 @@ fn deploy_account() { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -113,7 +110,7 @@ fn declare() { let state_reader = Arc::new(InMemoryStateReader::default()); let state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let block_context = &Default::default(); @@ -148,7 +145,7 @@ fn deploy() { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -189,7 +186,7 @@ fn invoke() { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state diff --git a/cli/src/main.rs b/cli/src/main.rs index 847c326fd..241fb3a7d 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -36,7 +36,7 @@ use starknet_in_rust::{ }; use std::{ path::PathBuf, - sync::{Arc, Mutex, RwLock}, + sync::{Arc, Mutex}, }; #[derive(Parser)] @@ -320,7 +320,7 @@ pub async fn start_devnet(port: u16) -> Result<(), std::io::Error> { let cached_state = web::Data::new(AppState { cached_state: Mutex::new(CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), )), }); diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 25b1e8b8f..8bac1f09e 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -24,13 +24,7 @@ use starknet_in_rust::{ EntryPointType, }; use std::{ - collections::HashSet, - fs, - path::PathBuf, - process::Command, - sync::{Arc, RwLock}, - thread, - time::Duration, + collections::HashSet, fs, path::PathBuf, process::Command, sync::Arc, thread, time::Duration, }; fn main() { @@ -132,10 +126,8 @@ fn main() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = + CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* ------------------------------------ //* Create execution entry point diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 58b380035..1745329ed 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -741,7 +741,7 @@ mod transaction_tests { felt::felt_str, state::{cached_state::CachedState, contract_class_cache::PermanentContractClassCache}, }; - use std::sync::{Arc, RwLock}; + use std::sync::Arc; fn test_tx( tx_hash: &str, @@ -756,7 +756,7 @@ mod transaction_tests { let rpc_state = Arc::new(RpcState::new(network, block)); let mut state = CachedState::new( rpc_state.clone(), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let fee_token_address = Address(felt_str!( diff --git a/src/bin/fibonacci.rs b/src/bin/fibonacci.rs index 221623606..fb2aea5dc 100644 --- a/src/bin/fibonacci.rs +++ b/src/bin/fibonacci.rs @@ -12,10 +12,7 @@ use starknet_in_rust::{ testing::state::StarknetState, utils::Address, }; -use std::{ - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::{path::PathBuf, sync::Arc}; #[cfg(feature = "with_mimalloc")] use mimalloc::MiMalloc; @@ -95,7 +92,7 @@ fn create_initial_state() -> CachedState CachedState CachedState( transactions: &[&Transaction], state: S, - contract_class_cache: Arc>, + contract_class_cache: Arc, block_context: &BlockContext, remaining_gas: u128, skip_validate: bool, @@ -83,7 +83,7 @@ pub fn simulate_transaction( pub fn estimate_fee( transactions: &[Transaction], state: T, - contract_class_cache: Arc>, + contract_class_cache: Arc, block_context: &BlockContext, ) -> Result, TransactionError> where @@ -173,7 +173,7 @@ pub fn call_contract( pub fn estimate_message_fee( l1_handler: &L1Handler, state: T, - contract_class_cache: Arc>, + contract_class_cache: Arc, block_context: &BlockContext, ) -> Result<(u128, usize), TransactionError> where @@ -252,10 +252,7 @@ mod test { use cairo_vm::felt::{felt_str, Felt252}; use lazy_static::lazy_static; use num_traits::{Num, One, Zero}; - use std::{ - path::PathBuf, - sync::{Arc, RwLock}, - }; + use std::{path::PathBuf, sync::Arc}; lazy_static! { // include_str! doesn't seem to work in CI @@ -303,7 +300,7 @@ mod test { let estimated_fee = estimate_fee( &[transaction], state, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), &block_context, ) .unwrap(); @@ -337,10 +334,7 @@ mod test { .address_to_nonce_mut() .insert(address.clone(), nonce); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let retdata = call_contract( @@ -394,14 +388,12 @@ mod test { let state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Initialize state.contract_classes state .contract_class_cache() - .write() - .unwrap() .set_contract_class( class_hash, CompiledClass::Deprecated(Arc::new(contract_class)), @@ -447,10 +439,7 @@ mod test { .address_to_nonce_mut() .insert(address.clone(), nonce); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let invoke = InvokeFunction::new( @@ -590,7 +579,7 @@ mod test { let context = simulate_transaction( &[&invoke_1, &invoke_2, &invoke_3], state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), &block_context, 1000, false, @@ -693,7 +682,7 @@ mod test { let context = simulate_transaction( &[&invoke], state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), &block_context, 1000, true, @@ -714,7 +703,7 @@ mod test { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -760,7 +749,7 @@ mod test { let state_reader = Arc::new(InMemoryStateReader::default()); let state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let block_context = &Default::default(); @@ -801,7 +790,7 @@ mod test { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -869,7 +858,7 @@ mod test { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -998,7 +987,7 @@ mod test { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -1031,7 +1020,7 @@ mod test { let state_reader = Arc::new(InMemoryStateReader::default()); let state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let block_context = &Default::default(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 35927f32a..9b562391b 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -15,7 +15,7 @@ use num_traits::Zero; use std::{ cell::RefCell, collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, + sync::Arc, }; pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; @@ -28,13 +28,13 @@ pub struct CachedState { pub(crate) cache: StateCache, #[getset(get = "pub", get_mut = "pub")] - pub(crate) contract_class_cache: Arc>, + pub(crate) contract_class_cache: Arc, pub(crate) contract_class_cache_private: RefCell>, } impl CachedState { /// Constructor, creates a new cached state. - pub fn new(state_reader: Arc, contract_classes: Arc>) -> Self { + pub fn new(state_reader: Arc, contract_classes: Arc) -> Self { Self { cache: StateCache::default(), state_reader, @@ -47,7 +47,7 @@ impl CachedState { pub fn new_for_testing( state_reader: Arc, cache: StateCache, - contract_classes: Arc>, + contract_classes: Arc, ) -> Self { Self { cache, @@ -147,11 +147,8 @@ impl StateReader for CachedState { let mut private_cache = self.contract_class_cache_private.borrow_mut(); if let Some(compiled_class) = private_cache.get(class_hash) { return Ok(compiled_class.clone()); - } else if let Some(compiled_class) = self - .contract_class_cache - .read() - .unwrap() - .get_contract_class(*class_hash) + } else if let Some(compiled_class) = + self.contract_class_cache().get_contract_class(*class_hash) { private_cache.insert(*class_hash, compiled_class.clone()); return Ok(compiled_class); @@ -168,9 +165,7 @@ impl StateReader for CachedState { { return Ok(casm_class.clone()); } else if let Some(casm_class) = self - .contract_class_cache - .read() - .unwrap() + .contract_class_cache() .get_contract_class(*compiled_class_hash) { self.contract_class_cache_private @@ -401,11 +396,8 @@ impl State for CachedState { // deprecated contract classes dont have compiled class hashes, so we only have one case if let Some(compiled_class) = self.contract_class_cache_private.get_mut().get(class_hash) { return Ok(compiled_class.clone()); - } else if let Some(compiled_class) = self - .contract_class_cache - .read() - .unwrap() - .get_contract_class(*class_hash) + } else if let Some(compiled_class) = + self.contract_class_cache().get_contract_class(*class_hash) { self.contract_class_cache_private .get_mut() @@ -424,9 +416,7 @@ impl State for CachedState { { return Ok(casm_class.clone()); } else if let Some(casm_class) = self - .contract_class_cache - .read() - .unwrap() + .contract_class_cache() .get_contract_class(*compiled_class_hash) { self.contract_class_cache_private @@ -498,7 +488,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); assert_eq!( @@ -533,7 +523,7 @@ mod tests { let cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); assert_eq!( @@ -550,7 +540,7 @@ mod tests { fn cached_state_storage_test() { let mut cached_state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let storage_entry: StorageEntry = (Address(31.into()), [0; 32]); @@ -575,7 +565,7 @@ mod tests { let mut cached_state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); assert!(cached_state @@ -594,7 +584,7 @@ mod tests { let mut cached_state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // set storage_key @@ -628,7 +618,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let result = cached_state @@ -656,7 +646,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); cached_state @@ -687,7 +677,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); cached_state @@ -719,7 +709,7 @@ mod tests { let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let state_diff = StateDiff { @@ -757,7 +747,7 @@ mod tests { let state_reader = InMemoryStateReader::default(); let mut cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let address_one = Address(1.into()); diff --git a/src/state/mod.rs b/src/state/mod.rs index 2a85c7cc1..48afeafa2 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -12,10 +12,7 @@ use crate::{ }; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; use getset::Getters; -use std::{ - collections::HashMap, - sync::{Arc, RwLock}, -}; +use std::{collections::HashMap, sync::Arc}; pub mod cached_state; pub mod contract_class_cache; @@ -168,7 +165,7 @@ impl StateDiff { pub fn to_cached_state( &self, state_reader: Arc, - contract_class_cache: Arc>, + contract_class_cache: Arc, ) -> Result, StateError> where T: StateReader + Clone, @@ -254,10 +251,7 @@ mod test { utils::Address, }; use cairo_vm::felt::Felt252; - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; + use std::{collections::HashMap, sync::Arc}; #[test] fn test_from_cached_state_without_updates() { @@ -276,7 +270,7 @@ mod test { let cached_state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let diff = StateDiff::from_cached_state(cached_state).unwrap(); @@ -339,7 +333,7 @@ mod test { let cached_state_original = CachedState::new( Arc::new(state_reader.clone()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); @@ -347,15 +341,15 @@ mod test { let cached_state = diff .to_cached_state::<_, PermanentContractClassCache>( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ) .unwrap(); assert_eq!( - (&*cached_state_original.contract_class_cache().read().unwrap()) + (&*cached_state_original.contract_class_cache().clone()) .into_iter() .collect::>(), - (&*cached_state.contract_class_cache().read().unwrap()) + (&*cached_state.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -399,7 +393,7 @@ mod test { let cached_state = CachedState::new_for_testing( Arc::new(state_reader), cache, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut diff = StateDiff::from_cached_state(cached_state).unwrap(); diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index 9b44e8329..9ff857c71 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -263,7 +263,7 @@ mod tests { }; use cairo_vm::relocatable; use num_traits::Num; - use std::sync::{Arc, RwLock}; + use std::sync::Arc; type DeprecatedBLSyscallHandler<'a> = crate::syscalls::deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler< @@ -745,7 +745,7 @@ mod tests { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -784,7 +784,7 @@ mod tests { // invoke syscall let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -829,7 +829,7 @@ mod tests { // invoke syscall let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -900,7 +900,7 @@ mod tests { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -968,7 +968,7 @@ mod tests { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -1045,7 +1045,7 @@ mod tests { // Create SyscallHintProcessor let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), @@ -1142,7 +1142,7 @@ mod tests { // Create SyscallHintProcessor let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut syscall_handler_hint_processor = SyscallHintProcessor::new( DeprecatedBLSyscallHandler::default_with(&mut state), diff --git a/src/syscalls/deprecated_syscall_response.rs b/src/syscalls/deprecated_syscall_response.rs index 2093d772c..2a89b7fe4 100644 --- a/src/syscalls/deprecated_syscall_response.rs +++ b/src/syscalls/deprecated_syscall_response.rs @@ -320,7 +320,7 @@ mod tests { utils::{get_integer, test_utils::vm}, }; use cairo_vm::relocatable; - use std::sync::{Arc, RwLock}; + use std::sync::Arc; type DeprecatedBLSyscallHandler<'a> = crate::syscalls::deprecated_business_logic_syscall_handler::DeprecatedBLSyscallHandler< @@ -335,7 +335,7 @@ mod tests { // Initialize a VM and syscall handler let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let syscall = DeprecatedBLSyscallHandler::default_with(&mut state); let mut vm = vm!(); diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index 2022ac284..214db47d0 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -82,10 +82,7 @@ fn test_erc20_cairo2() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let name_ = Felt252::from_bytes_be(b"some-token"); let symbol_ = Felt252::from_bytes_be(b"my-super-awesome-token"); diff --git a/src/testing/mod.rs b/src/testing/mod.rs index 479168bc8..339528fa0 100644 --- a/src/testing/mod.rs +++ b/src/testing/mod.rs @@ -14,10 +14,7 @@ use crate::{ }; use lazy_static::lazy_static; use num_traits::Zero; -use std::{ - collections::HashMap, - sync::{Arc, RwLock}, -}; +use std::{collections::HashMap, sync::Arc}; pub mod erc20; pub mod state; @@ -164,7 +161,7 @@ pub fn create_account_tx_test_state() -> Result< } Arc::new(state_reader) }, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); Ok((block_context, cached_state)) diff --git a/src/testing/state.rs b/src/testing/state.rs index faed53ea0..81c57147d 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -25,8 +25,8 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; +use std::collections::HashMap; use std::sync::Arc; -use std::{collections::HashMap, sync::RwLock}; // --------------------------------------------------------------------- /// StarkNet testing object. Represents a state of a StarkNet network. @@ -45,7 +45,7 @@ impl StarknetState { let state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let l2_to_l1_messages = HashMap::new(); @@ -454,10 +454,7 @@ mod tests { CompiledClass::Deprecated(Arc::new(contract_class.clone())), ); - let state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* -------------------------------------------- //* Create starknet state with previous data diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index d5b08accb..5ee71a52d 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -344,11 +344,7 @@ mod tests { vm::runners::cairo_runner::ExecutionResources, }; use num_traits::{One, Zero}; - use std::{ - collections::HashMap, - path::PathBuf, - sync::{Arc, RwLock}, - }; + use std::{collections::HashMap, path::PathBuf, sync::Arc}; #[test] fn declare_fibonacci() { @@ -382,10 +378,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* --------------------------------------- //* Test declare with previous data @@ -548,10 +541,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let _state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* --------------------------------------- //* Test declare with previous data @@ -617,10 +607,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::new(1)); - let _state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let _state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* --------------------------------------- //* Test declare with previous data @@ -685,10 +672,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* --------------------------------------- //* Test declare with previous data @@ -767,10 +751,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* --------------------------------------- //* Test declare with previous data @@ -817,7 +798,7 @@ mod tests { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, Arc::new(RwLock::new(contract_class_cache))); + let mut state = CachedState::new(state_reader, Arc::new(contract_class_cache)); // There are no account contracts in the state, so the transaction should fail let fib_contract_class = @@ -877,10 +858,7 @@ mod tests { .address_to_nonce_mut() .insert(sender_address, Felt252::zero()); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* --------------------------------------- //* Test declare with previous data diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 5e1eb3b70..5692dade6 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -470,12 +470,7 @@ mod tests { use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; - use std::{ - fs::File, - io::BufReader, - path::PathBuf, - sync::{Arc, RwLock}, - }; + use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc}; #[test] fn create_declare_v2_without_casm_contract_class_test() { @@ -521,10 +516,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new( - state_reader, - Arc::new(RwLock::new(casm_contract_class_cache)), - ); + let mut state = CachedState::new(state_reader, Arc::new(casm_contract_class_cache)); // call compile and store assert!(internal_declare @@ -593,10 +585,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new( - state_reader, - Arc::new(RwLock::new(casm_contract_class_cache)), - ); + let mut state = CachedState::new(state_reader, Arc::new(casm_contract_class_cache)); // call compile and store assert!(internal_declare @@ -667,10 +656,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new( - state_reader, - Arc::new(RwLock::new(casm_contract_class_cache)), - ); + let mut state = CachedState::new(state_reader, Arc::new(casm_contract_class_cache)); // call compile and store assert!(internal_declare @@ -739,10 +725,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new( - state_reader, - Arc::new(RwLock::new(casm_contract_class_cache)), - ); + let mut state = CachedState::new(state_reader, Arc::new(casm_contract_class_cache)); // call compile and store assert!(internal_declare @@ -812,10 +795,7 @@ mod tests { // crate state to store casm contract class let casm_contract_class_cache = PermanentContractClassCache::default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new( - state_reader, - Arc::new(RwLock::new(casm_contract_class_cache)), - ); + let mut state = CachedState::new(state_reader, Arc::new(casm_contract_class_cache)); let expected_err = format!( "Invalid compiled class, expected class hash: {}, but received: {}", diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index d42d80ff1..1115055ea 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -314,10 +314,7 @@ mod tests { }, utils::calculate_sn_keccak, }; - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; + use std::{collections::HashMap, sync::Arc}; #[test] fn invoke_constructor_test() { @@ -325,7 +322,7 @@ mod tests { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Set contract_class @@ -376,7 +373,7 @@ mod tests { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let contract_class = @@ -408,7 +405,7 @@ mod tests { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let contract_path = "starknet_programs/amm.json"; diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index c41d1d175..fb7c9140b 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -396,10 +396,7 @@ mod tests { state::{cached_state::CachedState, contract_class_cache::PermanentContractClassCache}, utils::felt_to_hash, }; - use std::{ - path::PathBuf, - sync::{Arc, RwLock}, - }; + use std::{path::PathBuf, sync::Arc}; #[test] fn get_state_selector() { @@ -412,7 +409,7 @@ mod tests { let block_context = BlockContext::default(); let mut _state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let internal_deploy = DeployAccount::new( @@ -447,7 +444,7 @@ mod tests { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let internal_deploy = DeployAccount::new( @@ -500,7 +497,7 @@ mod tests { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let internal_deploy = DeployAccount::new( diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 98062b931..e63a2f1c6 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -195,16 +195,13 @@ mod tests { }, transaction::{error::TransactionError, fee::charge_fee}, }; - use std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }; + use std::{collections::HashMap, sync::Arc}; #[test] fn test_charge_fee_v0_actual_fee_exceeds_max_fee_should_return_error() { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut tx_execution_context = TransactionExecutionContext::default(); let mut block_context = BlockContext::default(); @@ -233,7 +230,7 @@ mod tests { fn test_charge_fee_v1_actual_fee_exceeds_max_fee_should_return_error() { let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let mut tx_execution_context = TransactionExecutionContext { version: 1.into(), diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index dc5602f2d..4cd192fe8 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -415,7 +415,7 @@ mod tests { }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; use num_traits::Num; - use std::sync::{Arc, RwLock}; + use std::sync::Arc; #[test] fn test_invoke_apply_without_fees() { @@ -459,7 +459,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -531,7 +531,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -599,7 +599,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -661,7 +661,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -729,7 +729,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -791,7 +791,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -851,7 +851,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -912,7 +912,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -978,7 +978,7 @@ mod tests { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state @@ -1125,10 +1125,8 @@ mod tests { casm_contract_class_cache .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(casm_contract_class_cache)), - ); + let mut state = + CachedState::new(Arc::new(state_reader), Arc::new(casm_contract_class_cache)); let state_before_execution = state.clone(); diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index b12178aa7..70f6543ab 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -227,7 +227,7 @@ mod test { use num_traits::{Num, Zero}; use std::{ collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, + sync::Arc, }; #[test] @@ -268,7 +268,7 @@ mod test { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index 00fcb42e4..e4b542843 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -26,7 +26,7 @@ use starknet_in_rust::{ }; use std::{ collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, + sync::Arc, }; fn create_execute_extrypoint( @@ -80,10 +80,7 @@ fn storage_write_read() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -247,10 +244,7 @@ fn library_call() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -420,10 +414,7 @@ fn call_contract_storage_write_read() { .insert(simple_wallet_address.clone(), simple_wallet_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -580,10 +571,7 @@ fn emit_event() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [].to_vec(); @@ -701,10 +689,7 @@ fn deploy_cairo1_from_cairo1() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -805,10 +790,7 @@ fn deploy_cairo0_from_cairo1_without_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -908,10 +890,7 @@ fn deploy_cairo0_from_cairo1_with_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt, address.0.clone(), Felt252::zero()].to_vec(); @@ -1012,10 +991,8 @@ fn deploy_cairo0_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state: CachedState<_, _> = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state: CachedState<_, _> = + CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1136,10 +1113,7 @@ fn test_send_message_to_l1_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // RUN SEND_MSG // Create an execution entry point @@ -1233,10 +1207,7 @@ fn test_get_execution_info() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -1348,10 +1319,7 @@ fn replace_class_internal() { ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Run upgrade entrypoint and check that the storage was updated with the new contract class // Create an execution entry point @@ -1482,10 +1450,7 @@ fn replace_class_contract_call() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1660,10 +1625,7 @@ fn replace_class_contract_call_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1786,10 +1748,7 @@ fn call_contract_upgrade_cairo_0_to_cairo_1_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -1910,10 +1869,7 @@ fn call_contract_downgrade_cairo_1_to_cairo_0_same_transaction() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -2030,10 +1986,7 @@ fn call_contract_replace_class_cairo_0() { .insert(wrapper_address, nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // INITIALIZE STARKNET CONFIG let block_context = BlockContext::default(); @@ -2110,10 +2063,7 @@ fn test_out_of_gas_failure() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [].to_vec(); @@ -2191,10 +2141,7 @@ fn deploy_syscall_failure_uninitialized_class_hash() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [Felt252::zero()].to_vec(); @@ -2283,10 +2230,7 @@ fn deploy_syscall_failure_in_constructor() { ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [f_c_class_hash].to_vec(); @@ -2365,10 +2309,7 @@ fn storage_read_no_value() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2440,10 +2381,7 @@ fn storage_read_unavailable_address_domain() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2518,10 +2456,7 @@ fn storage_write_unavailable_address_domain() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( @@ -2617,10 +2552,7 @@ fn library_call_failure() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -2733,10 +2665,7 @@ fn send_messages_to_l1_different_contract_calls() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2857,10 +2786,7 @@ fn send_messages_to_l1_different_contract_calls_cairo1_to_cairo0() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -2981,10 +2907,7 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); @@ -3079,10 +3002,7 @@ fn keccak_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let block_context = BlockContext::default(); let mut tx_execution_context = TransactionExecutionContext::new( diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index b05d72bcb..2a846b967 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -1,24 +1,27 @@ -use std::collections::{HashMap, HashSet}; -use std::sync::{Arc, RwLock}; - -use cairo_vm::vm::runners::builtin_runner::HASH_BUILTIN_NAME; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; -use cairo_vm::{felt::Felt252, vm::runners::builtin_runner::RANGE_CHECK_BUILTIN_NAME}; +use crate::complex_contracts::utils::*; +use cairo_vm::{ + felt::Felt252, + vm::runners::{ + builtin_runner::{HASH_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME}, + cairo_runner::ExecutionResources, + }, +}; use num_traits::Zero; -use starknet_in_rust::definitions::block_context::BlockContext; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ + definitions::block_context::BlockContext, execution::{CallInfo, CallType}, services::api::contract_classes::deprecated_contract_class::ContractClass, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::StateReader, + ExecutionResourcesManager, + }, transaction::error::TransactionError, utils::{calculate_sn_keccak, Address}, + EntryPointType, }; - -use crate::complex_contracts::utils::*; -use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; -use starknet_in_rust::state::state_api::StateReader; +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; fn init_pool( calldata: &[Felt252], @@ -58,7 +61,7 @@ fn amm_init_pool_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -127,7 +130,7 @@ fn amm_add_demo_tokens_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -205,7 +208,7 @@ fn amm_get_pool_token_balance() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -280,7 +283,7 @@ fn amm_swap_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -381,7 +384,7 @@ fn amm_init_pool_should_fail_with_amount_out_of_bounds() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -420,7 +423,7 @@ fn amm_swap_should_fail_with_unexistent_token() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -459,7 +462,7 @@ fn amm_swap_should_fail_with_amount_out_of_bounds() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -498,7 +501,7 @@ fn amm_swap_should_fail_when_user_does_not_have_enough_funds() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( @@ -540,7 +543,7 @@ fn amm_get_account_token_balance_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, class_hash) = deploy( diff --git a/tests/complex_contracts/amm_contracts/amm_proxy.rs b/tests/complex_contracts/amm_contracts/amm_proxy.rs index a959f06e4..bba8c7eea 100644 --- a/tests/complex_contracts/amm_contracts/amm_proxy.rs +++ b/tests/complex_contracts/amm_contracts/amm_proxy.rs @@ -15,7 +15,7 @@ use starknet_in_rust::{ }; use std::{ collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, + sync::Arc, }; #[test] @@ -23,7 +23,7 @@ fn amm_proxy_init_pool_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -123,7 +123,7 @@ fn amm_proxy_get_pool_token_balance_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -230,7 +230,7 @@ fn amm_proxy_add_demo_token_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -343,7 +343,7 @@ fn amm_proxy_get_account_token_balance() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( @@ -469,7 +469,7 @@ fn amm_proxy_swap() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); // Deploy contract let (contract_address, contract_class_hash) = deploy( diff --git a/tests/complex_contracts/nft/erc721.rs b/tests/complex_contracts/nft/erc721.rs index 77ba9a3e9..a3985a0cf 100644 --- a/tests/complex_contracts/nft/erc721.rs +++ b/tests/complex_contracts/nft/erc721.rs @@ -1,33 +1,38 @@ -use std::collections::{HashMap, HashSet}; -use std::sync::{Arc, RwLock}; - +use crate::complex_contracts::utils::*; use assert_matches::assert_matches; -use cairo_vm::felt::Felt252; -use cairo_vm::vm::runners::builtin_runner::{HASH_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME}; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use cairo_vm::{ + felt::Felt252, + vm::runners::{ + builtin_runner::{HASH_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME}, + cairo_runner::ExecutionResources, + }, +}; use num_traits::Zero; use starknet_crypto::FieldElement; -use starknet_in_rust::definitions::block_context::BlockContext; -use starknet_in_rust::services::api::contract_classes::deprecated_contract_class::ContractClass; -use starknet_in_rust::state::cached_state::CachedState; -use starknet_in_rust::transaction::error::TransactionError; -use starknet_in_rust::EntryPointType; use starknet_in_rust::{ + definitions::block_context::BlockContext, execution::{CallInfo, CallType, OrderedEvent}, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + services::api::contract_classes::deprecated_contract_class::ContractClass, + state::{ + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::StateReader, + ExecutionResourcesManager, + }, + transaction::error::TransactionError, utils::{calculate_sn_keccak, Address}, + EntryPointType, +}; +use std::{ + collections::{HashMap, HashSet}, + sync::Arc, }; - -use crate::complex_contracts::utils::*; -use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; -use starknet_in_rust::state::state_api::StateReader; #[test] fn erc721_constructor_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be(b"some-nft"); @@ -73,7 +78,7 @@ fn erc721_balance_of_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -163,7 +168,7 @@ fn erc721_test_owner_of() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -245,7 +250,7 @@ fn erc721_test_get_approved() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -344,7 +349,7 @@ fn erc721_test_is_approved_for_all() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -446,7 +451,7 @@ fn erc721_test_approve() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -550,7 +555,7 @@ fn erc721_set_approval_for_all() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -648,7 +653,7 @@ fn erc721_transfer_from_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -788,7 +793,7 @@ fn erc721_transfer_from_and_get_owner_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -879,7 +884,7 @@ fn erc721_safe_transfer_from_should_fail_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -946,7 +951,7 @@ fn erc721_calling_constructor_twice_should_fail_test() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -995,7 +1000,7 @@ fn erc721_constructor_should_fail_with_to_equal_zero() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -1022,7 +1027,7 @@ fn erc721_transfer_fail_to_zero_address() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); @@ -1076,7 +1081,7 @@ fn erc721_transfer_fail_not_owner() { let block_context = BlockContext::default(); let mut state = CachedState::new( Arc::new(InMemoryStateReader::default()), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let collection_name = Felt252::from_bytes_be("some-nft".as_bytes()); diff --git a/tests/delegate_call.rs b/tests/delegate_call.rs index 2f28219bd..01025bdd8 100644 --- a/tests/delegate_call.rs +++ b/tests/delegate_call.rs @@ -19,10 +19,7 @@ use starknet_in_rust::{ utils::Address, EntryPointType, }; -use std::{ - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::{path::PathBuf, sync::Arc}; #[test] fn delegate_call() { @@ -90,10 +87,7 @@ fn delegate_call() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* ------------------------------------ //* Create execution entry point diff --git a/tests/delegate_l1_handler.rs b/tests/delegate_l1_handler.rs index 0dd5d7def..9a77f86d9 100644 --- a/tests/delegate_l1_handler.rs +++ b/tests/delegate_l1_handler.rs @@ -19,10 +19,7 @@ use starknet_in_rust::{ utils::Address, EntryPointType, }; -use std::{ - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::{path::PathBuf, sync::Arc}; #[test] fn delegate_l1_handler() { @@ -83,10 +80,7 @@ fn delegate_l1_handler() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* ------------------------------------ //* Create execution entry point diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index f491bbd53..40b013973 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -23,10 +23,7 @@ use starknet_in_rust::{ utils::Address, CasmContractClass, EntryPointType, }; -use std::{ - collections::HashSet, - sync::{Arc, RwLock}, -}; +use std::{collections::HashSet, sync::Arc}; lazy_static! { static ref TEST_ACCOUNT_COMPILED_CONTRACT_CLASS_HASH: Felt252 = felt_str!("1"); @@ -37,7 +34,7 @@ fn internal_deploy_account() { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); let contract_class = @@ -121,7 +118,7 @@ fn internal_deploy_account_cairo1() { let state_reader = Arc::new(InMemoryStateReader::default()); let mut state = CachedState::new( state_reader, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); #[cfg(not(feature = "cairo_1_tests"))] diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index 60655f1d0..d6252de69 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -78,7 +78,7 @@ fn integration_test() { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); //* ------------------------------------ @@ -180,7 +180,7 @@ fn integration_test_cairo1() { // Create state from the state_reader and contract cache. let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); // Create an execution entry point diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index 54ee5b5d2..6fa2b6d3e 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -20,11 +20,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, Address}, EntryPointType, }; -use std::{ - collections::HashSet, - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::{collections::HashSet, path::PathBuf, sync::Arc}; #[test] fn hello_starknet_increase_balance() { @@ -78,10 +74,7 @@ fn hello_starknet_increase_balance() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* ------------------------------------ //* Create execution entry point diff --git a/tests/internal_calls.rs b/tests/internal_calls.rs index 610736ae3..d86775e43 100644 --- a/tests/internal_calls.rs +++ b/tests/internal_calls.rs @@ -20,7 +20,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, Address, ClassHash}, EntryPointType, }; -use std::sync::{Arc, RwLock}; +use std::sync::Arc; #[test] fn test_internal_calls() { @@ -53,14 +53,14 @@ fn test_internal_calls() { let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new({ + Arc::new({ let cache = PermanentContractClassCache::default(); cache.set_contract_class( [0x01; 32], CompiledClass::Deprecated(Arc::new(contract_class)), ); cache - })), + }), ); let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"a")); diff --git a/tests/internals.rs b/tests/internals.rs index 4fd197d06..76d127c9a 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -54,7 +54,7 @@ use starknet_in_rust::{ }; use std::{ collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, + sync::Arc, }; const ACCOUNT_CONTRACT_PATH: &str = "starknet_programs/account_without_validation.json"; @@ -200,7 +200,7 @@ fn create_account_tx_test_state() -> Result< } Arc::new(state_reader) }, - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); Ok((block_context, cached_state)) @@ -211,7 +211,7 @@ fn expected_state_before_tx() -> CachedState>(), - (&*expected_initial_state - .contract_class_cache() - .read() - .unwrap()) + (&*expected_initial_state.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -887,13 +884,10 @@ fn test_declare_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - (&*state.contract_class_cache().read().unwrap()) + (&*state.contract_class_cache().clone()) .into_iter() .collect::>(), - (&*expected_initial_state - .contract_class_cache() - .read() - .unwrap()) + (&*expected_initial_state.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -978,13 +972,10 @@ fn test_declarev2_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - (&*state.contract_class_cache().read().unwrap()) + (&*state.contract_class_cache().clone()) .into_iter() .collect::>(), - (&*expected_initial_state - .contract_class_cache() - .read() - .unwrap()) + (&*expected_initial_state.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -1327,13 +1318,10 @@ fn test_invoke_tx_state() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - (&*state.contract_class_cache().read().unwrap()) + (&*state.contract_class_cache().clone()) .into_iter() .collect::>(), - (&*expected_initial_state - .contract_class_cache() - .read() - .unwrap()) + (&*expected_initial_state.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -1407,13 +1395,10 @@ fn test_invoke_with_declarev2_tx() { let expected_initial_state = expected_state_before_tx(); assert_eq!(&state.cache(), &expected_initial_state.cache()); assert_eq!( - (&*state.contract_class_cache().read().unwrap()) + (&*state.contract_class_cache().clone()) .into_iter() .collect::>(), - (&*expected_initial_state - .contract_class_cache() - .read() - .unwrap()) + (&*expected_initial_state.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -1512,10 +1497,10 @@ fn test_deploy_account() { assert_eq!(&state.cache(), &state_before.cache()); assert_eq!( - (&*state.contract_class_cache().read().unwrap()) + (&*state.contract_class_cache().clone()) .into_iter() .collect::>(), - (&*state_before.contract_class_cache().read().unwrap()) + (&*state_before.contract_class_cache().clone()) .into_iter() .collect::>() ); @@ -1641,7 +1626,7 @@ fn expected_deploy_account_states() -> ( ]), HashMap::new(), )), - Arc::new(RwLock::new(PermanentContractClassCache::default())), + Arc::new(PermanentContractClassCache::default()), ); state_before.set_storage_at( &( @@ -1655,8 +1640,7 @@ fn expected_deploy_account_states() -> ( // Make the contract cache independent (otherwise tests will fail because the initial state's // cache will not be empty anymore). - *state_after.contract_class_cache_mut() = - Arc::new(RwLock::new(PermanentContractClassCache::default())); + *state_after.contract_class_cache_mut() = Arc::new(PermanentContractClassCache::default()); state_after.cache_mut().nonce_initial_values_mut().insert( Address(felt_str!( diff --git a/tests/multi_syscall_test.rs b/tests/multi_syscall_test.rs index 97882a10c..bb2fa70eb 100644 --- a/tests/multi_syscall_test.rs +++ b/tests/multi_syscall_test.rs @@ -17,7 +17,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, Address, ClassHash}, EntryPointType, }; -use std::{sync::Arc, sync::RwLock, vec}; +use std::{sync::Arc, vec}; #[test] fn test_multiple_syscall() { @@ -43,10 +43,7 @@ fn test_multiple_syscall() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache.clone())), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [].to_vec(); diff --git a/tests/storage.rs b/tests/storage.rs index 29e9744b5..d5c02a2c1 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -18,11 +18,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, Address}, EntryPointType, }; -use std::{ - collections::HashSet, - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::{collections::HashSet, path::PathBuf, sync::Arc}; #[test] fn integration_storage_test() { @@ -75,10 +71,7 @@ fn integration_storage_test() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* ------------------------------------ //* Create execution entry point diff --git a/tests/syscalls.rs b/tests/syscalls.rs index f036d5ac4..29fdfaa9d 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -125,7 +125,7 @@ fn test_contract<'a>( }; let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); storage_entries .into_iter() @@ -1116,7 +1116,7 @@ fn deploy_cairo1_from_cairo0_with_constructor() { // Create state from the state_reader and contract cache. let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); // arguments of deploy contract @@ -1221,7 +1221,7 @@ fn deploy_cairo1_from_cairo0_without_constructor() { // Create state from the state_reader and contract cache. let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); // arguments of deploy contract @@ -1328,7 +1328,7 @@ fn deploy_cairo1_and_invoke() { // Create state from the state_reader and contract cache. let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); // arguments of deploy contract @@ -1471,7 +1471,7 @@ fn send_messages_to_l1_different_contract_calls() { // Create state from the state_reader and contract cache. let mut state = CachedState::new( Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), + Arc::new(contract_class_cache), ); // Create an execution entry point diff --git a/tests/syscalls_errors.rs b/tests/syscalls_errors.rs index e578ec94b..59f2d0157 100644 --- a/tests/syscalls_errors.rs +++ b/tests/syscalls_errors.rs @@ -21,10 +21,7 @@ use starknet_in_rust::{ utils::{calculate_sn_keccak, felt_to_hash, Address, ClassHash}, EntryPointType, }; -use std::{ - path::Path, - sync::{Arc, RwLock}, -}; +use std::{path::Path, sync::Arc}; #[allow(clippy::too_many_arguments)] fn test_contract<'a>( @@ -106,10 +103,7 @@ fn test_contract<'a>( contract_class_cache }; - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(RwLock::new(contract_class_cache)), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); storage_entries .into_iter() .for_each(|(a, b, c)| state.set_storage_at(&(a, b), c)); From 395f5de3cb6122678c7b558bb5a4c5302e89415c Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 13:11:09 +0200 Subject: [PATCH 16/56] Fix stuff. --- tests/fibonacci.rs | 16 +++------------- tests/syscalls.rs | 27 ++++++--------------------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index d6252de69..abad548d8 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -24,11 +24,7 @@ use starknet_in_rust::{ utils::{Address, ClassHash}, EntryPointType, }; -use std::{ - collections::HashMap, - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::{collections::HashMap, path::PathBuf, sync::Arc}; #[test] fn integration_test() { @@ -76,10 +72,7 @@ fn integration_test() { //* Create state with previous data //* --------------------------------------- - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); //* ------------------------------------ //* Create execution entry point @@ -178,10 +171,7 @@ fn integration_test_cairo1() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [0.into(), 1.into(), 12.into()].to_vec(); diff --git a/tests/syscalls.rs b/tests/syscalls.rs index 29fdfaa9d..6296ac462 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -36,7 +36,7 @@ use std::{ collections::{HashMap, HashSet}, iter::empty, path::{Path, PathBuf}, - sync::{Arc, RwLock}, + sync::Arc, }; #[allow(clippy::too_many_arguments)] @@ -123,10 +123,7 @@ fn test_contract<'a>( contract_class_cache }; - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); storage_entries .into_iter() .for_each(|(a, b, c)| state.set_storage_at(&(a, b), c)); @@ -1114,10 +1111,7 @@ fn deploy_cairo1_from_cairo0_with_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt, Felt252::one()].to_vec(); @@ -1219,10 +1213,7 @@ fn deploy_cairo1_from_cairo0_without_constructor() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1326,10 +1317,7 @@ fn deploy_cairo1_and_invoke() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // arguments of deploy contract let calldata: Vec<_> = [test_felt_hash, salt].to_vec(); @@ -1469,10 +1457,7 @@ fn send_messages_to_l1_different_contract_calls() { .insert(send_msg_address, send_msg_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new( - Arc::new(state_reader), - Arc::new(contract_class_cache), - ); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), 50.into(), 75.into()].to_vec(); From 3908f6f7d936225e7d035033b9e47ced700c5caf Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 13:51:50 +0200 Subject: [PATCH 17/56] Add LRU cache example. --- Cargo.lock | 12 +++- Cargo.toml | 1 + examples/contract_execution/main.rs | 5 +- examples/lru_cache/main.rs | 95 +++++++++++++++++++++++++++++ src/bin/deploy.rs | 6 +- src/bin/deploy_invoke.rs | 8 ++- src/testing/state.rs | 52 ++++++++++------ 7 files changed, 151 insertions(+), 28 deletions(-) create mode 100644 examples/lru_cache/main.rs diff --git a/Cargo.lock b/Cargo.lock index fbf90ed9e..e89653ae7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2450,6 +2450,15 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "lru" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eedb2bdbad7e0634f83989bf596f497b070130daaa398ab22d84c39e266deec5" +dependencies = [ + "hashbrown 0.14.0", +] + [[package]] name = "matrixmultiply" version = "0.2.4" @@ -2607,7 +2616,7 @@ checksum = "5f4e3bc495f6e95bc15a6c0c55ac00421504a5a43d09e3cc455d1fea7015581d" dependencies = [ "bitvec", "either", - "lru", + "lru 0.7.8", "num-bigint", "num-integer", "num-modular", @@ -3834,6 +3843,7 @@ dependencies = [ "hex", "keccak", "lazy_static", + "lru 0.11.0", "mimalloc", "num-bigint", "num-integer", diff --git a/Cargo.toml b/Cargo.toml index c4ef535b6..81b544bfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ serde_json_pythonic = { git = "https://github.com/xJonathanLEI/serde_json_python [dev-dependencies] assert_matches = "1.5.0" coverage-helper = "0.1.0" +lru = "0.11.0" [[bench]] path = "bench/internals.rs" diff --git a/examples/contract_execution/main.rs b/examples/contract_execution/main.rs index b735362d4..c3b793831 100644 --- a/examples/contract_execution/main.rs +++ b/examples/contract_execution/main.rs @@ -12,10 +12,11 @@ use cairo_vm::felt::Felt252; use starknet_in_rust::{ services::api::contract_classes::deprecated_contract_class::ContractClass, + state::contract_class_cache::PermanentContractClassCache, testing::state::StarknetState, utils::{calculate_sn_keccak, Address}, }; -use std::path::Path; +use std::{path::Path, sync::Arc}; fn main() { // replace this with the path to your compiled contract @@ -47,7 +48,7 @@ fn test_contract( //* -------------------------------------------- //* Initialize state //* -------------------------------------------- - let mut state = StarknetState::new(None); + let mut state = StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); //* -------------------------------------------- //* Read contract from file diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs new file mode 100644 index 000000000..6ab74baab --- /dev/null +++ b/examples/lru_cache/main.rs @@ -0,0 +1,95 @@ +#![deny(warnings)] + +use cairo_vm::felt::Felt252; +use lru::LruCache; +use starknet_in_rust::{ + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::contract_class_cache::ContractClassCache, + testing::state::StarknetState, + utils::{calculate_sn_keccak, Address, ClassHash}, +}; +use std::{ + num::NonZeroUsize, + path::Path, + sync::{Arc, Mutex}, +}; + +fn main() { + let shared_cache = Arc::new(LruContractCache::new()); + + let ret_data = run_contract( + "starknet_programs/factorial.json", + "factorial", + [1.into(), 1.into(), 10.into()], + shared_cache, + ); + + println!("{ret_data:?}"); +} + +fn run_contract( + contract_path: impl AsRef, + entry_point: impl AsRef, + calldata: impl Into>, + contract_cache: Arc, +) -> Vec +where + C: ContractClassCache, +{ + let mut state = StarknetState::new(None, contract_cache); + + let contract_class = ContractClass::from_path(contract_path.as_ref()).unwrap(); + state.declare(contract_class.clone()).unwrap(); + + let (contract_address, _) = state + .deploy(contract_class, vec![], Felt252::default(), None, 0) + .unwrap(); + + let entry_point_selector = + Felt252::from_bytes_be(&calculate_sn_keccak(entry_point.as_ref().as_bytes())); + let caller_address = Address::default(); + + let call_info = state + .execute_entry_point_raw( + contract_address, + entry_point_selector, + calldata.into(), + caller_address, + ) + .unwrap(); + + call_info.retdata +} + +struct LruContractCache { + storage: Mutex>, +} + +impl LruContractCache { + pub fn new() -> Self { + Self { + storage: Mutex::new(LruCache::new(NonZeroUsize::new(64).unwrap())), + } + } +} + +impl ContractClassCache for LruContractCache { + fn get_contract_class(&self, class_hash: ClassHash) -> Option { + self.storage.lock().unwrap().get(&class_hash).cloned() + } + + fn set_contract_class(&self, class_hash: ClassHash, compiled_class: CompiledClass) { + self.storage.lock().unwrap().put(class_hash, compiled_class); + } + + fn extend(&self, other: I) + where + I: IntoIterator, + { + other.into_iter().for_each(|(k, v)| { + self.storage.lock().unwrap().put(k, v); + }); + } +} diff --git a/src/bin/deploy.rs b/src/bin/deploy.rs index 1b58d386a..59bb8b5ca 100644 --- a/src/bin/deploy.rs +++ b/src/bin/deploy.rs @@ -1,11 +1,12 @@ use lazy_static::lazy_static; use starknet_in_rust::{ services::api::contract_classes::deprecated_contract_class::ContractClass, - testing::state::StarknetState, + state::contract_class_cache::PermanentContractClassCache, testing::state::StarknetState, }; #[cfg(feature = "with_mimalloc")] use mimalloc::MiMalloc; +use std::sync::Arc; #[cfg(feature = "with_mimalloc")] #[global_allocator] @@ -20,7 +21,8 @@ lazy_static! { fn main() { const RUNS: usize = 100; - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); for n in 0..RUNS { let contract_address_salt = n.into(); diff --git a/src/bin/deploy_invoke.rs b/src/bin/deploy_invoke.rs index 1036a6496..f698049d9 100644 --- a/src/bin/deploy_invoke.rs +++ b/src/bin/deploy_invoke.rs @@ -1,11 +1,12 @@ -use std::path::PathBuf; +use std::{path::PathBuf, sync::Arc}; use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; use starknet_in_rust::{ services::api::contract_classes::deprecated_contract_class::ContractClass, - testing::state::StarknetState, utils::Address, + state::contract_class_cache::PermanentContractClassCache, testing::state::StarknetState, + utils::Address, }; use lazy_static::lazy_static; @@ -36,7 +37,8 @@ lazy_static! { fn main() { const RUNS: usize = 10000; - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let contract_address_salt = 1.into(); let (contract_address, _exec_info) = starknet_state diff --git a/src/testing/state.rs b/src/testing/state.rs index 81c57147d..6fbcefbdc 100644 --- a/src/testing/state.rs +++ b/src/testing/state.rs @@ -14,7 +14,7 @@ use crate::{ }, state::{ cached_state::CachedState, - contract_class_cache::PermanentContractClassCache, + contract_class_cache::ContractClassCache, state_api::{State, StateReader}, }, state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, @@ -25,28 +25,30 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::{One, Zero}; -use std::collections::HashMap; -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; // --------------------------------------------------------------------- /// StarkNet testing object. Represents a state of a StarkNet network. -pub struct StarknetState { - pub state: CachedState, +pub struct StarknetState +where + C: ContractClassCache, +{ + pub state: CachedState, pub(crate) block_context: BlockContext, l2_to_l1_messages: HashMap, usize>, l2_to_l1_messages_log: Vec, events: Vec, } -impl StarknetState { - pub fn new(context: Option) -> Self { +impl StarknetState +where + C: ContractClassCache, +{ + pub fn new(context: Option, contract_cache: Arc) -> Self { let block_context = context.unwrap_or_default(); let state_reader = Arc::new(InMemoryStateReader::default()); - let state = CachedState::new( - state_reader, - Arc::new(PermanentContractClassCache::default()), - ); + let state = CachedState::new(state_reader, contract_cache); let l2_to_l1_messages = HashMap::new(); let l2_to_l1_messages_log = Vec::new(); @@ -63,7 +65,7 @@ impl StarknetState { pub fn new_with_states( block_context: Option, - state: CachedState, + state: CachedState, ) -> Self { let block_context = block_context.unwrap_or_default(); let l2_to_l1_messages = HashMap::new(); @@ -339,13 +341,17 @@ mod tests { execution::{CallType, OrderedL2ToL1Message}, hash_utils::calculate_contract_address, services::api::contract_classes::compiled_class::CompiledClass, - state::{contract_class_cache::ContractClassCache, state_cache::StorageEntry}, + state::{ + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + state_cache::StorageEntry, + }, utils::{calculate_sn_keccak, felt_to_hash}, }; #[test] fn test_deploy() { - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); @@ -460,7 +466,8 @@ mod tests { //* Create starknet state with previous data //* -------------------------------------------- - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); starknet_state.state = state; starknet_state @@ -531,7 +538,8 @@ mod tests { // 1) deploy fibonacci // 2) invoke call over fibonacci - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let contract_class = ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); let calldata = [1.into(), 1.into(), 10.into()].to_vec(); let contract_address_salt: Felt252 = 1.into(); @@ -621,7 +629,8 @@ mod tests { #[test] fn test_execute_entry_point_raw() { - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let path = PathBuf::from("starknet_programs/fibonacci.json"); let contract_class = ContractClass::from_path(path).unwrap(); let contract_address_salt = 1.into(); @@ -646,7 +655,8 @@ mod tests { #[test] fn test_add_messages_and_events() { - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let test_msg_1 = OrderedL2ToL1Message { order: 0, to_address: Address(0.into()), @@ -676,7 +686,8 @@ mod tests { #[test] fn test_consume_message_hash() { - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let test_msg_1 = OrderedL2ToL1Message { order: 0, to_address: Address(0.into()), @@ -709,7 +720,8 @@ mod tests { #[test] fn test_consume_message_hash_twice_should_fail() { - let mut starknet_state = StarknetState::new(None); + let mut starknet_state = + StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); let test_msg = OrderedL2ToL1Message { order: 0, to_address: Address(0.into()), From 73957f4d812e09344e01576936f1268a15aaf421 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 13:53:23 +0200 Subject: [PATCH 18/56] Run `cargo fmt`. --- src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3f5497d38..5341afc4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -392,12 +392,10 @@ mod test { ); // Initialize state.contract_classes - state - .contract_class_cache() - .set_contract_class( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - ); + state.contract_class_cache().set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); let mut block_context = BlockContext::default(); block_context.starknet_os_config.gas_price = 1; From 5425ca9f24fb6803630295d15b3281d5791e9fe8 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 17:20:24 +0200 Subject: [PATCH 19/56] Fix LRU example. --- examples/lru_cache/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index 6ab74baab..15d1a28b2 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -22,7 +22,7 @@ fn main() { let ret_data = run_contract( "starknet_programs/factorial.json", "factorial", - [1.into(), 1.into(), 10.into()], + [10.into()], shared_cache, ); From 9127d275a05ab42f5be40d41f81cca9f2c9dc8d2 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 31 Aug 2023 17:22:38 +0200 Subject: [PATCH 20/56] Fix the other example. --- examples/contract_execution/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/contract_execution/main.rs b/examples/contract_execution/main.rs index c3b793831..ff4375b64 100644 --- a/examples/contract_execution/main.rs +++ b/examples/contract_execution/main.rs @@ -26,7 +26,7 @@ fn main() { let entry_point: &str = "factorial"; // replace this with the arguments for the entrypoint - let calldata: Vec = [1.into(), 1.into(), 10.into()].to_vec(); + let calldata: Vec = [10.into()].to_vec(); let retdata = test_contract(contract_path, entry_point, calldata); From adf5672a4ef81ba9d2991a4241b7c0acb831df6c Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 6 Sep 2023 19:24:59 +0200 Subject: [PATCH 21/56] Fix after merge. --- rpc_state_reader_sn_api/src/lib.rs | 10 ++++------ .../deprecated_business_logic_syscall_handler.rs | 5 ++++- src/transaction/invoke_function.rs | 2 +- tests/complex_contracts/amm_contracts/amm_proxy.rs | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/rpc_state_reader_sn_api/src/lib.rs b/rpc_state_reader_sn_api/src/lib.rs index 61393d32a..505feb6f9 100644 --- a/rpc_state_reader_sn_api/src/lib.rs +++ b/rpc_state_reader_sn_api/src/lib.rs @@ -1062,10 +1062,8 @@ mod starknet_in_rust_transaction_tests { execution::TransactionExecutionInfo, services::api::contract_classes::compiled_class::CompiledClass, state::{ - cached_state::{CachedState, ContractClassCache}, - state_api::StateReader, - state_cache::StorageEntry, - BlockInfo, + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + state_api::StateReader, state_cache::StorageEntry, BlockInfo, }, transaction::{InvokeFunction, Transaction}, utils::{Address, ClassHash}, @@ -1187,8 +1185,8 @@ mod starknet_in_rust_transaction_tests { let trace = rpc_reader.0.get_transaction_trace(&tx_hash); let receipt = rpc_reader.0.get_transaction_receipt(&tx_hash); - let class_cache = ContractClassCache::default(); - let mut state = CachedState::new(Arc::new(rpc_reader), class_cache); + let class_cache = PermanentContractClassCache::default(); + let mut state = CachedState::new(Arc::new(rpc_reader), Arc::new(class_cache)); let block_context = BlockContext::new( starknet_os_config, diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 4038fa206..734752bdc 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -1062,7 +1062,10 @@ mod tests { Felt252::zero(), ); // Create empty-cached state - let mut state = CachedState::new(Arc::new(state_reader), HashMap::new()); + let mut state = CachedState::new( + Arc::new(state_reader), + Arc::new(PermanentContractClassCache::default()), + ); let mut syscall_handler = DeprecatedBLSyscallHandler::default_with(&mut state); // Perform write assert!(syscall_handler diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index b434aa808..98350a27d 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -24,7 +24,7 @@ use crate::{ }; use cairo_vm::felt::Felt252; use getset::Getters; -use num_traits::{One, Zero}; +use num_traits::Zero; /// Represents an InvokeFunction transaction in the starknet network. #[derive(Debug, Getters, Clone)] diff --git a/tests/complex_contracts/amm_contracts/amm_proxy.rs b/tests/complex_contracts/amm_contracts/amm_proxy.rs index ef172d002..df8978826 100644 --- a/tests/complex_contracts/amm_contracts/amm_proxy.rs +++ b/tests/complex_contracts/amm_contracts/amm_proxy.rs @@ -1,5 +1,6 @@ use crate::complex_contracts::utils::*; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; +use num_traits::Zero; use starknet_crypto::FieldElement; use starknet_in_rust::{ definitions::block_context::BlockContext, From 7071a031b58626b90245e82781bab7333dd956ed Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 6 Sep 2023 20:31:07 +0200 Subject: [PATCH 22/56] Add private cache drain method. --- src/state/cached_state.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index b36713c44..2f66d3241 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -60,6 +60,12 @@ impl CachedState { contract_class_cache_private: RefCell::new(HashMap::new()), } } + + pub fn drain_private_contract_class_cache( + &self, + ) -> impl Iterator { + self.contract_class_cache_private.take().into_iter() + } } impl StateReader for CachedState { From e6933164709800dde5dbf9a2b12b1ecfcc125504 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 6 Sep 2023 20:35:36 +0200 Subject: [PATCH 23/56] Temporarily disable `max_fee` checks. --- src/transaction/verify_version.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/transaction/verify_version.rs b/src/transaction/verify_version.rs index 8787b09b9..490d20dd1 100644 --- a/src/transaction/verify_version.rs +++ b/src/transaction/verify_version.rs @@ -6,7 +6,7 @@ use super::error::TransactionError; pub fn verify_version( version: &Felt252, - max_fee: u128, + _max_fee: u128, nonce: &Felt252, signature: &Vec, ) -> Result<(), TransactionError> { @@ -15,9 +15,9 @@ pub fn verify_version( } if *version == 0.into() || *version == *QUERY_VERSION_BASE { - if max_fee != 0 { - return Err(TransactionError::InvalidMaxFee); - } + // if max_fee != 0 { + // return Err(TransactionError::InvalidMaxFee); + // } if nonce != &0.into() { return Err(TransactionError::InvalidNonce); } From c76073dce6a2cb97b335abbc7edeb76f7c2be683 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 7 Sep 2023 15:41:43 +0200 Subject: [PATCH 24/56] Add comment on `RefCell::get_mut()`. --- src/state/cached_state.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 2f66d3241..b00baba43 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -181,6 +181,8 @@ impl State for CachedState { class_hash: &ClassHash, contract_class: &CompiledClass, ) -> Result<(), StateError> { + // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when we + // have a mutable reference to the `RefCell` available. self.contract_class_cache_private .get_mut() .insert(*class_hash, contract_class.clone()); From b14c0bb50259ef2f470e19d45def7ce7f9026195 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 7 Sep 2023 17:11:13 +0200 Subject: [PATCH 25/56] Remove `extend` from trait. Remove unused code. --- examples/lru_cache/main.rs | 26 ++++++------- src/state/contract_class_cache.rs | 63 +++++-------------------------- 2 files changed, 22 insertions(+), 67 deletions(-) diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index 15d1a28b2..5c6768d53 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -17,7 +17,7 @@ use std::{ }; fn main() { - let shared_cache = Arc::new(LruContractCache::new()); + let shared_cache = Arc::new(LruContractCache::new(NonZeroUsize::new(64).unwrap())); let ret_data = run_contract( "starknet_programs/factorial.json", @@ -63,16 +63,25 @@ where call_info.retdata } -struct LruContractCache { +pub struct LruContractCache { storage: Mutex>, } impl LruContractCache { - pub fn new() -> Self { + pub fn new(cap: NonZeroUsize) -> Self { Self { - storage: Mutex::new(LruCache::new(NonZeroUsize::new(64).unwrap())), + storage: Mutex::new(LruCache::new(cap)), } } + + pub fn extend(&self, other: I) + where + I: IntoIterator, + { + other.into_iter().for_each(|(k, v)| { + self.storage.lock().unwrap().put(k, v); + }); + } } impl ContractClassCache for LruContractCache { @@ -83,13 +92,4 @@ impl ContractClassCache for LruContractCache { fn set_contract_class(&self, class_hash: ClassHash, compiled_class: CompiledClass) { self.storage.lock().unwrap().put(class_hash, compiled_class); } - - fn extend(&self, other: I) - where - I: IntoIterator, - { - other.into_iter().for_each(|(k, v)| { - self.storage.lock().unwrap().put(k, v); - }); - } } diff --git a/src/state/contract_class_cache.rs b/src/state/contract_class_cache.rs index ddbd3bfd2..6645af100 100644 --- a/src/state/contract_class_cache.rs +++ b/src/state/contract_class_cache.rs @@ -22,48 +22,8 @@ pub trait ContractClassCache { fn get_contract_class(&self, class_hash: ClassHash) -> Option; /// Inserts or replaces a contract class associated with a specific class hash. fn set_contract_class(&self, class_hash: ClassHash, compiled_class: CompiledClass); - - /// Performs a bulk insert of contract classes from an iterator over pairs of the class hash and - /// its contract class. - fn extend(&self, other: I) - where - I: IntoIterator; } -// pub(crate) fn merge_caches( -// shared: &RwLock>, -// mut private: HashMap, -// ) { -// // FIXME: Parallel invocation of `merge_caches()` may cause data loss. Example: -// // - Thread A: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. -// // - Thread B: Invokes `merge_caches()`. Starts copying data from `shared` into its `private`. -// // - Thread A: Updates the shared cache. It now contains A's specific entries. -// // - Thread B: Updates the shared cache. It now contains only B's specific entries, since it -// // lost A's ones. - -// // Extend private to contain all of shared's entries. Using a readonly lock will avoid blocking -// // the other potential cache readers. -// { -// let shared_lock = shared.read().unwrap(); -// private.extend(shared_lock.iter().map(|(k, v)| (*k, v.clone()))); -// } - -// // Swap the active cache to apply the changes. This will delay `private`'s destructor, which -// // will run after the write lock has been dropped. -// { -// let mut shared_lock = shared.write().unwrap(); -// mem::swap(&mut *shared_lock, &mut private); -// } -// } - -// pub(crate) fn take_cache(state: CachedState) -> HashMap -// where -// T: StateReader, -// C: ContractClassCache, -// { -// state.contract_class_cache_private -// } - /// A contract class cache which stores nothing. In other words, using this as a cache means there's /// effectively no cache. #[derive(Clone, Copy, Debug, Default, Hash)] @@ -77,13 +37,6 @@ impl ContractClassCache for NullContractClassCache { fn set_contract_class(&self, _class_hash: ClassHash, _compiled_class: CompiledClass) { // Nothing needs to be done here. } - - fn extend(&self, _other: I) - where - I: IntoIterator, - { - // Nothing needs to be done here. - } } /// A contract class cache which stores everything. This cache is useful for testing but will @@ -93,6 +46,15 @@ pub struct PermanentContractClassCache { storage: RwLock>, } +impl PermanentContractClassCache { + pub fn extend(&self, other: I) + where + I: IntoIterator, + { + self.storage.write().unwrap().extend(other); + } +} + impl ContractClassCache for PermanentContractClassCache { fn get_contract_class(&self, class_hash: ClassHash) -> Option { self.storage.read().unwrap().get(&class_hash).cloned() @@ -104,13 +66,6 @@ impl ContractClassCache for PermanentContractClassCache { .unwrap() .insert(class_hash, compiled_class); } - - fn extend(&self, other: I) - where - I: IntoIterator, - { - self.storage.write().unwrap().extend(other); - } } impl Clone for PermanentContractClassCache { From ec6e516ee98b310490381efd663121569dd24c19 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Fri, 8 Sep 2023 12:44:07 +0200 Subject: [PATCH 26/56] Fix duplicated `CachedState` issue. --- src/lib.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3b56e386a..a5fefda9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,17 +172,13 @@ pub fn call_contract( /// Estimate the fee associated with L1Handler pub fn estimate_message_fee( l1_handler: &L1Handler, - state: T, - contract_class_cache: Arc, + mut cached_state: CachedState, block_context: &BlockContext, ) -> Result<(u128, usize), TransactionError> where T: StateReader, C: ContractClassCache, { - // This is used as a copy of the original state, we can update this cached state freely. - let mut cached_state = CachedState::::new(Arc::new(state), contract_class_cache); - // Check if the contract is deployed. cached_state.get_class_hash_at(l1_handler.contract_address())?; @@ -400,13 +396,7 @@ mod test { let mut block_context = BlockContext::default(); block_context.starknet_os_config.gas_price = 1; - let estimated_fee = estimate_message_fee( - &l1_handler, - state.clone(), - state.contract_class_cache().clone(), - &block_context, - ) - .unwrap(); + let estimated_fee = estimate_message_fee(&l1_handler, state, &block_context).unwrap(); assert_eq!(estimated_fee, (19709, 19695)); } From 0b13b4950ba6190726deb3b93a01189c3b43dd77 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Fri, 8 Sep 2023 14:34:29 +0200 Subject: [PATCH 27/56] Add missing comments. --- src/state/cached_state.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index b00baba43..99a6b29f9 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -396,6 +396,8 @@ impl State for CachedState { // I: FETCHING FROM CACHE // deprecated contract classes dont have compiled class hashes, so we only have one case + // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when we + // have a mutable reference to the `RefCell` available. if let Some(compiled_class) = self.contract_class_cache_private.get_mut().get(class_hash) { return Ok(compiled_class.clone()); } else if let Some(compiled_class) = @@ -411,6 +413,8 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { + // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when + // we have a mutable reference to the `RefCell` available. if let Some(casm_class) = self .contract_class_cache_private .get_mut() From abd8bcb2f815a600816568194fd3409116b67f8e Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Fri, 8 Sep 2023 17:07:08 +0200 Subject: [PATCH 28/56] Update `README.md`. --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b754db81..2a02f7e98 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ It makes use of [cairo-vm](https://github.com/lambdaclass/cairo-vm), the Rust im ### Dependencies - Rust 1.70 - A working installation of cairo-lang 0.12 (for compiling the cairo files) -- [Optional, for testing purposes] Heaptrack +- [Optional, for testing purposes] Heaptrack ### Installation @@ -109,6 +109,26 @@ You can find a tutorial on running contracts [here](/examples/contract_execution ### Using the CLI You can find an example on how to use the CLI [here](/docs/CLI_USAGE_EXAMPLE.md) + +### Customization + +#### Contract class cache behavior + +`starknet_in_rust` supports caching contracts in memory. The project provides two builtin cache +policies: null and permanent. The null cache behaves as if there was no cache at all. The permanent +cache caches everything in memory forever. + +```rs +// To use the null cache (aka. no cache at all), create the state as follows: +let state = StarknetState::new(None, Arc::new(NullContractClassCache::default())); + +// If the permanent cache is preferred, then use `PermanentContractClassCache` instead: +let state = StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); +``` + +Custom cache policies are also supported by implementing a single trait. An example may be found +[here](examples/lru_cache/main.rs). + ### Testing [Add an Infura API key.](#rpc-state-reader) @@ -138,7 +158,7 @@ $ make benchmark ## 🛠 Contributing -The open source community is a fantastic place for learning, inspiration, and creation, and this is all thanks to contributions from people like you. Your contributions are **greatly appreciated**. +The open source community is a fantastic place for learning, inspiration, and creation, and this is all thanks to contributions from people like you. Your contributions are **greatly appreciated**. If you have any suggestions for how to improve the project, please feel free to fork the repo and create a pull request, or [open an issue](https://github.com/lambdaclass/starknet_in_rust/issues/new?labels=enhancement&title=feat%3A+) with the tag 'enhancement'. From 35b52397f290b6f557732e922036ecdda0959a25 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 12 Sep 2023 12:42:41 +0200 Subject: [PATCH 29/56] Fix after merge. --- src/lib.rs | 1 - src/state/cached_state.rs | 25 ++++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 10042506d..7e122ccf8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -212,7 +212,6 @@ mod test { EXECUTE_ENTRY_POINT_SELECTOR, INITIAL_GAS_COST, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, VALIDATE_ENTRY_POINT_SELECTOR, }, - transaction_type::TransactionType, }, estimate_fee, estimate_message_fee, hash_utils::calculate_contract_address, diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 7490b2e5d..4b76fdabb 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -33,12 +33,15 @@ pub struct CachedState { #[getset(get = "pub", get_mut = "pub")] pub(crate) contract_class_cache: Arc, pub(crate) contract_class_cache_private: RefCell>, + + #[cfg(feature = "metrics")] cache_hits: usize, + #[cfg(feature = "metrics")] cache_misses: usize, } #[cfg(feature = "metrics")] -impl CachedState { +impl CachedState { #[inline(always)] pub fn add_hit(&mut self) { self.cache_hits += 1; @@ -51,7 +54,7 @@ impl CachedState { } #[cfg(not(feature = "metrics"))] -impl CachedState { +impl CachedState { #[inline(always)] pub fn add_hit(&mut self) { // does nothing @@ -71,7 +74,10 @@ impl CachedState { state_reader, contract_class_cache: contract_classes, contract_class_cache_private: RefCell::new(HashMap::new()), + + #[cfg(feature = "metrics")] cache_hits: 0, + #[cfg(feature = "metrics")] cache_misses: 0, } } @@ -87,7 +93,10 @@ impl CachedState { state_reader, contract_class_cache: contract_classes, contract_class_cache_private: RefCell::new(HashMap::new()), + + #[cfg(feature = "metrics")] cache_hits: 0, + #[cfg(feature = "metrics")] cache_misses: 0, } } @@ -433,9 +442,14 @@ impl State for CachedState { // deprecated contract classes dont have compiled class hashes, so we only have one case // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when we // have a mutable reference to the `RefCell` available. - if let Some(compiled_class) = self.contract_class_cache_private.get_mut().get(class_hash) { + if let Some(compiled_class) = self + .contract_class_cache_private + .get_mut() + .get(class_hash) + .cloned() + { self.add_hit(); - return Ok(compiled_class.clone()); + return Ok(compiled_class); } else if let Some(compiled_class) = self.contract_class_cache().get_contract_class(*class_hash) { @@ -456,9 +470,10 @@ impl State for CachedState { .contract_class_cache_private .get_mut() .get(compiled_class_hash) + .cloned() { self.add_hit(); - return Ok(casm_class.clone()); + return Ok(casm_class); } else if let Some(casm_class) = self .contract_class_cache() .get_contract_class(*compiled_class_hash) From fcb114bd92beddcd2d8266f2a96ffa682de80ce0 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 12 Sep 2023 13:18:52 +0200 Subject: [PATCH 30/56] Remove obsolete comment. --- src/state/contract_class_cache.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/state/contract_class_cache.rs b/src/state/contract_class_cache.rs index 6645af100..d7269ce00 100644 --- a/src/state/contract_class_cache.rs +++ b/src/state/contract_class_cache.rs @@ -6,11 +6,6 @@ //! The trait `ContractClassCache` provides methods for retrieving and inserting elements into the //! cache. It also contains a method to extend the shared cache from an iterator so that it can be //! used with the private caches. -//! -//! TODO: Right now, it's impossible to implement the issue's `merge_caches` because -//! `ContractClassCache::extend` will be called already with the write lock in place. To solve -//! this, the lock may be pushed into the cache, but the methods will not be able to have -//! `&mut self` as the object. use crate::{services::api::contract_classes::compiled_class::CompiledClass, utils::ClassHash}; use std::{collections::HashMap, sync::RwLock}; From 204ff7450ccd68dcc98b95c7366412ee643e711a Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 12 Sep 2023 13:19:03 +0200 Subject: [PATCH 31/56] Fix test after merge. --- src/state/cached_state.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 4b76fdabb..0fe43dfa3 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -901,12 +901,15 @@ mod tests { #[test] fn test_cache_hit_miss_counter() { let state_reader = Arc::new(InMemoryStateReader::default()); - let mut cached_state = CachedState::new(state_reader, None, None); + let mut cached_state = CachedState::new( + state_reader, + Arc::new(PermanentContractClassCache::default()), + ); let address = Address(1.into()); // Simulate a cache miss by querying an address not in the cache. - let _ = as State>::get_class_hash_at(&mut cached_state, &address); + let _ = as State>::get_class_hash_at(&mut cached_state, &address); assert_eq!(cached_state.cache_misses, 1); assert_eq!(cached_state.cache_hits, 0); @@ -915,18 +918,18 @@ mod tests { .cache .class_hash_writes .insert(address.clone(), [0; 32]); - let _ = as State>::get_class_hash_at(&mut cached_state, &address); + let _ = as State>::get_class_hash_at(&mut cached_state, &address); assert_eq!(cached_state.cache_misses, 1); assert_eq!(cached_state.cache_hits, 1); // Simulate another cache hit. - let _ = as State>::get_class_hash_at(&mut cached_state, &address); + let _ = as State>::get_class_hash_at(&mut cached_state, &address); assert_eq!(cached_state.cache_misses, 1); assert_eq!(cached_state.cache_hits, 2); // Simulate another cache miss. let other_address = Address(2.into()); - let _ = as State>::get_class_hash_at(&mut cached_state, &other_address); + let _ = as State>::get_class_hash_at(&mut cached_state, &other_address); assert_eq!(cached_state.cache_misses, 2); assert_eq!(cached_state.cache_hits, 2); } From dd282e79c1978b3f98071832566a99ac3f593dcf Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 12 Sep 2023 13:25:39 +0200 Subject: [PATCH 32/56] Fix borrows. --- src/state/cached_state.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 0fe43dfa3..b4a7aaa36 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -179,25 +179,22 @@ impl StateReader for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self - .contract_class_cache_private - .borrow() - .get(compiled_class_hash) - { + if let Some(casm_class) = private_cache.get(compiled_class_hash) { return Ok(casm_class.clone()); } else if let Some(casm_class) = self .contract_class_cache() .get_contract_class(*compiled_class_hash) { - self.contract_class_cache_private - .borrow_mut() - .insert(*class_hash, casm_class.clone()); + private_cache.insert(*class_hash, casm_class.clone()); return Ok(casm_class); } } // II: FETCHING FROM STATE_READER - self.state_reader.get_contract_class(class_hash) + let contract_class = self.state_reader.get_contract_class(class_hash)?; + private_cache.insert(*class_hash, contract_class.clone()); + + Ok(contract_class) } } From eae0b0c49ac8a4653ba631a5a5e0fc86ca024e6d Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Thu, 14 Sep 2023 13:15:34 +0200 Subject: [PATCH 33/56] Fix after merge. --- src/testing/erc20.rs | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/src/testing/erc20.rs b/src/testing/erc20.rs index a7af52a71..209932391 100644 --- a/src/testing/erc20.rs +++ b/src/testing/erc20.rs @@ -1,50 +1,31 @@ -#![allow(unused_imports)] -use std::{ - collections::HashMap, - io::Bytes, - path::Path, - sync::{Arc, RwLock}, -}; +// Since it has nothing exported, restrict compilation on test mode only. Fixes unused import +// warnings without disabling them. +#![cfg(test)] use crate::{ call_contract, - definitions::{ - block_context::{BlockContext, StarknetChainId}, - constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR, - }, + definitions::block_context::{BlockContext, StarknetChainId}, execution::{ execution_entry_point::ExecutionEntryPoint, CallType, TransactionExecutionContext, }, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, + services::api::contract_classes::compiled_class::CompiledClass, state::{ cached_state::CachedState, contract_class_cache::{ContractClassCache, PermanentContractClassCache}, in_memory_state_reader::InMemoryStateReader, - state_api::{State, StateReader}, + state_api::State, ExecutionResourcesManager, }, - transaction::{error::TransactionError, DeployAccount, InvokeFunction}, - utils::calculate_sn_keccak, - EntryPointType, Felt252, + transaction::DeployAccount, + utils::{calculate_sn_keccak, Address, ClassHash}, + EntryPointType, }; use cairo_lang_starknet::casm_contract_class::CasmContractClass; -use cairo_vm::felt::felt_str; -use lazy_static::lazy_static; +use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; -pub const ERC20_CONTRACT_PATH: &str = "starknet_programs/cairo2/ERC20.casm"; -use crate::{ - state::state_cache::StorageEntry, - utils::{felt_to_hash, Address, ClassHash}, -}; +use std::sync::Arc; -use super::{ - new_starknet_block_context_for_testing, ACCOUNT_CONTRACT_PATH, ACTUAL_FEE, - TEST_ACCOUNT_CONTRACT_ADDRESS, TEST_ACCOUNT_CONTRACT_CLASS_HASH, TEST_CLASS_HASH, - TEST_CONTRACT_ADDRESS, TEST_CONTRACT_PATH, TEST_ERC20_ACCOUNT_BALANCE_KEY, - TEST_ERC20_CONTRACT_CLASS_HASH, -}; +pub const ERC20_CONTRACT_PATH: &str = "starknet_programs/cairo2/ERC20.casm"; #[test] fn test_erc20_cairo2() { From 3c64761a1856c24b19079488622f2565afae2ff2 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Mon, 18 Sep 2023 15:08:51 +0200 Subject: [PATCH 34/56] Fix erc20 test. --- src/state/cached_state.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 5b2511cc9..c453e1a96 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -115,7 +115,9 @@ impl CachedState { state_reader, cache: self.cache.clone(), contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RefCell::new(HashMap::default()), + contract_class_cache_private: RefCell::new( + self.contract_class_cache_private.borrow().clone(), + ), #[cfg(feature = "metrics")] cache_hits: 0, #[cfg(feature = "metrics")] From 0a6dee18e22e9c636a118ed81e638a2295299098 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Mon, 18 Sep 2023 15:30:59 +0200 Subject: [PATCH 35/56] Remove unused feature. --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c90143e25..82e6a7ef1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![deny(warnings)] #![forbid(unsafe_code)] -#![cfg_attr(coverage_nightly, feature(no_coverage))] use crate::{ definitions::block_context::BlockContext, From 8f6439108517e051d51522db24fb602f6ef11d0e Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Mon, 18 Sep 2023 15:36:18 +0200 Subject: [PATCH 36/56] Update `coverage-helper` to support `#[coverage(off)]`. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- cli/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aefa0adc6..52d724a00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1426,9 +1426,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "coverage-helper" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9db510e477cf3c14a6c56aa2ed28e499f1e27e01c17723b41ece793d11cf3fe" +checksum = "3036399e8abfc9d696c1ee94f7677f9704e903d96299b0026e339eed6055dcaf" [[package]] name = "cpufeatures" diff --git a/Cargo.toml b/Cargo.toml index 4546168c0..ccb77a306 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ serde_json_pythonic = "0.1.2" [dev-dependencies] assert_matches = "1.5.0" -coverage-helper = "0.1.0" +coverage-helper = "0.2.0" lru = "0.11.0" pretty_assertions_sorted = "1.2.3" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index cd1114021..221de3cb5 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -19,4 +19,4 @@ mimalloc = { version = "0.1.29", default-features = false, optional = true } [dev-dependencies] assert_matches = "1.5.0" -coverage-helper = "0.1.0" +coverage-helper = "0.2.0" From 6694d01994e7b6af9cf0a3efba2736e342427a7a Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Mon, 18 Sep 2023 15:37:01 +0200 Subject: [PATCH 37/56] Add `coverage` attribute feature on testing. --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 82e6a7ef1..1defd28a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![deny(warnings)] #![forbid(unsafe_code)] +#![cfg_attr(coverage_nightly, feature(coverage_attribute))] use crate::{ definitions::block_context::BlockContext, From 5941f497eca00f6900732ed929eb9cba234d7c1f Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 19 Sep 2023 13:02:21 +0200 Subject: [PATCH 38/56] Update `README.md` and example. --- README.md | 26 ++++++++++++++++++-------- examples/lru_cache/main.rs | 15 ++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2a02f7e98..f8d7b4a76 100644 --- a/README.md +++ b/README.md @@ -114,21 +114,31 @@ You can find an example on how to use the CLI [here](/docs/CLI_USAGE_EXAMPLE.md) #### Contract class cache behavior -`starknet_in_rust` supports caching contracts in memory. The project provides two builtin cache -policies: null and permanent. The null cache behaves as if there was no cache at all. The permanent -cache caches everything in memory forever. +`starknet_in_rust` supports caching contracts in memory. Caching the contracts is useful for +avoiding excessive RPC API usage. The project provides two builtin cache policies: null andç +permanent. The null cache behaves as if there was no cache at all. The permanent cache caches +everything in memory forever. + +In addition to those two, an example is provided that implements and uses an LRU cache policy. +Long-running applications should ideally implement a cache algorithm suited to their needs or +alternatively use our example's implementation to avoid spamming the API when using the null cache +or blowing the memory usage when running with the permanent cache. + +Customized cache policies may be used by implementing the `ContractClassCache` trait. Check out our +[LRU cache example](examples/lru_cache/main.rs) for more details. ```rs // To use the null cache (aka. no cache at all), create the state as follows: -let state = StarknetState::new(None, Arc::new(NullContractClassCache::default())); +let cache = Arc::new(NullContractClassCache::default()); +let state1 = StarknetState::new(None, cache.clone()); +let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. // If the permanent cache is preferred, then use `PermanentContractClassCache` instead: -let state = StarknetState::new(None, Arc::new(PermanentContractClassCache::default())); +let cache = Arc::new(PermanentContractClassCache::default()); +let state1 = StarknetState::new(None, cache.clone()); +let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. ``` -Custom cache policies are also supported by implementing a single trait. An example may be found -[here](examples/lru_cache/main.rs). - ### Testing [Add an Infura API key.](#rpc-state-reader) diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index 5c6768d53..e7e75b892 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -29,16 +29,13 @@ fn main() { println!("{ret_data:?}"); } -fn run_contract( +fn run_contract( contract_path: impl AsRef, entry_point: impl AsRef, calldata: impl Into>, - contract_cache: Arc, -) -> Vec -where - C: ContractClassCache, -{ - let mut state = StarknetState::new(None, contract_cache); + contract_cache: Arc, +) -> Vec { + let mut state = StarknetState::new(None, contract_cache.clone()); let contract_class = ContractClass::from_path(contract_path.as_ref()).unwrap(); state.declare(contract_class.clone()).unwrap(); @@ -60,6 +57,10 @@ where ) .unwrap(); + // Store the local cache changes into the shared cache. This updates the shared cache with all + // the contracts used on this state. + contract_cache.extend(state.state.drain_private_contract_class_cache()); + call_info.retdata } From 13150c8cd0fa660657251d9c262b08ab96a454b7 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 19 Sep 2023 13:20:15 +0200 Subject: [PATCH 39/56] Fix `README.md`. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f8d7b4a76..abc883da3 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,9 @@ You can find an example on how to use the CLI [here](/docs/CLI_USAGE_EXAMPLE.md) #### Contract class cache behavior `starknet_in_rust` supports caching contracts in memory. Caching the contracts is useful for -avoiding excessive RPC API usage. The project provides two builtin cache policies: null andç -permanent. The null cache behaves as if there was no cache at all. The permanent cache caches -everything in memory forever. +avoiding excessive RPC API usage and keeping the contract class deserialization overhead to the +minimum. The project provides two builtin cache policies: null and permanent. The null cache behaves +as if there was no cache at all. The permanent cache caches everything in memory forever. In addition to those two, an example is provided that implements and uses an LRU cache policy. Long-running applications should ideally implement a cache algorithm suited to their needs or From dab48c22df6951b7b5c782f70c17bf093f1cf731 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 19 Sep 2023 18:45:54 +0200 Subject: [PATCH 40/56] Improve `README.md`. --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index abc883da3..5d2fff04c 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,9 @@ alternatively use our example's implementation to avoid spamming the API when us or blowing the memory usage when running with the permanent cache. Customized cache policies may be used by implementing the `ContractClassCache` trait. Check out our -[LRU cache example](examples/lru_cache/main.rs) for more details. +[LRU cache example](examples/lru_cache/main.rs) for more details. Updating the cache requires +manually merging the local state cache into the shared cache manually. This can be done by calling +the `drain_private_contract_class_cache` on the `CachedState` instance. ```rs // To use the null cache (aka. no cache at all), create the state as follows: @@ -133,10 +135,22 @@ let cache = Arc::new(NullContractClassCache::default()); let state1 = StarknetState::new(None, cache.clone()); let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. +// Insert state usage here. + +// The null cache doesn't have any method to extend it since it has no data. +``` + +```rs // If the permanent cache is preferred, then use `PermanentContractClassCache` instead: let cache = Arc::new(PermanentContractClassCache::default()); let state1 = StarknetState::new(None, cache.clone()); let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. + +// Insert state usage here. + +// Extend the shared cache with the states' contracts after using them. +cache.extend(state1.state.drain_private_contract_class_cache()); +cache.extend(state2.state.drain_private_contract_class_cache()); ``` ### Testing From a30fbb2ae4cd055e8814c2260edb5225db78a4c3 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 19 Sep 2023 18:55:05 +0200 Subject: [PATCH 41/56] Remove references to `StarknetState` in `README.md`. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5d2fff04c..b90b9f1e5 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,8 @@ the `drain_private_contract_class_cache` on the `CachedState` instance. ```rs // To use the null cache (aka. no cache at all), create the state as follows: let cache = Arc::new(NullContractClassCache::default()); -let state1 = StarknetState::new(None, cache.clone()); -let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. +let state1 = CachedState::new(state_reader.clone(), cache.clone()); +let state2 = CachedState::new(state_reader.clone(), cache.clone()); // Cache is reused. // Insert state usage here. @@ -143,8 +143,8 @@ let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. ```rs // If the permanent cache is preferred, then use `PermanentContractClassCache` instead: let cache = Arc::new(PermanentContractClassCache::default()); -let state1 = StarknetState::new(None, cache.clone()); -let state2 = StarknetState::new(None, cache.clone()); // Cache is reused. +let state1 = CachedState::new(state_reader.clone(), cache.clone()); +let state2 = CachedState::new(state_reader.clone(), cache.clone()); // Cache is reused. // Insert state usage here. From f6b550b7798cd8342cfc74307140b36e7b2972ab Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Tue, 19 Sep 2023 19:05:13 +0200 Subject: [PATCH 42/56] Remove debug print. --- src/state/in_memory_state_reader.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/state/in_memory_state_reader.rs b/src/state/in_memory_state_reader.rs index 2c75fd8a1..8e316e42b 100644 --- a/src/state/in_memory_state_reader.rs +++ b/src/state/in_memory_state_reader.rs @@ -106,7 +106,6 @@ impl StateReader for InMemoryStateReader { &self, class_hash: &ClassHash, ) -> Result { - println!("{}", std::backtrace::Backtrace::force_capture()); self.class_hash_to_compiled_class_hash .get(class_hash) .ok_or(StateError::NoneCompiledHash(*class_hash)) From 01b528d54980273ae85bea394c011cb30ab2b565 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Wed, 20 Sep 2023 13:22:31 +0200 Subject: [PATCH 43/56] Remove commented block of code. --- tests/internals.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/internals.rs b/tests/internals.rs index 7dbfbbbd1..5a7443a92 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -1706,11 +1706,6 @@ fn test_deploy_account_revert() { .storage_initial_values_mut() .extend(state_after.cache_mut().storage_initial_values_mut().clone()); - // // Set contract class cache - // state_reverted - // .set_contract_classes(state_after.contract_class_cache().clone()) - // .unwrap(); - // Set storage writes related to the fee transfer state_reverted .cache_mut() From b28780032a11180692fa2ec36357a939b6e9eb48 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Fri, 22 Sep 2023 13:49:30 +0200 Subject: [PATCH 44/56] Fix after merging. --- tests/complex_contracts/erc20.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/complex_contracts/erc20.rs b/tests/complex_contracts/erc20.rs index dc249032a..6d803b7fc 100644 --- a/tests/complex_contracts/erc20.rs +++ b/tests/complex_contracts/erc20.rs @@ -1,5 +1,3 @@ -use std::{collections::HashMap, sync::Arc}; - use cairo_vm::felt::{felt_str, Felt252}; use num_traits::Zero; use starknet_in_rust::{ @@ -10,13 +8,14 @@ use starknet_in_rust::{ }, services::api::contract_classes::compiled_class::CompiledClass, state::{ - cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, state_api::State, - ExecutionResourcesManager, + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::State, ExecutionResourcesManager, }, transaction::DeployAccount, utils::{calculate_sn_keccak, Address, ClassHash}, CasmContractClass, EntryPointType, }; +use std::sync::Arc; #[test] fn test_erc20_cairo2() { @@ -32,17 +31,19 @@ fn test_erc20_cairo2() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let contract_class_cache = Arc::new(PermanentContractClassCache::default()); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - contract_class_cache.insert( - erc20_class_hash, - CompiledClass::Casm(Arc::new(test_contract_class)), - ); + contract_class_cache.extend([ + (class_hash, CompiledClass::Casm(Arc::new(contract_class))), + ( + erc20_class_hash, + CompiledClass::Casm(Arc::new(test_contract_class)), + ), + ]); let mut state_reader = InMemoryStateReader::default(); state_reader From 57c52f9aac808c4e49f368edfceb24768e0ac3a6 Mon Sep 17 00:00:00 2001 From: Esteve Soler Arderiu Date: Fri, 22 Sep 2023 13:53:13 +0200 Subject: [PATCH 45/56] Fix formatting. --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b9ab9f818..b14dfc402 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -229,7 +229,14 @@ mod test { transaction::{ Declare, DeclareV2, Deploy, DeployAccount, InvokeFunction, L1Handler, Transaction, }, - utils::{felt_to_hash, Address, ClassHash, test_utils::{TEST_CONTRACT_PATH, create_account_tx_test_state, TEST_CONTRACT_ADDRESS, TEST_ACCOUNT_CONTRACT_ADDRESS, TEST_FIB_COMPILED_CONTRACT_CLASS_HASH}}, + utils::{ + felt_to_hash, + test_utils::{ + create_account_tx_test_state, TEST_ACCOUNT_CONTRACT_ADDRESS, TEST_CONTRACT_ADDRESS, + TEST_CONTRACT_PATH, TEST_FIB_COMPILED_CONTRACT_CLASS_HASH, + }, + Address, ClassHash, + }, }; use cairo_lang_starknet::{ casm_contract_class::CasmContractClass, From 8a112590e107cc69767bd31c6034c7070ca47c0a Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:55:19 +0200 Subject: [PATCH 46/56] Update Pr: Make contract caches shared (#1071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove `serde_json_pythonic`. (#1047) * Remove `serde_json_pythonic`. * Fix JSON formatter on `deprecated_contract_class.rs`. * Fix hash JSON formatter (non-ascii support). * Add unwrap reasoning comment. * Add debug logging. (#1018) * Add `tracing` and update dependencies. * Configure the example to use tracing logging (and make it work again). * Add tracing logging. * Add error logging. * Fix error logging. * Reduce the amount of spam logged. * Update `README.md`. * Fix `Makefile` dependencies. * Remove `Debug` trait dependency. * Update `Cargo.lock` after merge. * Fix warnings. * Fix formatting. --------- Co-authored-by: Esteve Soler Arderiu * fmt and improvements * Fix skip validate (#1053) * update version * fix skip validation for invoke txs * run fmt * fix clippy suggestion * simplify a bit the execute_tx function variants * Add documentation to transaction/fee module (#889) * added comments to src/transaction/fee.rs * added return and error comments --------- Co-authored-by: fannyguthmann Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Co-authored-by: Juan Bono * Add comments to origin/Document-transactionl1_handler module (#888) * added comments to origin/Document-transactionl1_handler-module * modified comments * Test multi syscall (#687) * create multy syscall * remove the replace syscall, it failed because the contract adress didn't match * added library call_syscall * wip * wip * wip * wip * work in progress * remove .sjon files from starknet_programs * finished implemented all the syscalls * reorder code, create one call to syscall * fix pull bug * Update tests/multi_syscall_test.rs Co-authored-by: Matías Ignacio González * Update starknet_programs/cairo1/multi_syscall_test.cairo Co-authored-by: Matías Ignacio González * Update starknet_programs/cairo1/contract_a.cairo Co-authored-by: Matías Ignacio González * Update tests/multi_syscall_test.rs Co-authored-by: Matías Ignacio González * added test syscall for deploy * make format changes * corrected make clippy error * get_caller_address and get_contract_address return a adress * failed of get_contract_address * failed of get_contract_address * wip * modify the selector entrypoint_selector to be function specific * wip * wip * wip * add input to cairo functions * coorect format problem * wip * wip * wip * remove format problem * Fix sierra class hash calculation (#886) * reproduce bug * use pythonic formatter * rename test * fix test * cargo fmt * Fail with an Err transactions whose calculated fee exceed `max_fee` (#892) * Make tx fail when actual_fee exceeds max_fee * Changed test * Formatting * Fix logic * Leave fail only without charging * Change test * Fix test broken by better fee calc * Fixed test fee * Update fee on test_deploy_account * Remove comment --------- Co-authored-by: Juan Bono * Fix test_get_nonce_at (#910) * Fix test_get_nonce_at * Rely on another contract * fix get_sorted_events bug (#912) * fix get_sorted_events bug * fmt * fix clippy --------- Co-authored-by: Estéfano Bargas * Added documentations to syscalls/deprecated_syscall_handler module (#883) * added comments to file syscalls/deprecated_syscall_handler-module' * Update src/syscalls/deprecated_syscall_handler.rs Co-authored-by: Matías Ignacio González * Update src/syscalls/deprecated_syscall_handler.rs Co-authored-by: Matías Ignacio González --------- Co-authored-by: fannyguthmann Co-authored-by: Juan Bono Co-authored-by: Matías Ignacio González * wip * Modify the tests * fixed clippy errors --------- Co-authored-by: fannyguthmann Co-authored-by: Matías Ignacio González Co-authored-by: SantiagoPittella Co-authored-by: Juan Bono Co-authored-by: Estéfano Bargas * Parse internal calls (#915) * Added comments to core/contract_address module (#900) Co-authored-by: fannyguthmann * Add more transaction tests and fee investigation (#914) * add function for getting tx and refactor tests * improve imports * separe tests into 2 groups * fix test * add comments * format * cargo clippy * add details to every test * add fee discrepancy to test doc * cargo fmt * improve imports * added safety element --------- Co-authored-by: fannyguthmann Co-authored-by: Matías Ignacio González Co-authored-by: SantiagoPittella Co-authored-by: Juan Bono Co-authored-by: Estéfano Bargas Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> * remove transactionalstatereader as it is not needed as-is (#1054) * Fix test (or try to) * Revert "Fix test (or try to)" This reverts commit 423052f341165bb23b473c9231aa68560fb46568. * Implement Clone for CachedState * Fix conflict in Makefile + run clippy-fix * Remove empty line * fmt * Remove unwraps * Add clone_for_testing * Remove clones * Add cairo native (#943) * Added cairo native flag * Added cairo_native as dependency * Partial progress * Progress * Partial progress * Point to newly created branch on cairo native * Use updated version of cairo native and make test pass * Run test with storage_write and storage_read with cairo native * Tidy up code * Start unhardcoding stuff * Handle return values * Tidy up code a little * Added sierra programs cache * Add impl for emit_event and send_l1_message * Fix tests * Install LLVM on CI * Test * Test CI * Fix lint step * Save work in progress * Unhardcode calldata and entry point * Unhardcode more stuff * Fix test * Add basic implementation for call_contract * Add call to get_name to integration test * Make call_contract impl compile * Fix test * Pass the correct amount of builtins for every function * Improve test legibility * Write call_contract test skeleton * Finish writing test, still bugs to fix * implement get_execution_info, make increase_allowance work * More debugging * Basic test for call_contract working * More progress on testing ERC20 * More progress on test * Add caller and callee contracts * Fix call_contract test after merge * Fix callee address in tests * Polish some details * Remove use_cairo_native from TransactionExecutionContext * Write test skeleton * Add test contracts * Fix tests * Readd deleted contracts * Echo contract test passing * Update cairo compiler to version 2.2.0 * Calling another contract with events test is passing * Fix failing tests * Remove internal_calls field TODO in CallInfo returned by native_execute * Add event_emitter contract * Add cairo vm execution to the erc20 test for comparison * Add simple implementation for panics in native execution * Add some documentation in code * Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs * Add event_emitter contract * Remove print * Remove comments * Move native syscall handler to its own file * Add felt decode to string when program panics * Make cairo native an optional dependency behind a feature * Move execution result to cairo native * Add a README section explaining how to setup cairo native * Fix some clippy issues * Fix test compilation * CI test * Revert "CI test" This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d. * CI test * Test * Test * Address comment about multiple cfgs * Remove unnecessary clone * Test * Test * Switch to special workflow for native integration tests * Fix workflow * Fix stuff after merge. * Fix clippy warnings. * Fix after merge. * Fix comments. * Fix `Makefile`. * Remove unused import. * Use transactional state. * update cairo native to llvm 17 and remove nightly requirement * update ci * upd ci * try to fix ci * use ubuntu on native * try to fix ci * not needed? * fix ci * update cairo native * fix nightly usage * try to fix ci * dont need a transactional state reader, simply clone the state reader * try to fix ci * format * fix again * fix if * values * force rebuild * make cache track cairo 2 version to trigger rebuilds * try no restore key * update readme * fix tests on ci * update cairo native commit * fix more tests on ci * fix cairo native interface * try ci without cache * setup rustup home * make param passing to cairo native not obscure * try * try again * remove large packages * remove large dirs * remove android too * polly is needed * needs sudo * fix cov * fix test for now * format * cleanup ci file * use pyenv if available * nightly not needed in readme * add .sierra as generated to gitattributes * fix gitattributes * add casm too --------- Co-authored-by: Javier Chatruc Co-authored-by: Mariano Nicolini Co-authored-by: Esteve Soler Arderiu Co-authored-by: Edgar Luque * add test to check cairo 2 account contract deploy panic failing properly (#1045) * add test for account contract execution with panic * clippy * update cairo native to latest revision, u128 gas, mut self (#1082) Co-authored-by: Juan Bono * Fix `get_execution_info` syscall (#1081) * Mark read-only segments * Move call * Remove debug prints * Remove fn * Add test case * Add comment * Restore newlines * Add function comment * Fix test values * Undo changes to makefile * Undo changes to makefile * clippy * cairo-native: implement testing syscalls (#1084) * cleanup erc20 test (#1087) * Fix `get_onchain_data_segment_length` (#1085) * Fix get_onchain_data_segment_length * Update test values * Update test values * fmt --------- Co-authored-by: Juan Bono * Check that running a declare v1 yields a higher fee than simulating it without validation (#1076) * Reorder DeployAccount::apply * Revert "Reorder DeployAccount::apply" This reverts commit 11b0c39cd9cdd92f5211930e9f36f3840a978ae9. * Add test * Add test * clippy + fmt --------- Co-authored-by: Juan Bono * implement display and debug trait for Address (#1080) * implement display and debug trait for Address * hexa fmt * Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072) * Add recursive library call test * Add test programs * Change base changes * Add recursive test for call_contract * fmt + clippy * Add test for 100 contract calls * clippy + fmt * Update test values --------- Co-authored-by: Juan Bono * Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096) * Fix get_onchain_data_segment_length * Update test values * Update test values * fmt * Fix/Refactor `State::count actual storage changes` (#1086) * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Fix bug in `From for CompiledClass` implementation (#1090) * Fix bug in CompiledClass * Add tests --------- Co-authored-by: Juan Bono * fmt * Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104) * Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Fix get_onchain_data_segment_length * Add StorageChangesCount struct * Update test values * Update test values * fmt * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Add test case with declare * Deserialize Declare transactions * Create blockifier Declare transaction * Fix/Refactor `State::count actual storage changes` (#1086) * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Fix bug in `From for CompiledClass` implementation (#1090) * Fix bug in CompiledClass * Add tests * fetch class hash from the next block in declare tx * Return an error if a class_hash is not declared + add tests for declare tx * Fix error msg * Add support for DeclareV0-1 in sir_tests * Make Sierra class optional in declare v2 + other changes * Add support for DeclareV2 * Uncomment test * fix * Use new_with_sierra_class_hash_and_tx_hash * use CompiledClassHash instead of CompiledClass where applicatble * Handle nonce in declare v2 + run fmt * Set casm class before counting state changes in declare v2 * Changes * Make sierra class hash non-optional * fix + clippy * Use state_reader instead of creating a state to fetch the next block s contract classes * Add removed test * Update test values --------- Co-authored-by: Juan Bono * Execute `L1Handler` transactions using the `RpcState` (#1103) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Fix get_onchain_data_segment_length * Add StorageChangesCount struct * Update test values * Update test values * fmt * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Add test case with declare * Deserialize Declare transactions * Create blockifier Declare transaction * Fix/Refactor `State::count actual storage changes` (#1086) * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Fix bug in `From for CompiledClass` implementation (#1090) * Fix bug in CompiledClass * Add tests * fetch class hash from the next block in declare tx * Return an error if a class_hash is not declared + add tests for declare tx * Fix error msg * Add support for DeclareV0-1 in sir_tests * Make Sierra class optional in declare v2 + other changes * Add support for DeclareV2 * Uncomment test * fix * Use new_with_sierra_class_hash_and_tx_hash * use CompiledClassHash instead of CompiledClass where applicatble * Handle nonce in declare v2 + run fmt * Set casm class before counting state changes in declare v2 * Changes * Make sierra class hash non-optional * fix + clippy * Use state_reader instead of creating a state to fetch the next block s contract classes * Add removed test * Update test values * Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState * Add L1Handler to blockifier_tests::execute_tx * Add blockifier test case * Add L1Handler to sir_tests::execute_tx * Add one more test case * fmt --------- Co-authored-by: Juan Bono * Added a usage target to makefile (#1069) * Added a usage target to makefile * Fixed typo * Implement `NativeSyscallHandler::deploy` (#1106) * wip * Minor improvements + add test * Improve make clippy * Clippy + fmt * Update error messages * Add failure flag test * Fix typo * Apply suggestions + run formatter * Add llvm setup so we can run clippy with `cairo-native` feature * Fix * Remove todo * Use a proper class_hash * Fix test assertion --------- Co-authored-by: Juan Bono * update cairo native to use gas consumed (#1102) * update cairo native to use gas consumed * gas consumed * update native rev * fix gas consumed * remove comments * fixes --------- Co-authored-by: Juan Bono * Fix cairo-native feature-gated code * clippy --------- Co-authored-by: MrAzteca Co-authored-by: Esteve Soler Arderiu Co-authored-by: juanbono Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com> Co-authored-by: fannyguthmann Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Co-authored-by: Matías Ignacio González Co-authored-by: SantiagoPittella Co-authored-by: Estéfano Bargas Co-authored-by: Edgar Co-authored-by: ElFantasma Co-authored-by: Javier Chatruc Co-authored-by: Mariano Nicolini Co-authored-by: Esteve Soler Arderiu Co-authored-by: Antonio Calvín García Co-authored-by: Iñaki Garay --- .gitattributes | 2 + .github/workflows/rust-tests.yml | 297 +- Cargo.lock | 1276 ++++- Cargo.toml | 39 +- Makefile | 52 +- README.md | 20 +- bench/internals.rs | 8 +- cairo_programs/erc20.sierra | 5012 +++++++++++++++++ cairo_programs/wallet.sierra | 1430 +++++ cli/src/main.rs | 2 +- examples/contract_execution/main.rs | 9 + examples/lru_cache/main.rs | 2 +- fuzzer/src/main.rs | 2 +- rpc_state_reader/Cargo.toml | 2 +- rpc_state_reader/src/lib.rs | 43 +- rpc_state_reader/src/rpc_state.rs | 26 +- rpc_state_reader/src/utils.rs | 20 +- rpc_state_reader/tests/blockifier_tests.rs | 134 +- rpc_state_reader/tests/sir_tests.rs | 223 +- rust-toolchain | 2 +- .../contract_address/casm_contract_address.rs | 12 +- .../deprecated_contract_address.rs | 2 +- .../sierra_contract_address.rs | 77 +- src/core/errors/state_errors.rs | 2 + src/definitions/constants.rs | 8 +- src/execution/execution_entry_point.rs | 254 +- src/execution/gas_usage.rs | 49 +- src/execution/mod.rs | 13 +- src/lib.rs | 140 +- .../api/contract_classes/compiled_class.rs | 3 +- src/state/cached_state.rs | 269 +- src/state/mod.rs | 12 +- src/state/state_api.rs | 27 +- src/state/state_cache.rs | 35 +- .../business_logic_syscall_handler.rs | 137 +- ...precated_business_logic_syscall_handler.rs | 5 +- src/syscalls/deprecated_syscall_handler.rs | 2 +- src/syscalls/mod.rs | 2 + src/syscalls/native_syscall_handler.rs | 576 ++ src/syscalls/syscall_handler.rs | 2 +- src/transaction/declare.rs | 156 +- src/transaction/declare_v2.rs | 58 +- src/transaction/deploy.rs | 23 +- src/transaction/deploy_account.rs | 53 +- src/transaction/error.rs | 2 + src/transaction/fee.rs | 14 +- src/transaction/invoke_function.rs | 33 +- src/transaction/l1_handler.rs | 57 +- src/transaction/mod.rs | 1 + src/transaction/verify_version.rs | 8 +- src/utils.rs | 54 +- .../cairo1/square_root_recursive.cairo | 24 + starknet_programs/cairo1/wallet_wrapper.cairo | 9 + starknet_programs/cairo2/account_panic.cairo | 148 + starknet_programs/cairo2/callee.cairo | 22 + starknet_programs/cairo2/caller.cairo | 19 + starknet_programs/cairo2/deploy.cairo | 8 +- starknet_programs/cairo2/echo.cairo | 17 + starknet_programs/cairo2/echo_caller.cairo | 20 + starknet_programs/cairo2/erc20.cairo | 2 +- starknet_programs/cairo2/event_emitter.cairo | 30 + .../cairo2/hello_world_account.cairo | 2 +- .../cairo2/square_root_recursive.cairo | 37 + starknet_programs/cairo2/wallet_wrapper.cairo | 14 +- ...9bd7409f07591f0a04f539bdf56693eaaf3.sierra | 687 +++ ...46e7e79464ad52ecdad80079ddfe486ca5eef.casm | 1429 +++++ ...171713f0e5229a084989d3894c171c160ace2.casm | 524 ++ ...16c42fa9b87c812dc398e49b57bf77930629f.casm | 1097 ++++ ...4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm | 755 +++ ...fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm | 557 ++ ...f33d879f790e202eb2c4b8622005c12252641.casm | 476 ++ .../raw_contract_classes/fibonacci.sierra | 373 ++ tests/account_panic.rs | 117 + tests/cairo_1_syscalls.rs | 593 +- tests/cairo_native.rs | 1001 ++++ tests/complex_contracts/amm_contracts/amm.rs | 20 +- .../amm_contracts/amm_proxy.rs | 40 +- tests/complex_contracts/nft/erc721.rs | 32 +- tests/deploy_account.rs | 26 +- tests/fibonacci.rs | 12 +- tests/increase_balance.rs | 4 +- tests/internals.rs | 122 +- tests/storage.rs | 4 +- tests/syscalls.rs | 53 +- 84 files changed, 17879 insertions(+), 1082 deletions(-) create mode 100644 .gitattributes create mode 100644 cairo_programs/erc20.sierra create mode 100644 cairo_programs/wallet.sierra create mode 100644 src/syscalls/native_syscall_handler.rs create mode 100644 starknet_programs/cairo1/square_root_recursive.cairo create mode 100644 starknet_programs/cairo2/account_panic.cairo create mode 100644 starknet_programs/cairo2/callee.cairo create mode 100644 starknet_programs/cairo2/caller.cairo create mode 100644 starknet_programs/cairo2/echo.cairo create mode 100644 starknet_programs/cairo2/echo_caller.cairo create mode 100644 starknet_programs/cairo2/event_emitter.cairo create mode 100644 starknet_programs/cairo2/square_root_recursive.cairo create mode 100644 starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra create mode 100644 starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm create mode 100644 starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm create mode 100644 starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm create mode 100644 starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm create mode 100644 starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm create mode 100644 starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm create mode 100644 starknet_programs/raw_contract_classes/fibonacci.sierra create mode 100644 tests/account_panic.rs create mode 100644 tests/cairo_native.rs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..6630a6678 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.sierra linguist-generated +*.casm linguist-generated diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index c1bea663e..52d2dfe0e 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -9,211 +9,121 @@ on: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: 1.70.0 - CAIRO_PROGRAMS_PATH: | - cairo_programs/**/*.casm - cairo_programs/**/*.sierra - cairo_programs/**/*.json - starknet_programs/**/*.casm - starknet_programs/**/*.sierra - starknet_programs/**/*.json - !starknet_programs/raw_contract_classes/* + RUST_TOOLCHAIN: '1.72.1' jobs: - build-programs: - strategy: - matrix: - program-target: [ - compile-cairo, - compile-starknet, - compile-cairo-1-casm, - compile-cairo-1-sierra, - compile-cairo-2-casm, - compile-cairo-2-sierra, - ] - name: Build Cairo programs - runs-on: ubuntu-22.04 + build: + name: Build with release profile + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Install Rust $RUST_TOOLCHAIN + uses: dtolnay/rust-toolchain@master with: - fetch-depth: 0 - - - name: Fetch from cache - uses: actions/cache@v3 - id: cache-programs - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - restore-keys: ${{ matrix.program-target }}-cache- - - # This is not pretty, but we need `make` to see the compiled programs are - # actually newer than the sources, otherwise it will try to rebuild them - - name: Restore timestamps - uses: chetan/git-restore-mtime-action@v1 - + toolchain: $RUST_TOOLCHAIN + components: rustfmt, clippy - name: Python3 Build - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' - - - name: Install deps - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} - run: make deps - - - name: Build programs - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} - run: make -j ${{ matrix.program-target }} - - # NOTE: used to reduce the amount of cache steps we need in later jobs - # TODO: remove this cache once the workflow finishes - merge-caches: - name: Merge Cairo programs cache - runs-on: ubuntu-22.04 - needs: build-programs - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Fetch from cache (compile-cairo) - uses: actions/cache/restore@v3 - id: cache-programs - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-starknet) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-starknet-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-1-casm) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-1-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-1-sierra) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-1-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-2-casm) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-2-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-2-sierra) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-2-sierra) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Merge caches - uses: actions/cache/save@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - - build: - name: Build with release profile - needs: merge-caches - runs-on: ubuntu-22.04 - steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Checkout - uses: actions/checkout@v3 - - name: Fetch programs - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true + - name: Install deps + run: make deps - name: Build - run: cargo build --release --workspace + run: make build lint: name: Lint with fmt and clippy - needs: merge-caches - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest + env: + MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ + TABLEGEN_170_PREFIX: /usr/lib/llvm-17/ steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - name: Install Rust $RUST_TOOLCHAIN + uses: dtolnay/rust-toolchain@master + with: + toolchain: $RUST_TOOLCHAIN + components: rustfmt, clippy + - name: Python3 Build + uses: actions/setup-python@v4 with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt, clippy + python-version: '3.9' + cache: 'pip' - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Checkout - uses: actions/checkout@v3 - - name: Fetch programs - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - + - name: check and free hdd space left + run: | + echo "Listing 20 largest packages" + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 + df -h + sudo apt-get update + sudo apt-get remove -y '^llvm-.*' + sudo apt-get remove -y 'php.*' + sudo apt-get remove -y '^dotnet-.*' + sudo apt-get remove -y '^temurin-.*' + sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel + sudo apt-get autoremove -y + sudo apt-get clean + df -h + echo "Removing large directories" + # deleting 15GB + sudo rm -rf /usr/share/dotnet/ + sudo rm -rf /usr/local/lib/android + df -h + - name: add llvm deb repository + uses: myci-actions/add-deb-repo@10 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools + - name: Install deps + run: make deps - name: Format run: cargo fmt --all -- --check - name: Run clippy - run: cargo clippy --workspace --all-targets -- -D warnings + run: make clippy tests: env: INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} + MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ + TABLEGEN_170_PREFIX: /usr/lib/llvm-17/ strategy: fail-fast: false matrix: - target: [ test-cairo-1, test-cairo-2, test-doctests ] + target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ] name: Run tests - needs: merge-caches - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - name: Install Rust $RUST_TOOLCHAIN + uses: dtolnay/rust-toolchain@master + with: + toolchain: $RUST_TOOLCHAIN + components: rustfmt, clippy + - name: Python3 Build + uses: actions/setup-python@v4 with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt, clippy + python-version: '3.9' + cache: 'pip' - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Checkout - uses: actions/checkout@v3 - - name: Fetch programs - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - + - name: Install deps + run: make deps + - name: Install testing tools # TODO: remove `if` when nextest adds doctests support if: ${{ matrix.target != 'test-doctests' }} @@ -221,28 +131,47 @@ jobs: with: tool: cargo-nextest@0.9.49 + - name: check and free hdd space left + run: | + echo "Listing 20 largest packages" + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 + df -h + sudo apt-get update + sudo apt-get remove -y '^llvm-.*' + sudo apt-get remove -y 'php.*' + sudo apt-get remove -y '^dotnet-.*' + sudo apt-get remove -y '^temurin-.*' + sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel + sudo apt-get autoremove -y + sudo apt-get clean + df -h + echo "Removing large directories" + # deleting 15GB + sudo rm -rf /usr/share/dotnet/ + sudo rm -rf /usr/local/lib/android + df -h + - name: add llvm deb repository + uses: myci-actions/add-deb-repo@10 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools - name: Run tests (${{ matrix.target }}) run: make ${{ matrix.target }} coverage: - needs: merge-caches name: Generate and upload coverage report - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Install Rust - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - - name: Set nightly as default - run: rustup default nightly - - name: Install testing tools - uses: taiki-e/install-action@v2 + - name: Install Rust nightly + uses: dtolnay/rust-toolchain@master with: - tool: cargo-nextest@0.9.49,cargo-llvm-cov + toolchain: nightly - uses: Swatinem/rust-cache@v2 with: @@ -255,13 +184,17 @@ jobs: path: lcov.info key: coverage-cache-${{ github.sha }} - - name: Fetch programs - if: steps.restore-report.outputs.cache-hit != 'true' - uses: actions/cache/restore@v3 + - name: Python3 Build + uses: actions/setup-python@v4 with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true + python-version: '3.9' + cache: 'pip' + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Install deps + run: make deps - name: Generate coverage report if: steps.restore-report.outputs.cache-hit != 'true' diff --git a/Cargo.lock b/Cargo.lock index c53120744..6d46e8782 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash 0.8.3", - "base64 0.21.3", + "base64 0.21.4", "bitflags 2.4.0", "brotli", "bytes", @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -103,7 +103,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.3", + "socket2 0.5.4", "tokio", "tracing", ] @@ -133,7 +133,7 @@ dependencies = [ "impl-more", "pin-project-lite", "rustls", - "rustls-webpki 0.101.4", + "rustls-webpki", "tokio", "tokio-util", "tracing", @@ -184,7 +184,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.5.3", + "socket2 0.5.4", "time", "url", ] @@ -198,7 +198,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -252,9 +252,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -295,11 +295,17 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -311,15 +317,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -335,9 +341,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys", @@ -368,7 +374,7 @@ dependencies = [ "derivative", "hashbrown 0.13.2", "itertools 0.10.5", - "num-traits 0.2.16", + "num-traits 0.2.17", "zeroize", ] @@ -386,7 +392,7 @@ dependencies = [ "digest", "itertools 0.10.5", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "paste", "rustc_version", "zeroize", @@ -409,7 +415,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "proc-macro2", "quote", "syn 1.0.109", @@ -479,7 +485,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", ] @@ -512,7 +518,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -545,7 +551,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "base64 0.21.3", + "base64 0.21.4", "bytes", "cfg-if", "cookie", @@ -589,9 +595,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bigdecimal" @@ -601,7 +607,16 @@ checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", + "serde", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ "serde", ] @@ -614,6 +629,52 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.0", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.38", + "which", +] + +[[package]] +name = "bindgen" +version = "0.68.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" +dependencies = [ + "bitflags 2.4.0", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.38", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -684,7 +745,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "phf", "serde", "serde_json", @@ -698,9 +759,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.3.4" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -709,9 +770,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -719,9 +780,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -731,15 +792,15 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bytestring" @@ -795,7 +856,7 @@ dependencies = [ "lazy_static", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde", ] @@ -808,7 +869,7 @@ dependencies = [ "cairo-lang-utils", "indoc", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "parity-scale-codec", "parity-scale-codec-derive", "schemars", @@ -863,7 +924,7 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "salsa", "smol_str", @@ -890,7 +951,7 @@ checksum = "c35dddbc63b2a4870891cc74498726aa32bfaa518596352f9bb101411cc4c584" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", ] @@ -924,11 +985,11 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "salsa", "smol_str", @@ -949,7 +1010,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "salsa", "smol_str", "unescaper", @@ -983,7 +1044,7 @@ checksum = "170838817fc33ddb65e0a9480526df0b226b148a0fca0a5cd7071be4c6683157" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1032,7 +1093,7 @@ dependencies = [ "keccak", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "salsa", "thiserror", ] @@ -1056,7 +1117,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "salsa", "smol_str", @@ -1076,7 +1137,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "regex", "salsa", "serde", @@ -1132,7 +1193,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", "once_cell", @@ -1158,7 +1219,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "thiserror", ] @@ -1204,7 +1265,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "serde", "serde_json", @@ -1223,7 +1284,7 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "salsa", "smol_str", "thiserror", @@ -1246,16 +1307,63 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f974b6e859f0b09c0f13ec8188c96e9e8bbb5da04214f911dbb5bcda67cb812b" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "parity-scale-codec", "schemars", "serde", ] +[[package]] +name = "cairo-native" +version = "0.1.0" +source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" +dependencies = [ + "bumpalo", + "cairo-felt", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-sierra", + "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-gas", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-utils", + "cairo-native-runtime", + "cc", + "clap", + "id-arena", + "itertools 0.11.0", + "lazy_static", + "libc", + "melior", + "mlir-sys", + "num-bigint", + "serde", + "serde_json", + "thiserror", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cairo-native-runtime" +version = "0.1.0" +source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" +dependencies = [ + "cairo-felt", + "cairo-lang-runner", + "libc", + "starknet-crypto 0.6.0", + "starknet-curve 0.4.0", +] + [[package]] name = "cairo-vm" version = "0.8.7" @@ -1265,13 +1373,13 @@ dependencies = [ "anyhow", "ark-ff", "ark-std", - "bincode", + "bincode 2.0.0-rc.3", "bitvec", "cairo-felt", "cairo-lang-casm", "cairo-lang-starknet", "generic-array", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "hex", "keccak", "lazy_static", @@ -1280,7 +1388,7 @@ dependencies = [ "num-bigint", "num-integer", "num-prime", - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", "serde", "serde_json", @@ -1290,6 +1398,12 @@ dependencies = [ "thiserror-no-std", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -1300,6 +1414,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -1308,17 +1431,44 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde", "windows-targets", ] +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cipher" version = "0.4.4" @@ -1329,11 +1479,22 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" -version = "4.4.2" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", "clap_derive", @@ -1341,14 +1502,15 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", + "terminal_size", ] [[package]] @@ -1360,7 +1522,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1386,6 +1548,25 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "comrak" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "482aa5695bca086022be453c700a40c02893f1ba7098a2c88351de55341ae894" +dependencies = [ + "clap", + "entities", + "memchr", + "once_cell", + "regex", + "shell-words", + "slug", + "syntect", + "typed-arena", + "unicode_categories", + "xdg", +] + [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -1418,6 +1599,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -1448,6 +1639,66 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "is-terminal", + "itertools 0.10.5", + "num-traits 0.2.17", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-utils" version = "0.8.16" @@ -1465,9 +1716,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array", "subtle", @@ -1486,12 +1737,12 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" +checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1548,7 +1799,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1570,7 +1821,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1585,6 +1836,19 @@ dependencies = [ "ordered-float", ] +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.1", + "lock_api", + "once_cell", + "parking_lot_core 0.9.8", +] + [[package]] name = "deranged" version = "0.3.8" @@ -1618,6 +1882,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deunicode" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" + [[package]] name = "diff" version = "0.1.13" @@ -1664,9 +1934,9 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dyn-clone" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "either" @@ -1692,6 +1962,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "equivalent" version = "1.0.1" @@ -1700,25 +1976,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "eth-keystore" version = "0.5.0" @@ -1768,11 +2033,21 @@ dependencies = [ "uint", ] +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fixed-hash" @@ -1867,7 +2142,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1903,7 +2178,7 @@ version = "0.4.0" dependencies = [ "cairo-vm", "honggfuzz", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde_json", "starknet_api", "starknet_in_rust", @@ -1912,9 +2187,9 @@ dependencies = [ [[package]] name = "genco" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6973ce8518068a71d404f428f6a5b563088545546a6bd8f9c0a7f2608149bc8a" +checksum = "c4fd234893ffe9cf5b81224ebb1d21bbe2eeb94d95bac3ea25c97cba7293304d" dependencies = [ "genco-macros", "relative-path", @@ -1923,13 +2198,13 @@ dependencies = [ [[package]] name = "genco-macros" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2c778cf01917d0fbed53900259d6604a421fab4916a2e738856ead9f1d926a" +checksum = "8e1c8cd3de2f32ee05ba2adaa90f8d0c354ffa0adeb2d186978d7ae70e5025e9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] @@ -1973,11 +2248,17 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "good_lp" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7f3b0e0de4e671b6ffc1274b153a9394cb58bf04ee67505b0cb9915513115f" +checksum = "fa124423ded10046a849fa0ae9747c541895557f1af177e0890b09879e7e9e7d" dependencies = [ "fnv", "minilp", @@ -2002,6 +2283,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.12.3" @@ -2022,9 +2309,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -2048,9 +2335,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -2067,6 +2354,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + [[package]] name = "honggfuzz" version = "0.5.55" @@ -2268,20 +2564,20 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "serde", ] [[package]] name = "indoc" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "inout" @@ -2385,7 +2681,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax", + "regex-syntax 0.7.5", "string_cache", "term", "tiny-keccak", @@ -2416,37 +2712,67 @@ dependencies = [ "spin", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" + +[[package]] +name = "libloading" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] [[package]] name = "libmimalloc-sys" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25d058a81af0d1c22d7a1c948576bee6d673f7af3c0f35564abd6c81122f513d" +checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" dependencies = [ "cc", "libc", ] [[package]] -name = "linux-raw-sys" -version = "0.4.5" +name = "line-wrap" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" - +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" + [[package]] name = "local-channel" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" +checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" dependencies = [ "futures-core", "futures-sink", - "futures-util", "local-waker", ] @@ -2487,7 +2813,16 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.14.1", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", ] [[package]] @@ -2499,11 +2834,41 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "melior" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91ea0e9e00979f692a52fb127a2d352e358535168dece6fd4e7948fd7714db5" +dependencies = [ + "criterion", + "dashmap", + "melior-macro", + "mlir-sys", + "once_cell", +] + +[[package]] +name = "melior-macro" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef4083994160cca85418ff2099183160787db26ab4ef5840bcf73472f678590" +dependencies = [ + "comrak", + "convert_case 0.6.0", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.38", + "tblgen", + "unindent", +] + [[package]] name = "memchr" -version = "2.6.2" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -2514,11 +2879,20 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "mimalloc" -version = "0.1.38" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972e5f23f6716f62665760b0f4cbf592576a80c7b879ba9beaafc0e558894127" +checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" dependencies = [ "libmimalloc-sys", ] @@ -2566,6 +2940,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "mlir-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e19a5391ed2759fd9060f538330b9b89191e7b13503d7499a4f9580af6699a" +dependencies = [ + "bindgen 0.68.1", +] + [[package]] name = "ndarray" version = "0.13.1" @@ -2575,7 +2958,7 @@ dependencies = [ "matrixmultiply", "num-complex", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rawpointer", ] @@ -2595,6 +2978,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -2603,7 +2996,7 @@ checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", "serde", ] @@ -2615,7 +3008,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ "autocfg", - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] @@ -2625,7 +3018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] @@ -2636,7 +3029,7 @@ checksum = "64a5fe11d4135c3bcdf3a95b18b194afa9608a5f6ff034f5d857bc9a27fb0119" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] @@ -2651,7 +3044,7 @@ dependencies = [ "num-bigint", "num-integer", "num-modular", - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", ] @@ -2661,23 +3054,23 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -2688,6 +3081,28 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "oorandom" version = "11.1.3" @@ -2700,9 +3115,15 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" dependencies = [ - "num-traits 0.2.16", + "num-traits 0.2.17", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parity-scale-codec" version = "3.6.4" @@ -2798,6 +3219,12 @@ dependencies = [ "digest", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2811,7 +3238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.0.2", ] [[package]] @@ -2844,7 +3271,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -2889,6 +3316,48 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "plist" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" +dependencies = [ + "base64 0.21.4", + "indexmap 1.9.3", + "line-wrap", + "quick-xml", + "serde", + "time", +] + +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits 0.2.17", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2921,6 +3390,16 @@ dependencies = [ "pretty_assertions", ] +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn 2.0.38", +] + [[package]] name = "primitive-types" version = "0.12.1" @@ -2970,13 +3449,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.33" @@ -3028,6 +3516,26 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -3059,33 +3567,54 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.4" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.1", + "regex-syntax 0.8.0", ] [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.0", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "regex-syntax" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" + [[package]] name = "relative-path" version = "1.9.0" @@ -3094,11 +3623,11 @@ checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -3120,6 +3649,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -3127,7 +3657,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots", "winreg", ] @@ -3217,9 +3747,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ "bitflags 2.4.0", "errno", @@ -3236,7 +3766,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki 0.101.4", + "rustls-webpki", "sct", ] @@ -3246,24 +3776,14 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", ] [[package]] name = "rustls-webpki" -version = "0.100.2" +version = "0.101.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" dependencies = [ "ring", "untrusted", @@ -3281,6 +3801,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "salsa" version = "0.16.1" @@ -3319,11 +3845,20 @@ dependencies = [ "cipher", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schemars" -version = "0.8.13" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" dependencies = [ "dyn-clone", "indexmap 1.9.3", @@ -3334,9 +3869,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.13" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" dependencies = [ "proc-macro2", "quote", @@ -3374,9 +3909,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" @@ -3395,7 +3930,7 @@ checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -3411,9 +3946,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -3474,11 +4009,11 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_json", "serde_with_macros 3.3.0", @@ -3494,7 +4029,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -3506,14 +4041,14 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -3522,9 +4057,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -3541,6 +4076,27 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3565,11 +4121,20 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +dependencies = [ + "deunicode", +] + [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smol_str" @@ -3592,9 +4157,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys", @@ -3625,7 +4190,7 @@ checksum = "8fcb61961b91757a9bc2d11549067445b2f921bd957f53710db35449767a1ba3" dependencies = [ "starknet-accounts", "starknet-contract", - "starknet-core", + "starknet-core 0.5.1", "starknet-crypto 0.6.0", "starknet-ff", "starknet-macros", @@ -3640,7 +4205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "111ed887e4db14f0df1f909905e7737e4730770c8ed70997b58a71d5d940daac" dependencies = [ "async-trait", - "starknet-core", + "starknet-core 0.5.1", "starknet-providers", "starknet-signers", "thiserror", @@ -3656,7 +4221,7 @@ dependencies = [ "serde_json", "serde_with 2.3.3", "starknet-accounts", - "starknet-core", + "starknet-core 0.5.1", "starknet-providers", "thiserror", ] @@ -3667,7 +4232,25 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91f89c79b641618de8aa9668d74c6b6634659ceca311c6318a35c025f9d4d969" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", + "flate2", + "hex", + "serde", + "serde_json", + "serde_json_pythonic", + "serde_with 2.3.3", + "sha3", + "starknet-crypto 0.6.0", + "starknet-ff", +] + +[[package]] +name = "starknet-core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14139b1c39bdc2f1e663c12090ff5108fe50ebe62c09e15e32988dfaf445a7e4" +dependencies = [ + "base64 0.21.4", "flate2", "hex", "serde", @@ -3690,7 +4273,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -3710,7 +4293,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -3727,7 +4310,7 @@ checksum = "af6527b845423542c8a16e060ea1bc43f67229848e7cd4c4d80be994a84220ce" dependencies = [ "starknet-curve 0.4.0", "starknet-ff", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -3765,12 +4348,12 @@ dependencies = [ [[package]] name = "starknet-macros" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a5865ee0ed22ade86bdf45e7c09c5641f1c59ccae12c21ecde535b2b6bf64a" +checksum = "ef846b6bb48fc8c3e9a2aa9b5b037414f04a908d9db56493a3ae69a857eb2506" dependencies = [ - "starknet-core", - "syn 2.0.29", + "starknet-core 0.6.1", + "syn 2.0.38", ] [[package]] @@ -3788,7 +4371,7 @@ dependencies = [ "serde", "serde_json", "serde_with 2.3.3", - "starknet-core", + "starknet-core 0.5.1", "thiserror", "url", ] @@ -3804,7 +4387,7 @@ dependencies = [ "clap", "coverage-helper", "mimalloc", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde", "starknet_in_rust", ] @@ -3820,7 +4403,7 @@ dependencies = [ "crypto-bigint", "eth-keystore", "rand", - "starknet-core", + "starknet-core 0.5.1", "starknet-crypto 0.6.0", "thiserror", ] @@ -3849,12 +4432,13 @@ version = "0.4.0" dependencies = [ "anyhow", "assert_matches", - "base64 0.21.3", + "base64 0.21.4", "cairo-lang-casm", "cairo-lang-runner", "cairo-lang-sierra", "cairo-lang-starknet", "cairo-lang-utils", + "cairo-native", "cairo-vm", "coverage-helper", "flate2", @@ -3866,7 +4450,7 @@ dependencies = [ "mimalloc", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "pretty_assertions_sorted", "serde", @@ -3877,6 +4461,8 @@ dependencies = [ "starknet-crypto 0.5.1", "starknet_api", "thiserror", + "tracing", + "tracing-subscriber", ] [[package]] @@ -3942,21 +4528,76 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syntect" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" +dependencies = [ + "bincode 1.3.3", + "bitflags 1.3.2", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax 0.7.5", + "serde", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tblgen" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d19c09266feb8b16718d1183044d14703a0b4b59e55ce8beb4d6e21dd066b1b" +dependencies = [ + "bindgen 0.66.1", + "cc", + "paste", + "thiserror", +] + [[package]] name = "tempfile" version = "3.8.0" @@ -3981,59 +4622,69 @@ dependencies = [ "winapi", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys", +] + [[package]] name = "test-case" -version = "3.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1d6e7bde536b0412f20765b76e921028059adfd1b90d8974d33fd3c91b25df" +checksum = "c8f1e820b7f1d95a0cdbf97a5df9de10e1be731983ab943e56703ac1b8e9d425" dependencies = [ "test-case-macros", ] [[package]] name = "test-case-core" -version = "3.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d10394d5d1e27794f772b6fc854c7e91a2dc26e2cbf807ad523370c2a59c0cee" +checksum = "54c25e2cb8f5fcd7318157634e8838aa6f7e4715c96637f969fabaccd1ef5462" dependencies = [ "cfg-if", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] name = "test-case-macros" -version = "3.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb9a44b1c6a54c1ba58b152797739dba2a83ca74e18168a68c980eb142f9404" +checksum = "37cfd7bbc88a0104e304229fba519bdc45501a30b760fb72240342f1289ad257" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", "test-case-core", ] [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -4056,6 +4707,16 @@ dependencies = [ "thiserror-impl-no-std", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.26" @@ -4093,6 +4754,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -4110,9 +4781,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", @@ -4121,7 +4792,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.4", "tokio-macros", "windows-sys", ] @@ -4134,7 +4805,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -4149,9 +4820,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" dependencies = [ "bytes", "futures-core", @@ -4163,9 +4834,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -4184,11 +4855,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -4210,9 +4881,21 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -4220,6 +4903,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -4228,11 +4941,17 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uint" @@ -4263,9 +4982,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -4288,6 +5007,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "untrusted" version = "0.7.1" @@ -4296,20 +5027,20 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "ureq" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b11c96ac7ee530603dcdf68ed1557050f374ce55a5a07193ebf8cbc9f8927e9" +checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "flate2", "log", "once_cell", "rustls", - "rustls-webpki 0.100.2", + "rustls-webpki", "serde", "serde_json", "url", - "webpki-roots 0.23.1", + "webpki-roots", ] [[package]] @@ -4345,12 +5076,28 @@ dependencies = [ "serde", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -4387,7 +5134,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -4421,7 +5168,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4444,18 +5191,21 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.23.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.2", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] -name = "webpki-roots" -version = "0.25.2" +name = "which" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] [[package]] name = "winapi" @@ -4473,6 +5223,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -4556,9 +5315,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] @@ -4582,6 +5341,12 @@ dependencies = [ "tap", ] +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" + [[package]] name = "xshell" version = "0.2.5" @@ -4597,6 +5362,15 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yansi" version = "0.5.1" @@ -4620,7 +5394,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ccb77a306..c4b08bf43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,54 +15,57 @@ metrics = [] members = ["cli", "fuzzer", "rpc_state_reader"] [workspace.dependencies] +cairo-lang-casm = "2.2.0" +cairo-lang-runner = "2.2.0" +cairo-lang-sierra = "2.2.0" +cairo-lang-starknet = "2.2.0" +cairo-lang-utils = "2.2.0" cairo-vm = { version = "0.8.5", features = ["cairo-1-hints"] } -starknet_api = "0.4.1" num-traits = "0.2.15" starknet = "0.5.0" +starknet_api = "0.4.1" thiserror = "1.0.32" -cairo-lang-starknet = "2.1.0-rc4" -cairo-lang-casm = "2.1.0-rc4" -cairo-lang-runner = "2.1.0-rc4" -cairo-lang-sierra = "2.1.0-rc4" -cairo-lang-utils = "2.1.0-rc4" [dependencies] -cairo-lang-starknet = { workspace = true } +anyhow = "1.0.66" +base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } cairo-lang-casm = { workspace = true } cairo-lang-runner = { workspace = true } cairo-lang-sierra = { workspace = true } +cairo-lang-starknet = { workspace = true } cairo-lang-utils = { workspace = true } +cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "03cd09ba3e51852da2234fb32a74056787abba8e", optional = true } cairo-vm = { workspace = true, features = ["cairo-1-hints"] } +flate2 = "1.0.25" getset = "0.1.2" +hex = "0.4.3" +# TODO: Replace with sha3. We should look how to integrate it correctly to calculate sn_keccak +keccak = "0.1.3" lazy_static = "1.4.0" +mimalloc = { version = "0.1.29", default-features = false, optional = true } num-bigint = { version = "0.4", features = ["serde"] } num-integer = "0.1.45" num-traits = { workspace = true } +once_cell = "1.17.1" +sha3 = "0.10.1" serde = { version = "1.0.152", features = ["derive"] } serde_json = { version = "1.0", features = [ "arbitrary_precision", "raw_value", ] } -sha3 = "0.10.1" -# TODO: Replace with sha3. We should look how to integrate it correctly to calculate sn_keccak -keccak = "0.1.3" +serde_json_pythonic = "0.1.2" +starknet = { workspace = true } starknet_api = { workspace = true } starknet-crypto = "0.5.1" thiserror = { workspace = true } -mimalloc = { version = "0.1.29", default-features = false, optional = true } -hex = "0.4.3" -anyhow = "1.0.66" -once_cell = "1.17.1" -starknet = { workspace = true } -base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } -flate2 = "1.0.25" -serde_json_pythonic = "0.1.2" +tracing = "0.1.37" [dev-dependencies] assert_matches = "1.5.0" coverage-helper = "0.2.0" lru = "0.11.0" pretty_assertions_sorted = "1.2.3" +tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } [[bench]] path = "bench/internals.rs" diff --git a/Makefile b/Makefile index 689a4695b..61183ab26 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \ +.PHONY: usage build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \ compile-cairo-2-casm compile-cairo-2-sierra coverage deps test heaptrack check-python-version export PATH:=$(shell pyenv root)/shims:$(PATH) @@ -10,7 +10,6 @@ ifeq ($(OS), Darwin) export LDFLAGS += -L/opt/homebrew/opt/gmp/lib endif - CAIRO_SOURCES=$(wildcard cairo_programs/*.cairo) CAIRO_TARGETS=$(patsubst %.cairo,%.json,$(CAIRO_SOURCES)) CAIRO_ABI_TARGETS=$(patsubst %.cairo,%_abi.json,$(CAIRO_SOURCES)) @@ -28,6 +27,24 @@ STARKNET_SIERRA_COMPILE_CAIRO_1:=cairo1/bin/starknet-sierra-compile STARKNET_COMPILE_CAIRO_2:=cairo2/bin/starknet-compile STARKNET_SIERRA_COMPILE_CAIRO_2:=cairo2/bin/starknet-sierra-compile +usage: + @echo 'Usage:' + @echo ' build: Builds the Rust code' + @echo ' check: Runs cargo check' + @echo ' deps: Installs dependencies' + @echo ' deps-macos: Installs depedencies for MacOS' + @echo ' clean: Cleans all build artifacts' + @echo ' clippy: Runs clippy' + @echo ' test: Runs all tests' + @echo ' test-cairo-1: Runs the Cairo 1 tests' + @echo ' test-cairo-2: Runs the Cairo 2 tests' + @echo ' test-doctests: Runs the doctests' + @echo ' coverage: Runs everything necessary to generate the coverage report' + @echo ' coverage-report: Just generates the coverage report' + @echo ' heaptrack: Runs the heaptrack script' + @echo ' flamegraph: Runs cargo flamegraph' + @echo ' benchmark: Runs the benchmarks scripts' + # # VENV rules. # @@ -98,7 +115,7 @@ CAIRO_2_COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.ca CAIRO_2_COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm, $(CAIRO_2_COMPILED_SIERRA_CONTRACTS)) $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.cairo - $(STARKNET_COMPILE_CAIRO_2) $< $@ + $(STARKNET_COMPILE_CAIRO_2) --single-file $< $@ --replace-ids $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra $(STARKNET_SIERRA_COMPILE_CAIRO_2) --add-pythonic-hints $< $@ @@ -106,8 +123,7 @@ $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra compile-cairo-2-sierra: $(CAIRO_2_COMPILED_SIERRA_CONTRACTS) compile-cairo-2-casm: $(CAIRO_2_COMPILED_CASM_CONTRACTS) - -CAIRO_2_VERSION=2.0.1 +CAIRO_2_VERSION=2.2.0 cairo-repo-2-dir = cairo2 cairo-repo-2-dir-macos = cairo2-macos @@ -133,20 +149,21 @@ cairo-%-macos.tar: cairo-%.tar: curl -L -o "$@" "https://github.com/starkware-libs/cairo/releases/download/v$*/release-x86_64-unknown-linux-musl.tar.gz" - # ================= # Normal rules. # ================= -build: compile-cairo compile-starknet +build: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo build --release --workspace -check: compile-cairo compile-starknet +check: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo check --workspace --all-targets deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler cargo install flamegraph --version 0.6.2 cargo install cargo-llvm-cov --version 0.5.14 + -pyenv && pyenv install -s pypy3.9-7.3.9 + -pyenv && pyenv install -s 3.9.15 python3.9 -m venv starknet-venv . starknet-venv/bin/activate && $(MAKE) deps-venv cargo install cargo-nextest --version 0.9.49 @@ -154,6 +171,8 @@ deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-compiler-macos cargo install flamegraph --version 0.6.2 cargo install cargo-llvm-cov --version 0.5.14 + -pyenv install -s pypy3.9-7.3.9 + -pyenv install -s 3.9.15 python3.9 -m venv starknet-venv . starknet-venv/bin/activate && $(MAKE) deps-venv cargo install cargo-nextest @@ -173,8 +192,8 @@ clean: -rm -rf cairo2/ -rm -rf cairo-*.tar -clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm - cargo clippy --workspace --all-targets -- -D warnings +clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo clippy --workspace --all-targets --all-features -- -D warnings test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra echo "Cairo1 tests" @@ -182,11 +201,14 @@ test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra echo "Cairo2 tests" $(MAKE) test-cairo-2 -test-cairo-1: - cargo nextest run --workspace --all-targets --features=cairo_1_tests +test-cairo-1: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo nextest run --workspace --all-targets --features=cairo_1_tests,metrics + +test-cairo-2: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo nextest run --workspace --all-targets --features=metrics -test-cairo-2: - cargo nextest run --workspace --all-targets +test-cairo-native: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo nextest run --workspace --test cairo_native --features=cairo-native test-doctests: cargo test --workspace --doc @@ -194,7 +216,7 @@ test-doctests: coverage: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm $(MAKE) coverage-report -coverage-report: +coverage-report: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo +nightly llvm-cov nextest --lcov --ignore-filename-regex 'main.rs' --output-path lcov.info --release heaptrack: diff --git a/README.md b/README.md index b90b9f1e5..43ce64184 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ It makes use of [cairo-vm](https://github.com/lambdaclass/cairo-vm), the Rust im ### Installation +If you run `make` on it's own it will print out the main targets and their description. + Run the following make targets to have a working environment (if in Mac or if you encounter an error, see the subsection below): #### Linux (x86-64) @@ -98,7 +100,19 @@ In Mac you'll also need to tell the script where to find the gmp lib: export CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib ``` +### Cairo Native support + +Starknet in Rust can be integrated with [Cairo Native](https://github.com/lambdaclass/cairo_native), which makes the execution of sierra programs possible through native machine code. To use it, the following needs to be setup: + +- LLVM `17` needs to be installed and the `MLIR_SYS_170_PREFIX` and `TABLEGEN_170_PREFIX` environment variable needs to point to said installation. In macOS, run + ``` + brew install llvm@17 + export MLIR_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17 + export TABLEGEN_170_PREFIX=/opt/homebrew/opt/llvm@17 + ``` + and you're set. +Afterwards, compiling with the feature flag `cairo-native` will enable native execution. You can check out some example test code that uses it under `tests/cairo_native.rs`. ## 🚀 Usage @@ -109,7 +123,6 @@ You can find a tutorial on running contracts [here](/examples/contract_execution ### Using the CLI You can find an example on how to use the CLI [here](/docs/CLI_USAGE_EXAMPLE.md) - ### Customization #### Contract class cache behavior @@ -153,6 +166,11 @@ cache.extend(state1.state.drain_private_contract_class_cache()); cache.extend(state2.state.drain_private_contract_class_cache()); ``` +#### Logging configuration + +This project uses the [`tracing`](https://crates.io/crates/tracing) crate as a library. Check out +its documentation for more information. + ### Testing [Add an Infura API key.](#rpc-state-reader) diff --git a/bench/internals.rs b/bench/internals.rs index abb10cd2e..bc64f8075 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -81,7 +81,7 @@ fn deploy_account() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut state_copy = state.clone(); + let mut state_copy = state.clone_for_testing(); let class_hash = *CLASS_HASH_BYTES; let signature = SIGNATURE.clone(); scope(|| { @@ -116,7 +116,7 @@ fn declare() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut cloned_state = state.clone(); + let mut cloned_state = state.clone_for_testing(); let class = CONTRACT_CLASS.clone(); let address = CONTRACT_ADDRESS.clone(); scope(|| { @@ -158,7 +158,7 @@ fn deploy() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut state_copy = state.clone(); + let mut state_copy = state.clone_for_testing(); let salt = felt_str!( "2669425616857739096022668060305620640217901643963991674344872184515580705509" ); @@ -213,7 +213,7 @@ fn invoke() { let _deploy_exec_info = deploy.execute(&mut state, block_context).unwrap(); for _ in 0..RUNS { - let mut state_copy = state.clone(); + let mut state_copy = state.clone_for_testing(); let address = CONTRACT_ADDRESS.clone(); let selector = VALIDATE_ENTRY_POINT_SELECTOR.clone(); let signature = SIGNATURE.clone(); diff --git a/cairo_programs/erc20.sierra b/cairo_programs/erc20.sierra new file mode 100644 index 000000000..d7a57bf24 --- /dev/null +++ b/cairo_programs/erc20.sierra @@ -0,0 +1,5012 @@ +type RangeCheck = RangeCheck; +type GasBuiltin = GasBuiltin; +type felt252 = felt252; +type Array = Array; +type Snapshot> = Snapshot>; +type core::array::Span:: = Struct>>; +type u32 = u32; +type core::panics::Panic = Struct; +type Tuple> = Struct>; +type Tuple> = Struct>; +type core::panics::PanicResult::<(core::array::Span::,)> = Enum>, Tuple>>; +type System = System; +type BuiltinCosts = BuiltinCosts; +type erc20::erc20::erc_20::name::ContractState = Struct; +type erc20::erc20::erc_20::symbol::ContractState = Struct; +type erc20::erc20::erc_20::decimals::ContractState = Struct; +type erc20::erc20::erc_20::total_supply::ContractState = Struct; +type erc20::erc20::erc_20::balances::ContractState = Struct; +type erc20::erc20::erc_20::allowances::ContractState = Struct; +type erc20::erc20::erc_20::ContractState = Struct; +type Tuple = Struct; +type core::panics::PanicResult::<(core::felt252,)> = Enum, Tuple>>; +type Unit = Struct; +type u8 = u8; +type Tuple = Struct; +type core::panics::PanicResult::<(core::integer::u8,)> = Enum, Tuple>>; +type u128 = u128; +type core::integer::u256 = Struct; +type Tuple = Struct; +type core::panics::PanicResult::<(core::integer::u256,)> = Enum, Tuple>>; +type ContractAddress = ContractAddress; +type core::option::Option:: = Enum; +type Pedersen = Pedersen; +type core::option::Option:: = Enum; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())> = Enum, Tuple>>; +type core::option::Option:: = Enum; +type core::option::Option:: = Enum; +type Tuple = Struct; +type core::option::Option:: = Enum; +type Tuple = Struct; +type core::panics::PanicResult::<(core::starknet::contract_address::ContractAddress,)> = Enum, Tuple>>; +type Box = Box; +type core::option::Option::> = Enum, Unit>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::name::ContractState, ())> = Enum, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::symbol::ContractState, ())> = Enum, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::decimals::ContractState, ())> = Enum, Tuple>>; +type NonZero = NonZero; +type core::bool = Enum; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::total_supply::ContractState, ())> = Enum, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::balances::ContractState, ())> = Enum, Tuple>>; +type erc20::erc20::erc_20::Transfer = Struct; +type erc20::erc20::erc_20::Approval = Struct; +type erc20::erc20::erc_20::Event = Enum; +type StorageBaseAddress = StorageBaseAddress; +type StorageAddress = StorageAddress; +type core::result::Result::> = Enum>; +type core::result::Result::> = Enum>; +type Tuple>> = Struct>>; +type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; +type core::result::Result::> = Enum>; +type Tuple>> = Struct>>; +type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; +type u64 = u64; +type core::starknet::info::BlockInfo = Struct; +type Box = Box; +type core::starknet::info::TxInfo = Struct, felt252, felt252, felt252>; +type Box = Box; +type core::starknet::info::ExecutionInfo = Struct, Box, ContractAddress, ContractAddress, felt252>; +type Box = Box; +type Tuple> = Struct>; +type core::panics::PanicResult::<(core::box::Box::,)> = Enum>, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::allowances::ContractState, ())> = Enum, Tuple>>; +type core::result::Result::<(), core::array::Array::> = Enum>; +type Tuple = Struct; +type core::panics::PanicResult::<((),)> = Enum, Tuple>>; +type core::result::Result::> = Enum>; +type Tuple>> = Struct>>; +type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; +type core::result::Result::, core::array::Array::> = Enum, Array>; +type Tuple = Struct; +type Tuple = Struct; + +libfunc revoke_ap_tracking = revoke_ap_tracking; +libfunc withdraw_gas = withdraw_gas; +libfunc branch_align = branch_align; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc array_len = array_len; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc u32_const<0> = u32_const<0>; +libfunc rename = rename; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc u32_eq = u32_eq; +libfunc array_new = array_new; +libfunc felt252_const<7733229381460288120802334208475838166080759535023995805565484692595> = felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>; +libfunc store_temp = store_temp; +libfunc array_append = array_append; +libfunc struct_construct = struct_construct; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 1> = enum_init,)>, 1>; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc store_temp,)>> = store_temp,)>>; +libfunc get_builtin_costs = get_builtin_costs; +libfunc store_temp = store_temp; +libfunc withdraw_gas_all = withdraw_gas_all; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp> = store_temp>; +libfunc function_call = function_call; +libfunc drop = drop; +libfunc snapshot_take> = snapshot_take>; +libfunc drop> = drop>; +libfunc struct_construct> = struct_construct>; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 0> = enum_init,)>, 0>; +libfunc felt252_const<375233589013918064796019> = felt252_const<375233589013918064796019>; +libfunc drop> = drop>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc store_temp> = store_temp>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc drop> = drop>; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917>; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916>; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop = drop; +libfunc drop = drop; +libfunc drop = drop; +libfunc drop = drop; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc rename = rename; +libfunc struct_construct = struct_construct; +libfunc store_temp = store_temp; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc rename = rename; +libfunc u8_to_felt252 = u8_to_felt252; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc rename> = rename>; +libfunc rename = rename; +libfunc contract_address_try_from_felt252 = contract_address_try_from_felt252; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc store_temp = store_temp; +libfunc store_temp> = store_temp>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_construct = struct_construct; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc function_call = function_call; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc dup = dup; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc snapshot_take = snapshot_take; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc array_snapshot_pop_front = array_snapshot_pop_front; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc store_temp>> = store_temp>>; +libfunc jump = jump; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc enum_match>> = enum_match>>; +libfunc unbox = unbox; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc contract_address_to_felt252 = contract_address_to_felt252; +libfunc felt252_const<0> = felt252_const<0>; +libfunc felt252_sub = felt252_sub; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc felt252_is_zero = felt252_is_zero; +libfunc enum_init = enum_init; +libfunc store_temp = store_temp; +libfunc drop> = drop>; +libfunc enum_init = enum_init; +libfunc bool_not_impl = bool_not_impl; +libfunc enum_match = enum_match; +libfunc felt252_const<7300388948442106731950660484798539862217172507820428101544021685107> = felt252_const<7300388948442106731950660484798539862217172507820428101544021685107>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc contract_address_const<0> = contract_address_const<0>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct = struct_construct; +libfunc enum_init = enum_init; +libfunc store_temp = store_temp; +libfunc function_call>> = function_call>>; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336> = storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>; +libfunc storage_address_from_base = storage_address_from_base; +libfunc store_temp = store_temp; +libfunc storage_read_syscall = storage_read_syscall; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc rename>> = rename>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028> = storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>; +libfunc storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321> = storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc enum_match>,)>> = enum_match>,)>>; +libfunc struct_deconstruct>>> = struct_deconstruct>>>; +libfunc store_temp>> = store_temp>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646> = storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>; +libfunc function_call = function_call; +libfunc enum_match>,)>> = enum_match>,)>>; +libfunc struct_deconstruct>>> = struct_deconstruct>>>; +libfunc store_temp>> = store_temp>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc rename = rename; +libfunc u128_to_felt252 = u128_to_felt252; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_match,)>> = enum_match,)>>; +libfunc struct_deconstruct>> = struct_deconstruct>>; +libfunc unbox = unbox; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc felt252_const<25936191677694277552149992725516921697451103245639728> = felt252_const<25936191677694277552149992725516921697451103245639728>; +libfunc felt252_const<395754877894504967531585582359572169455970492464> = felt252_const<395754877894504967531585582359572169455970492464>; +libfunc snapshot_take = snapshot_take; +libfunc store_temp = store_temp; +libfunc function_call> = function_call>; +libfunc u128_const<340282366920938463463374607431768211455> = u128_const<340282366920938463463374607431768211455>; +libfunc snapshot_take = snapshot_take; +libfunc u128_eq = u128_eq; +libfunc felt252_const<101313248740993271302566317381896466254801065025584> = felt252_const<101313248740993271302566317381896466254801065025584>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct = struct_construct; +libfunc store_temp = store_temp; +libfunc function_call> = function_call>; +libfunc function_call = function_call; +libfunc felt252_const<39879774624079483812136948410799859986295> = felt252_const<39879774624079483812136948410799859986295>; +libfunc function_call = function_call; +libfunc felt252_const<39879774624085075084607933104993585622903> = felt252_const<39879774624085075084607933104993585622903>; +libfunc u8_try_from_felt252 = u8_try_from_felt252; +libfunc rename = rename; +libfunc rename> = rename>; +libfunc snapshot_take = snapshot_take; +libfunc storage_write_syscall = storage_write_syscall; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc rename>> = rename>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc snapshot_take = snapshot_take; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc snapshot_take = snapshot_take; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc snapshot_take = snapshot_take; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call::into> = function_call::into>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc function_call = function_call; +libfunc emit_event_syscall = emit_event_syscall; +libfunc enum_match>> = enum_match>>; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct>>> = struct_construct>>>; +libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; +libfunc store_temp>,)>> = store_temp>,)>>; +libfunc felt252_const<110930490496575599150170734222081291576> = felt252_const<110930490496575599150170734222081291576>; +libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc enum_match>> = enum_match>>; +libfunc dup = dup; +libfunc dup = dup; +libfunc function_call = function_call; +libfunc enum_match>,)>> = enum_match>,)>>; +libfunc struct_deconstruct>>> = struct_deconstruct>>>; +libfunc enum_match>> = enum_match>>; +libfunc u8_const<1> = u8_const<1>; +libfunc storage_address_from_base_and_offset = storage_address_from_base_and_offset; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct>>> = struct_construct>>>; +libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; +libfunc store_temp>,)>> = store_temp>,)>>; +libfunc felt252_const<476442828812030857794232422692155113556837216824> = felt252_const<476442828812030857794232422692155113556837216824>; +libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc drop = drop; +libfunc enum_match>> = enum_match>>; +libfunc felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564> = felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564>; +libfunc function_call = function_call; +libfunc storage_base_address_from_felt252 = storage_base_address_from_felt252; +libfunc felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719> = felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719>; +libfunc function_call::hash> = function_call::hash>; +libfunc u128s_from_felt252 = u128s_from_felt252; +libfunc rename> = rename>; +libfunc get_execution_info_syscall = get_execution_info_syscall; +libfunc enum_init, core::array::Array::>, 0> = enum_init, core::array::Array::>, 0>; +libfunc store_temp, core::array::Array::>> = store_temp, core::array::Array::>>; +libfunc enum_init, core::array::Array::>, 1> = enum_init, core::array::Array::>, 1>; +libfunc rename, core::array::Array::>> = rename, core::array::Array::>>; +libfunc function_call>::unwrap_syscall> = function_call>::unwrap_syscall>; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 0> = enum_init,)>, 0>; +libfunc store_temp,)>> = store_temp,)>>; +libfunc enum_init,)>, 1> = enum_init,)>, 1>; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc function_call = function_call; +libfunc enum_match>> = enum_match>>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc enum_match = enum_match; +libfunc felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697> = felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697>; +libfunc function_call = function_call; +libfunc felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999> = felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999>; +libfunc function_call = function_call; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct>>> = struct_construct>>>; +libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; +libfunc store_temp>,)>> = store_temp>,)>>; +libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc pedersen = pedersen; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc rename = rename; +libfunc enum_match, core::array::Array::>> = enum_match, core::array::Array::>>; +libfunc enum_init = enum_init; +libfunc u128_overflowing_add = u128_overflowing_add; +libfunc struct_construct> = struct_construct>; +libfunc store_temp> = store_temp>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct> = struct_construct>; +libfunc store_temp> = store_temp>; +libfunc u128_const<1> = u128_const<1>; +libfunc drop = drop; +libfunc rename> = rename>; +libfunc u128_overflowing_sub = u128_overflowing_sub; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc function_call = function_call; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc rename = rename; + +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 87([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 28() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 74([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([29]) -> ([44]); +store_temp([2]) -> ([45]); +store_temp([40]) -> ([46]); +function_call([44], [45], [46]) -> ([41], [42], [43]); +store_temp([28]) -> ([28]); +enum_match>([43]) { fallthrough([47]) 67([48]) }; +branch_align() -> (); +array_new() -> ([49]); +struct_deconstruct>([47]) -> ([50]); +snapshot_take([50]) -> ([51], [52]); +drop([51]) -> (); +store_temp([52]) -> ([55]); +store_temp>([49]) -> ([56]); +function_call([55], [56]) -> ([53], [54]); +drop([54]) -> (); +snapshot_take>([53]) -> ([57], [58]); +drop>([57]) -> (); +struct_construct>([58]) -> ([59]); +struct_construct>>([59]) -> ([60]); +enum_init,)>, 0>([60]) -> ([61]); +store_temp([28]) -> ([62]); +store_temp([41]) -> ([63]); +store_temp([42]) -> ([64]); +store_temp,)>>([61]) -> ([65]); +return([62], [63], [64], [65]); +branch_align() -> (); +enum_init,)>, 1>([48]) -> ([66]); +store_temp([28]) -> ([67]); +store_temp([41]) -> ([68]); +store_temp([42]) -> ([69]); +store_temp,)>>([66]) -> ([70]); +return([67], [68], [69], [70]); +branch_align() -> (); +array_new() -> ([71]); +felt252_const<375233589013918064796019>() -> ([72]); +store_temp([72]) -> ([72]); +array_append([71], [72]) -> ([73]); +struct_construct() -> ([74]); +struct_construct>>([74], [73]) -> ([75]); +enum_init,)>, 1>([75]) -> ([76]); +store_temp([30]) -> ([77]); +store_temp([31]) -> ([78]); +store_temp([2]) -> ([79]); +store_temp,)>>([76]) -> ([80]); +return([77], [78], [79], [80]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([81]); +felt252_const<375233589013918064796019>() -> ([82]); +store_temp([82]) -> ([82]); +array_append([81], [82]) -> ([83]); +struct_construct() -> ([84]); +struct_construct>>([84], [83]) -> ([85]); +enum_init,)>, 1>([85]) -> ([86]); +store_temp([6]) -> ([87]); +store_temp([7]) -> ([88]); +store_temp([2]) -> ([89]); +store_temp,)>>([86]) -> ([90]); +return([87], [88], [89], [90]); +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 188([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 129() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 175([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([29]) -> ([44]); +store_temp([2]) -> ([45]); +store_temp([40]) -> ([46]); +function_call([44], [45], [46]) -> ([41], [42], [43]); +store_temp([28]) -> ([28]); +enum_match>([43]) { fallthrough([47]) 168([48]) }; +branch_align() -> (); +array_new() -> ([49]); +struct_deconstruct>([47]) -> ([50]); +snapshot_take([50]) -> ([51], [52]); +drop([51]) -> (); +store_temp([52]) -> ([55]); +store_temp>([49]) -> ([56]); +function_call([55], [56]) -> ([53], [54]); +drop([54]) -> (); +snapshot_take>([53]) -> ([57], [58]); +drop>([57]) -> (); +struct_construct>([58]) -> ([59]); +struct_construct>>([59]) -> ([60]); +enum_init,)>, 0>([60]) -> ([61]); +store_temp([28]) -> ([62]); +store_temp([41]) -> ([63]); +store_temp([42]) -> ([64]); +store_temp,)>>([61]) -> ([65]); +return([62], [63], [64], [65]); +branch_align() -> (); +enum_init,)>, 1>([48]) -> ([66]); +store_temp([28]) -> ([67]); +store_temp([41]) -> ([68]); +store_temp([42]) -> ([69]); +store_temp,)>>([66]) -> ([70]); +return([67], [68], [69], [70]); +branch_align() -> (); +array_new() -> ([71]); +felt252_const<375233589013918064796019>() -> ([72]); +store_temp([72]) -> ([72]); +array_append([71], [72]) -> ([73]); +struct_construct() -> ([74]); +struct_construct>>([74], [73]) -> ([75]); +enum_init,)>, 1>([75]) -> ([76]); +store_temp([30]) -> ([77]); +store_temp([31]) -> ([78]); +store_temp([2]) -> ([79]); +store_temp,)>>([76]) -> ([80]); +return([77], [78], [79], [80]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([81]); +felt252_const<375233589013918064796019>() -> ([82]); +store_temp([82]) -> ([82]); +array_append([81], [82]) -> ([83]); +struct_construct() -> ([84]); +struct_construct>>([84], [83]) -> ([85]); +enum_init,)>, 1>([85]) -> ([86]); +store_temp([6]) -> ([87]); +store_temp([7]) -> ([88]); +store_temp([2]) -> ([89]); +store_temp,)>>([86]) -> ([90]); +return([87], [88], [89], [90]); +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 289([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 230() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 276([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([28]) -> ([45]); +store_temp([29]) -> ([46]); +store_temp([2]) -> ([47]); +store_temp([40]) -> ([48]); +function_call([45], [46], [47], [48]) -> ([41], [42], [43], [44]); +enum_match>([44]) { fallthrough([49]) 269([50]) }; +branch_align() -> (); +array_new() -> ([51]); +struct_deconstruct>([49]) -> ([52]); +snapshot_take([52]) -> ([53], [54]); +drop([53]) -> (); +store_temp([54]) -> ([57]); +store_temp>([51]) -> ([58]); +function_call([57], [58]) -> ([55], [56]); +drop([56]) -> (); +snapshot_take>([55]) -> ([59], [60]); +drop>([59]) -> (); +struct_construct>([60]) -> ([61]); +struct_construct>>([61]) -> ([62]); +enum_init,)>, 0>([62]) -> ([63]); +store_temp([41]) -> ([64]); +store_temp([42]) -> ([65]); +store_temp([43]) -> ([66]); +store_temp,)>>([63]) -> ([67]); +return([64], [65], [66], [67]); +branch_align() -> (); +enum_init,)>, 1>([50]) -> ([68]); +store_temp([41]) -> ([69]); +store_temp([42]) -> ([70]); +store_temp([43]) -> ([71]); +store_temp,)>>([68]) -> ([72]); +return([69], [70], [71], [72]); +branch_align() -> (); +array_new() -> ([73]); +felt252_const<375233589013918064796019>() -> ([74]); +store_temp([74]) -> ([74]); +array_append([73], [74]) -> ([75]); +struct_construct() -> ([76]); +struct_construct>>([76], [75]) -> ([77]); +enum_init,)>, 1>([77]) -> ([78]); +store_temp([30]) -> ([79]); +store_temp([31]) -> ([80]); +store_temp([2]) -> ([81]); +store_temp,)>>([78]) -> ([82]); +return([79], [80], [81], [82]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([83]); +felt252_const<375233589013918064796019>() -> ([84]); +store_temp([84]) -> ([84]); +array_append([83], [84]) -> ([85]); +struct_construct() -> ([86]); +struct_construct>>([86], [85]) -> ([87]); +enum_init,)>, 1>([87]) -> ([88]); +store_temp([6]) -> ([89]); +store_temp([7]) -> ([90]); +store_temp([2]) -> ([91]); +store_temp,)>>([88]) -> ([92]); +return([89], [90], [91], [92]); +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 390([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 331() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 377([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([28]) -> ([45]); +store_temp([29]) -> ([46]); +store_temp([2]) -> ([47]); +store_temp([40]) -> ([48]); +function_call([45], [46], [47], [48]) -> ([41], [42], [43], [44]); +enum_match>([44]) { fallthrough([49]) 370([50]) }; +branch_align() -> (); +array_new() -> ([51]); +struct_deconstruct>([49]) -> ([52]); +snapshot_take([52]) -> ([53], [54]); +drop([53]) -> (); +store_temp([54]) -> ([57]); +store_temp>([51]) -> ([58]); +function_call([57], [58]) -> ([55], [56]); +drop([56]) -> (); +snapshot_take>([55]) -> ([59], [60]); +drop>([59]) -> (); +struct_construct>([60]) -> ([61]); +struct_construct>>([61]) -> ([62]); +enum_init,)>, 0>([62]) -> ([63]); +store_temp([41]) -> ([64]); +store_temp([42]) -> ([65]); +store_temp([43]) -> ([66]); +store_temp,)>>([63]) -> ([67]); +return([64], [65], [66], [67]); +branch_align() -> (); +enum_init,)>, 1>([50]) -> ([68]); +store_temp([41]) -> ([69]); +store_temp([42]) -> ([70]); +store_temp([43]) -> ([71]); +store_temp,)>>([68]) -> ([72]); +return([69], [70], [71], [72]); +branch_align() -> (); +array_new() -> ([73]); +felt252_const<375233589013918064796019>() -> ([74]); +store_temp([74]) -> ([74]); +array_append([73], [74]) -> ([75]); +struct_construct() -> ([76]); +struct_construct>>([76], [75]) -> ([77]); +enum_init,)>, 1>([77]) -> ([78]); +store_temp([30]) -> ([79]); +store_temp([31]) -> ([80]); +store_temp([2]) -> ([81]); +store_temp,)>>([78]) -> ([82]); +return([79], [80], [81], [82]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([83]); +felt252_const<375233589013918064796019>() -> ([84]); +store_temp([84]) -> ([84]); +array_append([83], [84]) -> ([85]); +struct_construct() -> ([86]); +struct_construct>>([86], [85]) -> ([87]); +enum_init,)>, 1>([87]) -> ([88]); +store_temp([6]) -> ([89]); +store_temp([7]) -> ([90]); +store_temp([2]) -> ([91]); +store_temp,)>>([88]) -> ([92]); +return([89], [90], [91], [92]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 519([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 503([15]) }; +branch_align() -> (); +struct_deconstruct>([10]) -> ([16]); +array_len([16]) -> ([17]); +snapshot_take([17]) -> ([18], [19]); +drop([18]) -> (); +u32_const<0>() -> ([20]); +snapshot_take([20]) -> ([21], [22]); +drop([21]) -> (); +rename([19]) -> ([23]); +rename([22]) -> ([24]); +store_temp([23]) -> ([23]); +u32_eq([23], [24]) { fallthrough() 438() }; +branch_align() -> (); +drop([14]) -> (); +array_new() -> ([25]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([26]); +store_temp([26]) -> ([26]); +array_append([25], [26]) -> ([27]); +struct_construct() -> ([28]); +struct_construct>>([28], [27]) -> ([29]); +enum_init,)>, 1>([29]) -> ([30]); +store_temp([0]) -> ([31]); +store_temp([9]) -> ([32]); +store_temp([6]) -> ([33]); +store_temp([3]) -> ([34]); +store_temp,)>>([30]) -> ([35]); +return([31], [32], [33], [34], [35]); +branch_align() -> (); +get_builtin_costs() -> ([36]); +store_temp([36]) -> ([36]); +withdraw_gas_all([9], [6], [36]) { fallthrough([37], [38]) 488([39], [40]) }; +branch_align() -> (); +struct_construct() -> ([41]); +struct_construct() -> ([42]); +struct_construct() -> ([43]); +struct_construct() -> ([44]); +struct_construct() -> ([45]); +struct_construct() -> ([46]); +struct_construct([41], [42], [43], [44], [45], [46]) -> ([47]); +snapshot_take([47]) -> ([48], [49]); +drop([48]) -> (); +store_temp([37]) -> ([55]); +store_temp([38]) -> ([56]); +store_temp([0]) -> ([57]); +store_temp([3]) -> ([58]); +store_temp([49]) -> ([59]); +store_temp([14]) -> ([60]); +function_call([55], [56], [57], [58], [59], [60]) -> ([50], [51], [52], [53], [54]); +enum_match>([54]) { fallthrough([61]) 480([62]) }; +branch_align() -> (); +array_new() -> ([63]); +struct_deconstruct>([61]) -> ([64]); +snapshot_take([64]) -> ([65], [66]); +drop([65]) -> (); +store_temp([66]) -> ([69]); +store_temp>([63]) -> ([70]); +function_call([69], [70]) -> ([67], [68]); +drop([68]) -> (); +snapshot_take>([67]) -> ([71], [72]); +drop>([71]) -> (); +struct_construct>([72]) -> ([73]); +struct_construct>>([73]) -> ([74]); +enum_init,)>, 0>([74]) -> ([75]); +store_temp([52]) -> ([76]); +store_temp([50]) -> ([77]); +store_temp([51]) -> ([78]); +store_temp([53]) -> ([79]); +store_temp,)>>([75]) -> ([80]); +return([76], [77], [78], [79], [80]); +branch_align() -> (); +enum_init,)>, 1>([62]) -> ([81]); +store_temp([52]) -> ([82]); +store_temp([50]) -> ([83]); +store_temp([51]) -> ([84]); +store_temp([53]) -> ([85]); +store_temp,)>>([81]) -> ([86]); +return([82], [83], [84], [85], [86]); +branch_align() -> (); +drop([14]) -> (); +array_new() -> ([87]); +felt252_const<375233589013918064796019>() -> ([88]); +store_temp([88]) -> ([88]); +array_append([87], [88]) -> ([89]); +struct_construct() -> ([90]); +struct_construct>>([90], [89]) -> ([91]); +enum_init,)>, 1>([91]) -> ([92]); +store_temp([0]) -> ([93]); +store_temp([39]) -> ([94]); +store_temp([40]) -> ([95]); +store_temp([3]) -> ([96]); +store_temp,)>>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([98]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([99]); +store_temp([99]) -> ([99]); +array_append([98], [99]) -> ([100]); +struct_construct() -> ([101]); +struct_construct>>([101], [100]) -> ([102]); +enum_init,)>, 1>([102]) -> ([103]); +store_temp([0]) -> ([104]); +store_temp([9]) -> ([105]); +store_temp([6]) -> ([106]); +store_temp([3]) -> ([107]); +store_temp,)>>([103]) -> ([108]); +return([104], [105], [106], [107], [108]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([109]); +felt252_const<375233589013918064796019>() -> ([110]); +store_temp([110]) -> ([110]); +array_append([109], [110]) -> ([111]); +struct_construct() -> ([112]); +struct_construct>>([112], [111]) -> ([113]); +enum_init,)>, 1>([113]) -> ([114]); +store_temp([0]) -> ([115]); +store_temp([7]) -> ([116]); +store_temp([8]) -> ([117]); +store_temp([3]) -> ([118]); +store_temp,)>>([114]) -> ([119]); +return([115], [116], [117], [118], [119]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 674([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 658([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 641([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 574() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 625([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +snapshot_take([54]) -> ([55], [56]); +drop([55]) -> (); +store_temp([44]) -> ([62]); +store_temp([45]) -> ([63]); +store_temp([0]) -> ([64]); +store_temp([3]) -> ([65]); +store_temp([56]) -> ([66]); +store_temp([14]) -> ([67]); +store_temp([21]) -> ([68]); +function_call([62], [63], [64], [65], [66], [67], [68]) -> ([57], [58], [59], [60], [61]); +enum_match>([61]) { fallthrough([69]) 617([70]) }; +branch_align() -> (); +array_new() -> ([71]); +struct_deconstruct>([69]) -> ([72]); +snapshot_take([72]) -> ([73], [74]); +drop([73]) -> (); +store_temp([74]) -> ([77]); +store_temp>([71]) -> ([78]); +function_call([77], [78]) -> ([75], [76]); +drop([76]) -> (); +snapshot_take>([75]) -> ([79], [80]); +drop>([79]) -> (); +struct_construct>([80]) -> ([81]); +struct_construct>>([81]) -> ([82]); +enum_init,)>, 0>([82]) -> ([83]); +store_temp([59]) -> ([84]); +store_temp([57]) -> ([85]); +store_temp([58]) -> ([86]); +store_temp([60]) -> ([87]); +store_temp,)>>([83]) -> ([88]); +return([84], [85], [86], [87], [88]); +branch_align() -> (); +enum_init,)>, 1>([70]) -> ([89]); +store_temp([59]) -> ([90]); +store_temp([57]) -> ([91]); +store_temp([58]) -> ([92]); +store_temp([60]) -> ([93]); +store_temp,)>>([89]) -> ([94]); +return([90], [91], [92], [93], [94]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([95]); +felt252_const<375233589013918064796019>() -> ([96]); +store_temp([96]) -> ([96]); +array_append([95], [96]) -> ([97]); +struct_construct() -> ([98]); +struct_construct>>([98], [97]) -> ([99]); +enum_init,)>, 1>([99]) -> ([100]); +store_temp([0]) -> ([101]); +store_temp([46]) -> ([102]); +store_temp([47]) -> ([103]); +store_temp([3]) -> ([104]); +store_temp,)>>([100]) -> ([105]); +return([101], [102], [103], [104], [105]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([106]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([107]); +store_temp([107]) -> ([107]); +array_append([106], [107]) -> ([108]); +struct_construct() -> ([109]); +struct_construct>>([109], [108]) -> ([110]); +enum_init,)>, 1>([110]) -> ([111]); +store_temp([0]) -> ([112]); +store_temp([16]) -> ([113]); +store_temp([6]) -> ([114]); +store_temp([3]) -> ([115]); +store_temp,)>>([111]) -> ([116]); +return([112], [113], [114], [115], [116]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([117]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([118]); +store_temp([118]) -> ([118]); +array_append([117], [118]) -> ([119]); +struct_construct() -> ([120]); +struct_construct>>([120], [119]) -> ([121]); +enum_init,)>, 1>([121]) -> ([122]); +store_temp([0]) -> ([123]); +store_temp([9]) -> ([124]); +store_temp([6]) -> ([125]); +store_temp([3]) -> ([126]); +store_temp,)>>([122]) -> ([127]); +return([123], [124], [125], [126], [127]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([128]); +felt252_const<375233589013918064796019>() -> ([129]); +store_temp([129]) -> ([129]); +array_append([128], [129]) -> ([130]); +struct_construct() -> ([131]); +struct_construct>>([131], [130]) -> ([132]); +enum_init,)>, 1>([132]) -> ([133]); +store_temp([0]) -> ([134]); +store_temp([7]) -> ([135]); +store_temp([8]) -> ([136]); +store_temp([3]) -> ([137]); +store_temp,)>>([133]) -> ([138]); +return([134], [135], [136], [137], [138]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 821([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 805([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 788([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 729() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 772([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 764([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 994([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 978([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 961([22]) }; +branch_align() -> (); +store_temp([16]) -> ([26]); +store_temp>([17]) -> ([27]); +function_call([26], [27]) -> ([23], [24], [25]); +enum_match>([25]) { fallthrough([28]) 943([29]) }; +branch_align() -> (); +struct_deconstruct>([24]) -> ([30]); +array_len([30]) -> ([31]); +snapshot_take([31]) -> ([32], [33]); +drop([32]) -> (); +u32_const<0>() -> ([34]); +snapshot_take([34]) -> ([35], [36]); +drop([35]) -> (); +rename([33]) -> ([37]); +rename([36]) -> ([38]); +store_temp([37]) -> ([37]); +u32_eq([37], [38]) { fallthrough() 882() }; +branch_align() -> (); +drop([28]) -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([39]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([40]); +store_temp([40]) -> ([40]); +array_append([39], [40]) -> ([41]); +struct_construct() -> ([42]); +struct_construct>>([42], [41]) -> ([43]); +enum_init,)>, 1>([43]) -> ([44]); +store_temp([0]) -> ([45]); +store_temp([23]) -> ([46]); +store_temp([6]) -> ([47]); +store_temp([3]) -> ([48]); +store_temp,)>>([44]) -> ([49]); +return([45], [46], [47], [48], [49]); +branch_align() -> (); +get_builtin_costs() -> ([50]); +store_temp([50]) -> ([50]); +withdraw_gas_all([23], [6], [50]) { fallthrough([51], [52]) 926([53], [54]) }; +branch_align() -> (); +struct_construct() -> ([55]); +struct_construct() -> ([56]); +struct_construct() -> ([57]); +struct_construct() -> ([58]); +struct_construct() -> ([59]); +struct_construct() -> ([60]); +struct_construct([55], [56], [57], [58], [59], [60]) -> ([61]); +store_temp([51]) -> ([67]); +store_temp([52]) -> ([68]); +store_temp([0]) -> ([69]); +store_temp([3]) -> ([70]); +store_temp([61]) -> ([71]); +store_temp([14]) -> ([72]); +store_temp([21]) -> ([73]); +store_temp([28]) -> ([74]); +function_call([67], [68], [69], [70], [71], [72], [73], [74]) -> ([62], [63], [64], [65], [66]); +enum_match>([66]) { fallthrough([75]) 918([76]) }; +branch_align() -> (); +drop>([75]) -> (); +array_new() -> ([77]); +snapshot_take>([77]) -> ([78], [79]); +drop>([78]) -> (); +struct_construct>([79]) -> ([80]); +struct_construct>>([80]) -> ([81]); +enum_init,)>, 0>([81]) -> ([82]); +store_temp([64]) -> ([83]); +store_temp([62]) -> ([84]); +store_temp([63]) -> ([85]); +store_temp([65]) -> ([86]); +store_temp,)>>([82]) -> ([87]); +return([83], [84], [85], [86], [87]); +branch_align() -> (); +enum_init,)>, 1>([76]) -> ([88]); +store_temp([64]) -> ([89]); +store_temp([62]) -> ([90]); +store_temp([63]) -> ([91]); +store_temp([65]) -> ([92]); +store_temp,)>>([88]) -> ([93]); +return([89], [90], [91], [92], [93]); +branch_align() -> (); +drop([28]) -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([94]); +felt252_const<375233589013918064796019>() -> ([95]); +store_temp([95]) -> ([95]); +array_append([94], [95]) -> ([96]); +struct_construct() -> ([97]); +struct_construct>>([97], [96]) -> ([98]); +enum_init,)>, 1>([98]) -> ([99]); +store_temp([0]) -> ([100]); +store_temp([53]) -> ([101]); +store_temp([54]) -> ([102]); +store_temp([3]) -> ([103]); +store_temp,)>>([99]) -> ([104]); +return([100], [101], [102], [103], [104]); +branch_align() -> (); +drop([29]) -> (); +drop>([24]) -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([105]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>() -> ([106]); +store_temp([106]) -> ([106]); +array_append([105], [106]) -> ([107]); +struct_construct() -> ([108]); +struct_construct>>([108], [107]) -> ([109]); +enum_init,)>, 1>([109]) -> ([110]); +store_temp([0]) -> ([111]); +store_temp([23]) -> ([112]); +store_temp([6]) -> ([113]); +store_temp([3]) -> ([114]); +store_temp,)>>([110]) -> ([115]); +return([111], [112], [113], [114], [115]); +branch_align() -> (); +drop([22]) -> (); +drop([14]) -> (); +drop>([17]) -> (); +array_new() -> ([116]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([117]); +store_temp([117]) -> ([117]); +array_append([116], [117]) -> ([118]); +struct_construct() -> ([119]); +struct_construct>>([119], [118]) -> ([120]); +enum_init,)>, 1>([120]) -> ([121]); +store_temp([0]) -> ([122]); +store_temp([16]) -> ([123]); +store_temp([6]) -> ([124]); +store_temp([3]) -> ([125]); +store_temp,)>>([121]) -> ([126]); +return([122], [123], [124], [125], [126]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([127]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([128]); +store_temp([128]) -> ([128]); +array_append([127], [128]) -> ([129]); +struct_construct() -> ([130]); +struct_construct>>([130], [129]) -> ([131]); +enum_init,)>, 1>([131]) -> ([132]); +store_temp([0]) -> ([133]); +store_temp([9]) -> ([134]); +store_temp([6]) -> ([135]); +store_temp([3]) -> ([136]); +store_temp,)>>([132]) -> ([137]); +return([133], [134], [135], [136], [137]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([138]); +felt252_const<375233589013918064796019>() -> ([139]); +store_temp([139]) -> ([139]); +array_append([138], [139]) -> ([140]); +struct_construct() -> ([141]); +struct_construct>>([141], [140]) -> ([142]); +enum_init,)>, 1>([142]) -> ([143]); +store_temp([0]) -> ([144]); +store_temp([7]) -> ([145]); +store_temp([8]) -> ([146]); +store_temp([3]) -> ([147]); +store_temp,)>>([143]) -> ([148]); +return([144], [145], [146], [147], [148]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1141([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1125([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 1108([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 1049() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1092([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 1084([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1288([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1272([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 1255([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 1196() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1239([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 1231([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1435([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1419([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 1402([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 1343() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1386([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 1378([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1662([7], [8]) }; +branch_align() -> (); +store_temp>([4]) -> ([11]); +function_call([11]) -> ([9], [10]); +store_temp([5]) -> ([5]); +enum_match>([10]) { fallthrough([12]) 1646([13]) }; +branch_align() -> (); +store_temp>([9]) -> ([16]); +function_call([16]) -> ([14], [15]); +enum_match>([15]) { fallthrough([17]) 1629([18]) }; +branch_align() -> (); +store_temp([5]) -> ([22]); +store_temp>([14]) -> ([23]); +function_call([22], [23]) -> ([19], [20], [21]); +enum_match>([21]) { fallthrough([24]) 1611([25]) }; +branch_align() -> (); +store_temp([19]) -> ([29]); +store_temp>([20]) -> ([30]); +function_call([29], [30]) -> ([26], [27], [28]); +enum_match>([28]) { fallthrough([31]) 1592([32]) }; +branch_align() -> (); +store_temp([26]) -> ([36]); +store_temp>([27]) -> ([37]); +function_call([36], [37]) -> ([33], [34], [35]); +enum_match>([35]) { fallthrough([38]) 1572([39]) }; +branch_align() -> (); +struct_deconstruct>([34]) -> ([40]); +array_len([40]) -> ([41]); +snapshot_take([41]) -> ([42], [43]); +drop([42]) -> (); +u32_const<0>() -> ([44]); +snapshot_take([44]) -> ([45], [46]); +drop([45]) -> (); +rename([43]) -> ([47]); +rename([46]) -> ([48]); +store_temp([47]) -> ([47]); +u32_eq([47], [48]) { fallthrough() 1507() }; +branch_align() -> (); +drop([38]) -> (); +drop([31]) -> (); +drop([24]) -> (); +drop([17]) -> (); +drop([12]) -> (); +array_new() -> ([49]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([50]); +store_temp([50]) -> ([50]); +array_append([49], [50]) -> ([51]); +struct_construct() -> ([52]); +struct_construct>>([52], [51]) -> ([53]); +enum_init,)>, 1>([53]) -> ([54]); +store_temp([0]) -> ([55]); +store_temp([33]) -> ([56]); +store_temp([6]) -> ([57]); +store_temp([3]) -> ([58]); +store_temp,)>>([54]) -> ([59]); +return([55], [56], [57], [58], [59]); +branch_align() -> (); +get_builtin_costs() -> ([60]); +store_temp([60]) -> ([60]); +withdraw_gas_all([33], [6], [60]) { fallthrough([61], [62]) 1553([63], [64]) }; +branch_align() -> (); +struct_construct() -> ([65]); +struct_construct() -> ([66]); +struct_construct() -> ([67]); +struct_construct() -> ([68]); +struct_construct() -> ([69]); +struct_construct() -> ([70]); +struct_construct([65], [66], [67], [68], [69], [70]) -> ([71]); +store_temp([61]) -> ([77]); +store_temp([62]) -> ([78]); +store_temp([0]) -> ([79]); +store_temp([3]) -> ([80]); +store_temp([71]) -> ([81]); +store_temp([12]) -> ([82]); +store_temp([17]) -> ([83]); +store_temp([24]) -> ([84]); +store_temp([31]) -> ([85]); +store_temp([38]) -> ([86]); +function_call([77], [78], [79], [80], [81], [82], [83], [84], [85], [86]) -> ([72], [73], [74], [75], [76]); +enum_match>([76]) { fallthrough([87]) 1545([88]) }; +branch_align() -> (); +drop>([87]) -> (); +array_new() -> ([89]); +snapshot_take>([89]) -> ([90], [91]); +drop>([90]) -> (); +struct_construct>([91]) -> ([92]); +struct_construct>>([92]) -> ([93]); +enum_init,)>, 0>([93]) -> ([94]); +store_temp([74]) -> ([95]); +store_temp([72]) -> ([96]); +store_temp([73]) -> ([97]); +store_temp([75]) -> ([98]); +store_temp,)>>([94]) -> ([99]); +return([95], [96], [97], [98], [99]); +branch_align() -> (); +enum_init,)>, 1>([88]) -> ([100]); +store_temp([74]) -> ([101]); +store_temp([72]) -> ([102]); +store_temp([73]) -> ([103]); +store_temp([75]) -> ([104]); +store_temp,)>>([100]) -> ([105]); +return([101], [102], [103], [104], [105]); +branch_align() -> (); +drop([38]) -> (); +drop([31]) -> (); +drop([24]) -> (); +drop([17]) -> (); +drop([12]) -> (); +array_new() -> ([106]); +felt252_const<375233589013918064796019>() -> ([107]); +store_temp([107]) -> ([107]); +array_append([106], [107]) -> ([108]); +struct_construct() -> ([109]); +struct_construct>>([109], [108]) -> ([110]); +enum_init,)>, 1>([110]) -> ([111]); +store_temp([0]) -> ([112]); +store_temp([63]) -> ([113]); +store_temp([64]) -> ([114]); +store_temp([3]) -> ([115]); +store_temp,)>>([111]) -> ([116]); +return([112], [113], [114], [115], [116]); +branch_align() -> (); +drop([39]) -> (); +drop>([34]) -> (); +drop([31]) -> (); +drop([24]) -> (); +drop([17]) -> (); +drop([12]) -> (); +array_new() -> ([117]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917>() -> ([118]); +store_temp([118]) -> ([118]); +array_append([117], [118]) -> ([119]); +struct_construct() -> ([120]); +struct_construct>>([120], [119]) -> ([121]); +enum_init,)>, 1>([121]) -> ([122]); +store_temp([0]) -> ([123]); +store_temp([33]) -> ([124]); +store_temp([6]) -> ([125]); +store_temp([3]) -> ([126]); +store_temp,)>>([122]) -> ([127]); +return([123], [124], [125], [126], [127]); +branch_align() -> (); +drop([32]) -> (); +drop([17]) -> (); +drop([12]) -> (); +drop([24]) -> (); +drop>([27]) -> (); +array_new() -> ([128]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916>() -> ([129]); +store_temp([129]) -> ([129]); +array_append([128], [129]) -> ([130]); +struct_construct() -> ([131]); +struct_construct>>([131], [130]) -> ([132]); +enum_init,)>, 1>([132]) -> ([133]); +store_temp([0]) -> ([134]); +store_temp([26]) -> ([135]); +store_temp([6]) -> ([136]); +store_temp([3]) -> ([137]); +store_temp,)>>([133]) -> ([138]); +return([134], [135], [136], [137], [138]); +branch_align() -> (); +drop([25]) -> (); +drop([17]) -> (); +drop([12]) -> (); +drop>([20]) -> (); +array_new() -> ([139]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>() -> ([140]); +store_temp([140]) -> ([140]); +array_append([139], [140]) -> ([141]); +struct_construct() -> ([142]); +struct_construct>>([142], [141]) -> ([143]); +enum_init,)>, 1>([143]) -> ([144]); +store_temp([0]) -> ([145]); +store_temp([19]) -> ([146]); +store_temp([6]) -> ([147]); +store_temp([3]) -> ([148]); +store_temp,)>>([144]) -> ([149]); +return([145], [146], [147], [148], [149]); +branch_align() -> (); +drop([18]) -> (); +drop([12]) -> (); +drop>([14]) -> (); +array_new() -> ([150]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([151]); +store_temp([151]) -> ([151]); +array_append([150], [151]) -> ([152]); +struct_construct() -> ([153]); +struct_construct>>([153], [152]) -> ([154]); +enum_init,)>, 1>([154]) -> ([155]); +store_temp([0]) -> ([156]); +store_temp([5]) -> ([157]); +store_temp([6]) -> ([158]); +store_temp([3]) -> ([159]); +store_temp,)>>([155]) -> ([160]); +return([156], [157], [158], [159], [160]); +branch_align() -> (); +drop([13]) -> (); +drop>([9]) -> (); +array_new() -> ([161]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([162]); +store_temp([162]) -> ([162]); +array_append([161], [162]) -> ([163]); +struct_construct() -> ([164]); +struct_construct>>([164], [163]) -> ([165]); +enum_init,)>, 1>([165]) -> ([166]); +store_temp([0]) -> ([167]); +store_temp([5]) -> ([168]); +store_temp([6]) -> ([169]); +store_temp([3]) -> ([170]); +store_temp,)>>([166]) -> ([171]); +return([167], [168], [169], [170], [171]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([172]); +felt252_const<375233589013918064796019>() -> ([173]); +store_temp([173]) -> ([173]); +array_append([172], [173]) -> ([174]); +struct_construct() -> ([175]); +struct_construct>>([175], [174]) -> ([176]); +enum_init,)>, 1>([176]) -> ([177]); +store_temp([0]) -> ([178]); +store_temp([7]) -> ([179]); +store_temp([8]) -> ([180]); +store_temp([3]) -> ([181]); +store_temp,)>>([177]) -> ([182]); +return([178], [179], [180], [181], [182]); +struct_deconstruct([2]) -> ([3], [4], [5], [6], [7], [8]); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +drop([7]) -> (); +drop([8]) -> (); +store_temp([0]) -> ([12]); +store_temp([1]) -> ([13]); +store_temp([3]) -> ([14]); +function_call([12], [13], [14]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([15]) 1696([16]) }; +branch_align() -> (); +struct_deconstruct>([15]) -> ([17]); +struct_construct>([17]) -> ([18]); +enum_init, 0>([18]) -> ([19]); +store_temp([9]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp>([19]) -> ([22]); +return([20], [21], [22]); +branch_align() -> (); +enum_init, 1>([16]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([10]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +rename([0]) -> ([2]); +array_append([1], [2]) -> ([3]); +struct_construct() -> ([4]); +store_temp>([3]) -> ([5]); +store_temp([4]) -> ([6]); +return([5], [6]); +struct_deconstruct([2]) -> ([3], [4], [5], [6], [7], [8]); +drop([3]) -> (); +drop([5]) -> (); +drop([6]) -> (); +drop([7]) -> (); +drop([8]) -> (); +store_temp([0]) -> ([12]); +store_temp([1]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([12], [13], [14]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([15]) 1727([16]) }; +branch_align() -> (); +struct_deconstruct>([15]) -> ([17]); +struct_construct>([17]) -> ([18]); +enum_init, 0>([18]) -> ([19]); +store_temp([9]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp>([19]) -> ([22]); +return([20], [21], [22]); +branch_align() -> (); +enum_init, 1>([16]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([10]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +struct_deconstruct([3]) -> ([4], [5], [6], [7], [8], [9]); +drop([4]) -> (); +drop([5]) -> (); +drop([7]) -> (); +drop([8]) -> (); +drop([9]) -> (); +store_temp([0]) -> ([14]); +store_temp([1]) -> ([15]); +store_temp([2]) -> ([16]); +store_temp([6]) -> ([17]); +function_call([14], [15], [16], [17]) -> ([10], [11], [12], [13]); +enum_match>([13]) { fallthrough([18]) 1754([19]) }; +branch_align() -> (); +struct_deconstruct>([18]) -> ([20]); +struct_construct>([20]) -> ([21]); +enum_init, 0>([21]) -> ([22]); +store_temp([10]) -> ([23]); +store_temp([11]) -> ([24]); +store_temp([12]) -> ([25]); +store_temp>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +enum_init, 1>([19]) -> ([27]); +store_temp([10]) -> ([28]); +store_temp([11]) -> ([29]); +store_temp([12]) -> ([30]); +store_temp>([27]) -> ([31]); +return([28], [29], [30], [31]); +rename([0]) -> ([2]); +u8_to_felt252([2]) -> ([3]); +snapshot_take([3]) -> ([4], [5]); +drop([4]) -> (); +store_temp([5]) -> ([8]); +store_temp>([1]) -> ([9]); +function_call([8], [9]) -> ([6], [7]); +drop([7]) -> (); +struct_construct() -> ([10]); +store_temp>([6]) -> ([11]); +store_temp([10]) -> ([12]); +return([11], [12]); +struct_deconstruct([3]) -> ([4], [5], [6], [7], [8], [9]); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +drop([8]) -> (); +drop([9]) -> (); +store_temp([0]) -> ([14]); +store_temp([1]) -> ([15]); +store_temp([2]) -> ([16]); +store_temp([7]) -> ([17]); +function_call([14], [15], [16], [17]) -> ([10], [11], [12], [13]); +enum_match>([13]) { fallthrough([18]) 1794([19]) }; +branch_align() -> (); +struct_deconstruct>([18]) -> ([20]); +struct_construct>([20]) -> ([21]); +enum_init, 0>([21]) -> ([22]); +store_temp([10]) -> ([23]); +store_temp([11]) -> ([24]); +store_temp([12]) -> ([25]); +store_temp>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +enum_init, 1>([19]) -> ([27]); +store_temp([10]) -> ([28]); +store_temp([11]) -> ([29]); +store_temp([12]) -> ([30]); +store_temp>([27]) -> ([31]); +return([28], [29], [30], [31]); +dup([0]) -> ([0], [2]); +struct_deconstruct([2]) -> ([3], [4]); +drop([4]) -> (); +store_temp([3]) -> ([7]); +store_temp>([1]) -> ([8]); +function_call([7], [8]) -> ([5], [6]); +drop([6]) -> (); +struct_deconstruct([0]) -> ([9], [10]); +drop([9]) -> (); +store_temp([10]) -> ([13]); +store_temp>([5]) -> ([14]); +function_call([13], [14]) -> ([11], [12]); +rename>([11]) -> ([15]); +rename([12]) -> ([16]); +return([15], [16]); +store_temp>([1]) -> ([4]); +function_call([4]) -> ([2], [3]); +enum_match>([3]) { fallthrough([5]) 1834([6]) }; +branch_align() -> (); +contract_address_try_from_felt252([0], [5]) { fallthrough([7], [8]) 1827([9]) }; +branch_align() -> (); +enum_init, 0>([8]) -> ([10]); +store_temp([7]) -> ([11]); +store_temp>([2]) -> ([12]); +store_temp>([10]) -> ([13]); +return([11], [12], [13]); +branch_align() -> (); +struct_construct() -> ([14]); +enum_init, 1>([14]) -> ([15]); +store_temp([9]) -> ([16]); +store_temp>([2]) -> ([17]); +store_temp>([15]) -> ([18]); +return([16], [17], [18]); +branch_align() -> (); +enum_init, 1>([6]) -> ([19]); +store_temp([0]) -> ([20]); +store_temp>([2]) -> ([21]); +store_temp>([19]) -> ([22]); +return([20], [21], [22]); +struct_deconstruct([4]) -> ([6], [7], [8], [9], [10], [11]); +drop([6]) -> (); +drop([7]) -> (); +drop([8]) -> (); +drop([9]) -> (); +drop([11]) -> (); +store_temp([0]) -> ([17]); +store_temp([1]) -> ([18]); +store_temp([2]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp([5]) -> ([22]); +function_call([17], [18], [19], [20], [21], [22]) -> ([12], [13], [14], [15], [16]); +enum_match>([16]) { fallthrough([23]) 1864([24]) }; +branch_align() -> (); +struct_deconstruct>([23]) -> ([25]); +struct_construct>([25]) -> ([26]); +enum_init, 0>([26]) -> ([27]); +store_temp([12]) -> ([28]); +store_temp([13]) -> ([29]); +store_temp([14]) -> ([30]); +store_temp([15]) -> ([31]); +store_temp>([27]) -> ([32]); +return([28], [29], [30], [31], [32]); +branch_align() -> (); +enum_init, 1>([24]) -> ([33]); +store_temp([12]) -> ([34]); +store_temp([13]) -> ([35]); +store_temp([14]) -> ([36]); +store_temp([15]) -> ([37]); +store_temp>([33]) -> ([38]); +return([34], [35], [36], [37], [38]); +struct_deconstruct([4]) -> ([7], [8], [9], [10], [11], [12]); +drop([7]) -> (); +drop([8]) -> (); +drop([9]) -> (); +drop([10]) -> (); +drop([11]) -> (); +struct_construct>([5], [6]) -> ([13]); +store_temp([0]) -> ([19]); +store_temp([1]) -> ([20]); +store_temp([2]) -> ([21]); +store_temp([3]) -> ([22]); +store_temp([12]) -> ([23]); +store_temp>([13]) -> ([24]); +function_call([19], [20], [21], [22], [23], [24]) -> ([14], [15], [16], [17], [18]); +enum_match>([18]) { fallthrough([25]) 1897([26]) }; +branch_align() -> (); +struct_deconstruct>([25]) -> ([27]); +struct_construct>([27]) -> ([28]); +enum_init, 0>([28]) -> ([29]); +store_temp([14]) -> ([30]); +store_temp([15]) -> ([31]); +store_temp([16]) -> ([32]); +store_temp([17]) -> ([33]); +store_temp>([29]) -> ([34]); +return([30], [31], [32], [33], [34]); +branch_align() -> (); +enum_init, 1>([26]) -> ([35]); +store_temp([14]) -> ([36]); +store_temp([15]) -> ([37]); +store_temp([16]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp>([35]) -> ([40]); +return([36], [37], [38], [39], [40]); +store_temp([0]) -> ([5]); +store_temp>([1]) -> ([6]); +function_call([5], [6]) -> ([2], [3], [4]); +enum_match>([4]) { fallthrough([7]) 1928([8]) }; +branch_align() -> (); +store_temp([2]) -> ([12]); +store_temp>([3]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1921([15]) }; +branch_align() -> (); +struct_construct([7], [14]) -> ([16]); +enum_init, 0>([16]) -> ([17]); +store_temp([9]) -> ([18]); +store_temp>([10]) -> ([19]); +store_temp>([17]) -> ([20]); +return([18], [19], [20]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([15]) -> ([21]); +store_temp([9]) -> ([22]); +store_temp>([10]) -> ([23]); +store_temp>([21]) -> ([24]); +return([22], [23], [24]); +branch_align() -> (); +enum_init, 1>([8]) -> ([25]); +store_temp([2]) -> ([26]); +store_temp>([3]) -> ([27]); +store_temp>([25]) -> ([28]); +return([26], [27], [28]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 1970([13]) }; +branch_align() -> (); +struct_deconstruct>([12]) -> ([14]); +store_temp([0]) -> ([20]); +store_temp([7]) -> ([21]); +store_temp([2]) -> ([22]); +store_temp([8]) -> ([23]); +store_temp([4]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp([5]) -> ([26]); +store_temp([6]) -> ([27]); +function_call([20], [21], [22], [23], [24], [25], [26], [27]) -> ([15], [16], [17], [18], [19]); +enum_match>([19]) { fallthrough([28]) 1962([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30], [31]); +drop([31]) -> (); +struct_construct() -> ([32]); +struct_construct>([30], [32]) -> ([33]); +enum_init, 0>([33]) -> ([34]); +store_temp([15]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp([17]) -> ([37]); +store_temp([18]) -> ([38]); +store_temp>([34]) -> ([39]); +return([35], [36], [37], [38], [39]); +branch_align() -> (); +enum_init, 1>([29]) -> ([40]); +store_temp([15]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp([17]) -> ([43]); +store_temp([18]) -> ([44]); +store_temp>([40]) -> ([45]); +return([41], [42], [43], [44], [45]); +branch_align() -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +enum_init, 1>([13]) -> ([46]); +store_temp([0]) -> ([47]); +store_temp([7]) -> ([48]); +store_temp([2]) -> ([49]); +store_temp([8]) -> ([50]); +store_temp>([46]) -> ([51]); +return([47], [48], [49], [50], [51]); +store_temp([1]) -> ([11]); +store_temp([3]) -> ([12]); +function_call([11], [12]) -> ([8], [9], [10]); +enum_match>([10]) { fallthrough([13]) 2043([14]) }; +branch_align() -> (); +struct_deconstruct>([13]) -> ([15]); +store_temp([0]) -> ([21]); +store_temp([8]) -> ([22]); +store_temp([2]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([4]) -> ([25]); +dup([5]) -> ([5], [26]); +store_temp([26]) -> ([26]); +store_temp([15]) -> ([27]); +dup([7]) -> ([7], [28]); +store_temp([28]) -> ([28]); +function_call([21], [22], [23], [24], [25], [26], [27], [28]) -> ([16], [17], [18], [19], [20]); +enum_match>([20]) { fallthrough([29]) 2032([30]) }; +branch_align() -> (); +struct_deconstruct>([29]) -> ([31], [32]); +drop([32]) -> (); +store_temp([16]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp([18]) -> ([40]); +store_temp([19]) -> ([41]); +store_temp([31]) -> ([42]); +store_temp([5]) -> ([43]); +store_temp([6]) -> ([44]); +store_temp([7]) -> ([45]); +function_call([38], [39], [40], [41], [42], [43], [44], [45]) -> ([33], [34], [35], [36], [37]); +enum_match>([37]) { fallthrough([46]) 2024([47]) }; +branch_align() -> (); +struct_deconstruct>([46]) -> ([48], [49]); +drop([49]) -> (); +struct_construct() -> ([50]); +struct_construct>([48], [50]) -> ([51]); +enum_init, 0>([51]) -> ([52]); +store_temp([33]) -> ([53]); +store_temp([34]) -> ([54]); +store_temp([35]) -> ([55]); +store_temp([36]) -> ([56]); +store_temp>([52]) -> ([57]); +return([53], [54], [55], [56], [57]); +branch_align() -> (); +enum_init, 1>([47]) -> ([58]); +store_temp([33]) -> ([59]); +store_temp([34]) -> ([60]); +store_temp([35]) -> ([61]); +store_temp([36]) -> ([62]); +store_temp>([58]) -> ([63]); +return([59], [60], [61], [62], [63]); +branch_align() -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +enum_init, 1>([30]) -> ([64]); +store_temp([16]) -> ([65]); +store_temp([17]) -> ([66]); +store_temp([18]) -> ([67]); +store_temp([19]) -> ([68]); +store_temp>([64]) -> ([69]); +return([65], [66], [67], [68], [69]); +branch_align() -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +enum_init, 1>([14]) -> ([70]); +store_temp([0]) -> ([71]); +store_temp([8]) -> ([72]); +store_temp([2]) -> ([73]); +store_temp([9]) -> ([74]); +store_temp>([70]) -> ([75]); +return([71], [72], [73], [74], [75]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 2091([13]) }; +branch_align() -> (); +struct_deconstruct>([12]) -> ([14]); +store_temp([0]) -> ([20]); +store_temp([7]) -> ([21]); +store_temp([2]) -> ([22]); +store_temp([8]) -> ([23]); +store_temp([4]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp([5]) -> ([26]); +store_temp([6]) -> ([27]); +function_call([20], [21], [22], [23], [24], [25], [26], [27]) -> ([15], [16], [17], [18], [19]); +enum_match>([19]) { fallthrough([28]) 2083([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30], [31]); +drop([31]) -> (); +struct_construct() -> ([32]); +struct_construct>([30], [32]) -> ([33]); +enum_init, 0>([33]) -> ([34]); +store_temp([15]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp([17]) -> ([37]); +store_temp([18]) -> ([38]); +store_temp>([34]) -> ([39]); +return([35], [36], [37], [38], [39]); +branch_align() -> (); +enum_init, 1>([29]) -> ([40]); +store_temp([15]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp([17]) -> ([43]); +store_temp([18]) -> ([44]); +store_temp>([40]) -> ([45]); +return([41], [42], [43], [44], [45]); +branch_align() -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +enum_init, 1>([13]) -> ([46]); +store_temp([0]) -> ([47]); +store_temp([7]) -> ([48]); +store_temp([2]) -> ([49]); +store_temp([8]) -> ([50]); +store_temp>([46]) -> ([51]); +return([47], [48], [49], [50], [51]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 2194([13]) }; +branch_align() -> (); +struct_deconstruct([4]) -> ([14], [15], [16], [17], [18], [19]); +snapshot_take([19]) -> ([20], [21]); +struct_deconstruct>([12]) -> ([22]); +dup([22]) -> ([22], [23]); +dup([5]) -> ([5], [24]); +struct_construct>([23], [24]) -> ([25]); +store_temp([0]) -> ([31]); +store_temp([7]) -> ([32]); +store_temp([2]) -> ([33]); +store_temp([8]) -> ([34]); +store_temp([21]) -> ([35]); +store_temp>([25]) -> ([36]); +function_call([31], [32], [33], [34], [35], [36]) -> ([26], [27], [28], [29], [30]); +enum_match>([30]) { fallthrough([37]) 2177([38]) }; +branch_align() -> (); +struct_deconstruct>([37]) -> ([39]); +store_temp([26]) -> ([42]); +store_temp([39]) -> ([43]); +store_temp([6]) -> ([44]); +function_call([42], [43], [44]) -> ([40], [41]); +enum_match>([41]) { fallthrough([45]) 2161([46]) }; +branch_align() -> (); +struct_deconstruct>([45]) -> ([47]); +struct_construct([14], [15], [16], [17], [18], [20]) -> ([48]); +store_temp([40]) -> ([54]); +store_temp([27]) -> ([55]); +store_temp([28]) -> ([56]); +store_temp([29]) -> ([57]); +store_temp([48]) -> ([58]); +store_temp([22]) -> ([59]); +store_temp([5]) -> ([60]); +store_temp([47]) -> ([61]); +function_call([54], [55], [56], [57], [58], [59], [60], [61]) -> ([49], [50], [51], [52], [53]); +enum_match>([53]) { fallthrough([62]) 2153([63]) }; +branch_align() -> (); +struct_deconstruct>([62]) -> ([64], [65]); +drop([65]) -> (); +struct_construct() -> ([66]); +struct_construct>([64], [66]) -> ([67]); +enum_init, 0>([67]) -> ([68]); +store_temp([49]) -> ([69]); +store_temp([50]) -> ([70]); +store_temp([51]) -> ([71]); +store_temp([52]) -> ([72]); +store_temp>([68]) -> ([73]); +return([69], [70], [71], [72], [73]); +branch_align() -> (); +enum_init, 1>([63]) -> ([74]); +store_temp([49]) -> ([75]); +store_temp([50]) -> ([76]); +store_temp([51]) -> ([77]); +store_temp([52]) -> ([78]); +store_temp>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([15]) -> (); +enum_init, 1>([46]) -> ([80]); +store_temp([40]) -> ([81]); +store_temp([27]) -> ([82]); +store_temp([28]) -> ([83]); +store_temp([29]) -> ([84]); +store_temp>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([15]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([6]) -> (); +enum_init, 1>([38]) -> ([86]); +store_temp([26]) -> ([87]); +store_temp([27]) -> ([88]); +store_temp([28]) -> ([89]); +store_temp([29]) -> ([90]); +store_temp>([86]) -> ([91]); +return([87], [88], [89], [90], [91]); +branch_align() -> (); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +enum_init, 1>([13]) -> ([92]); +store_temp([0]) -> ([93]); +store_temp([7]) -> ([94]); +store_temp([2]) -> ([95]); +store_temp([8]) -> ([96]); +store_temp>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 2297([13]) }; +branch_align() -> (); +struct_deconstruct([4]) -> ([14], [15], [16], [17], [18], [19]); +snapshot_take([19]) -> ([20], [21]); +struct_deconstruct>([12]) -> ([22]); +dup([22]) -> ([22], [23]); +dup([5]) -> ([5], [24]); +struct_construct>([23], [24]) -> ([25]); +store_temp([0]) -> ([31]); +store_temp([7]) -> ([32]); +store_temp([2]) -> ([33]); +store_temp([8]) -> ([34]); +store_temp([21]) -> ([35]); +store_temp>([25]) -> ([36]); +function_call([31], [32], [33], [34], [35], [36]) -> ([26], [27], [28], [29], [30]); +enum_match>([30]) { fallthrough([37]) 2280([38]) }; +branch_align() -> (); +struct_deconstruct>([37]) -> ([39]); +store_temp([26]) -> ([42]); +store_temp([39]) -> ([43]); +store_temp([6]) -> ([44]); +function_call([42], [43], [44]) -> ([40], [41]); +enum_match>([41]) { fallthrough([45]) 2264([46]) }; +branch_align() -> (); +struct_deconstruct>([45]) -> ([47]); +struct_construct([14], [15], [16], [17], [18], [20]) -> ([48]); +store_temp([40]) -> ([54]); +store_temp([27]) -> ([55]); +store_temp([28]) -> ([56]); +store_temp([29]) -> ([57]); +store_temp([48]) -> ([58]); +store_temp([22]) -> ([59]); +store_temp([5]) -> ([60]); +store_temp([47]) -> ([61]); +function_call([54], [55], [56], [57], [58], [59], [60], [61]) -> ([49], [50], [51], [52], [53]); +enum_match>([53]) { fallthrough([62]) 2256([63]) }; +branch_align() -> (); +struct_deconstruct>([62]) -> ([64], [65]); +drop([65]) -> (); +struct_construct() -> ([66]); +struct_construct>([64], [66]) -> ([67]); +enum_init, 0>([67]) -> ([68]); +store_temp([49]) -> ([69]); +store_temp([50]) -> ([70]); +store_temp([51]) -> ([71]); +store_temp([52]) -> ([72]); +store_temp>([68]) -> ([73]); +return([69], [70], [71], [72], [73]); +branch_align() -> (); +enum_init, 1>([63]) -> ([74]); +store_temp([49]) -> ([75]); +store_temp([50]) -> ([76]); +store_temp([51]) -> ([77]); +store_temp([52]) -> ([78]); +store_temp>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([15]) -> (); +enum_init, 1>([46]) -> ([80]); +store_temp([40]) -> ([81]); +store_temp([27]) -> ([82]); +store_temp([28]) -> ([83]); +store_temp([29]) -> ([84]); +store_temp>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([15]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([6]) -> (); +enum_init, 1>([38]) -> ([86]); +store_temp([26]) -> ([87]); +store_temp([27]) -> ([88]); +store_temp([28]) -> ([89]); +store_temp([29]) -> ([90]); +store_temp>([86]) -> ([91]); +return([87], [88], [89], [90], [91]); +branch_align() -> (); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +enum_init, 1>([13]) -> ([92]); +store_temp([0]) -> ([93]); +store_temp([7]) -> ([94]); +store_temp([2]) -> ([95]); +store_temp([8]) -> ([96]); +store_temp>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +struct_deconstruct>([0]) -> ([1]); +array_snapshot_pop_front([1]) { fallthrough([2], [3]) 2315([4]) }; +branch_align() -> (); +enum_init>, 0>([3]) -> ([5]); +store_temp>>([2]) -> ([6]); +store_temp>>([5]) -> ([7]); +jump() { 2320() }; +branch_align() -> (); +struct_construct() -> ([8]); +enum_init>, 1>([8]) -> ([9]); +store_temp>>([4]) -> ([6]); +store_temp>>([9]) -> ([7]); +struct_construct>([6]) -> ([10]); +store_temp>([10]) -> ([10]); +enum_match>>([7]) { fallthrough([11]) 2330([12]) }; +branch_align() -> (); +unbox([11]) -> ([13]); +rename([13]) -> ([14]); +enum_init, 0>([14]) -> ([15]); +store_temp>([10]) -> ([16]); +store_temp>([15]) -> ([17]); +return([16], [17]); +branch_align() -> (); +drop([12]) -> (); +struct_construct() -> ([18]); +enum_init, 1>([18]) -> ([19]); +store_temp>([10]) -> ([20]); +store_temp>([19]) -> ([21]); +return([20], [21]); +struct_deconstruct>([1]) -> ([2]); +array_snapshot_pop_front([2]) { fallthrough([3], [4]) 2344([5]) }; +branch_align() -> (); +enum_init>, 0>([4]) -> ([6]); +store_temp>>([3]) -> ([7]); +store_temp>>([6]) -> ([8]); +jump() { 2349() }; +branch_align() -> (); +struct_construct() -> ([9]); +enum_init>, 1>([9]) -> ([10]); +store_temp>>([5]) -> ([7]); +store_temp>>([10]) -> ([8]); +struct_construct>([7]) -> ([11]); +store_temp>([11]) -> ([11]); +enum_match>>([8]) { fallthrough([12]) 2371([13]) }; +branch_align() -> (); +unbox([12]) -> ([14]); +rename([14]) -> ([15]); +store_temp([0]) -> ([18]); +store_temp([15]) -> ([19]); +function_call([18], [19]) -> ([16], [17]); +enum_match>([17]) { fallthrough([20]) 2365([21]) }; +branch_align() -> (); +enum_init, 0>([20]) -> ([22]); +store_temp([16]) -> ([23]); +store_temp>([11]) -> ([24]); +store_temp>([22]) -> ([25]); +return([23], [24], [25]); +branch_align() -> (); +enum_init, 1>([21]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp>([11]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([13]) -> (); +struct_construct() -> ([30]); +enum_init, 1>([30]) -> ([31]); +store_temp([0]) -> ([32]); +store_temp>([11]) -> ([33]); +store_temp>([31]) -> ([34]); +return([32], [33], [34]); +struct_deconstruct([4]) -> ([10], [11], [12], [13], [14], [15]); +store_temp([1]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp([5]) -> ([22]); +function_call([19], [20], [21], [22]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([23]) 2572([24]) }; +branch_align() -> (); +store_temp([16]) -> ([28]); +store_temp([17]) -> ([29]); +store_temp([11]) -> ([30]); +store_temp([6]) -> ([31]); +function_call([28], [29], [30], [31]) -> ([25], [26], [27]); +enum_match>([27]) { fallthrough([32]) 2556([33]) }; +branch_align() -> (); +store_temp([25]) -> ([37]); +store_temp([26]) -> ([38]); +store_temp([12]) -> ([39]); +store_temp([7]) -> ([40]); +function_call([37], [38], [39], [40]) -> ([34], [35], [36]); +enum_match>([36]) { fallthrough([41]) 2541([42]) }; +branch_align() -> (); +dup([9]) -> ([9], [44]); +contract_address_to_felt252([44]) -> ([43]); +snapshot_take([43]) -> ([45], [46]); +drop([45]) -> (); +felt252_const<0>() -> ([47]); +snapshot_take([47]) -> ([48], [49]); +drop([48]) -> (); +rename([46]) -> ([50]); +rename([49]) -> ([51]); +felt252_sub([50], [51]) -> ([52]); +struct_deconstruct>([23]) -> ([53], [54]); +drop([54]) -> (); +struct_deconstruct>([32]) -> ([55], [56]); +drop([56]) -> (); +struct_deconstruct>([41]) -> ([57], [58]); +drop([58]) -> (); +store_temp([52]) -> ([52]); +felt252_is_zero([52]) { fallthrough() 2424([59]) }; +branch_align() -> (); +struct_construct() -> ([60]); +enum_init([60]) -> ([61]); +store_temp([61]) -> ([62]); +jump() { 2429() }; +branch_align() -> (); +drop>([59]) -> (); +struct_construct() -> ([63]); +enum_init([63]) -> ([64]); +store_temp([64]) -> ([62]); +bool_not_impl([62]) -> ([65]); +store_temp([65]) -> ([65]); +enum_match([65]) { fallthrough([66]) 2455([67]) }; +branch_align() -> (); +drop([66]) -> (); +drop([9]) -> (); +drop([55]) -> (); +drop([53]) -> (); +drop([8]) -> (); +drop([57]) -> (); +drop([15]) -> (); +drop([14]) -> (); +drop([13]) -> (); +array_new() -> ([68]); +felt252_const<7300388948442106731950660484798539862217172507820428101544021685107>() -> ([69]); +store_temp([69]) -> ([69]); +array_append([68], [69]) -> ([70]); +struct_construct() -> ([71]); +struct_construct>>([71], [70]) -> ([72]); +enum_init, 1>([72]) -> ([73]); +store_temp([0]) -> ([74]); +store_temp([34]) -> ([75]); +store_temp([2]) -> ([76]); +store_temp([35]) -> ([77]); +store_temp>([73]) -> ([78]); +return([74], [75], [76], [77], [78]); +branch_align() -> (); +drop([67]) -> (); +store_temp([34]) -> ([82]); +store_temp([35]) -> ([83]); +store_temp([13]) -> ([84]); +dup([8]) -> ([8], [85]); +store_temp([85]) -> ([85]); +function_call([82], [83], [84], [85]) -> ([79], [80], [81]); +enum_match>([81]) { fallthrough([86]) 2526([87]) }; +branch_align() -> (); +store_temp([0]) -> ([93]); +store_temp([79]) -> ([94]); +store_temp([2]) -> ([95]); +store_temp([80]) -> ([96]); +store_temp([14]) -> ([97]); +dup([9]) -> ([9], [98]); +store_temp([98]) -> ([98]); +dup([8]) -> ([8], [99]); +store_temp([99]) -> ([99]); +function_call([93], [94], [95], [96], [97], [98], [99]) -> ([88], [89], [90], [91], [92]); +enum_match>([92]) { fallthrough([100]) 2511([101]) }; +branch_align() -> (); +contract_address_const<0>() -> ([102]); +struct_deconstruct>([86]) -> ([103], [104]); +drop([104]) -> (); +struct_deconstruct>([100]) -> ([105], [106]); +drop([106]) -> (); +struct_construct([102], [9], [8]) -> ([107]); +enum_init([107]) -> ([108]); +struct_construct([53], [55], [57], [103], [105], [15]) -> ([109]); +store_temp([89]) -> ([113]); +store_temp([91]) -> ([114]); +store_temp([109]) -> ([115]); +store_temp([108]) -> ([116]); +function_call>>([113], [114], [115], [116]) -> ([110], [111], [112]); +enum_match>([112]) { fallthrough([117]) 2503([118]) }; +branch_align() -> (); +struct_deconstruct>([117]) -> ([119], [120]); +drop([120]) -> (); +struct_construct() -> ([121]); +struct_construct>([119], [121]) -> ([122]); +enum_init, 0>([122]) -> ([123]); +store_temp([88]) -> ([124]); +store_temp([110]) -> ([125]); +store_temp([90]) -> ([126]); +store_temp([111]) -> ([127]); +store_temp>([123]) -> ([128]); +return([124], [125], [126], [127], [128]); +branch_align() -> (); +enum_init, 1>([118]) -> ([129]); +store_temp([88]) -> ([130]); +store_temp([110]) -> ([131]); +store_temp([90]) -> ([132]); +store_temp([111]) -> ([133]); +store_temp>([129]) -> ([134]); +return([130], [131], [132], [133], [134]); +branch_align() -> (); +drop([53]) -> (); +drop([15]) -> (); +drop>([86]) -> (); +drop([9]) -> (); +drop([57]) -> (); +drop([55]) -> (); +drop([8]) -> (); +enum_init, 1>([101]) -> ([135]); +store_temp([88]) -> ([136]); +store_temp([89]) -> ([137]); +store_temp([90]) -> ([138]); +store_temp([91]) -> ([139]); +store_temp>([135]) -> ([140]); +return([136], [137], [138], [139], [140]); +branch_align() -> (); +drop([9]) -> (); +drop([55]) -> (); +drop([53]) -> (); +drop([8]) -> (); +drop([57]) -> (); +drop([15]) -> (); +drop([14]) -> (); +enum_init, 1>([87]) -> ([141]); +store_temp([0]) -> ([142]); +store_temp([79]) -> ([143]); +store_temp([2]) -> ([144]); +store_temp([80]) -> ([145]); +store_temp>([141]) -> ([146]); +return([142], [143], [144], [145], [146]); +branch_align() -> (); +drop([9]) -> (); +drop([13]) -> (); +drop>([32]) -> (); +drop([8]) -> (); +drop>([23]) -> (); +drop([15]) -> (); +drop([14]) -> (); +enum_init, 1>([42]) -> ([147]); +store_temp([0]) -> ([148]); +store_temp([34]) -> ([149]); +store_temp([2]) -> ([150]); +store_temp([35]) -> ([151]); +store_temp>([147]) -> ([152]); +return([148], [149], [150], [151], [152]); +branch_align() -> (); +drop([14]) -> (); +drop([15]) -> (); +drop([9]) -> (); +drop([13]) -> (); +drop([8]) -> (); +drop>([23]) -> (); +drop([7]) -> (); +drop([12]) -> (); +enum_init, 1>([33]) -> ([153]); +store_temp([0]) -> ([154]); +store_temp([25]) -> ([155]); +store_temp([2]) -> ([156]); +store_temp([26]) -> ([157]); +store_temp>([153]) -> ([158]); +return([154], [155], [156], [157], [158]); +branch_align() -> (); +drop([14]) -> (); +drop([15]) -> (); +drop([9]) -> (); +drop([13]) -> (); +drop([12]) -> (); +drop([8]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([11]) -> (); +enum_init, 1>([24]) -> ([159]); +store_temp([0]) -> ([160]); +store_temp([16]) -> ([161]); +store_temp([2]) -> ([162]); +store_temp([17]) -> ([163]); +store_temp>([159]) -> ([164]); +return([160], [161], [162], [163], [164]); +drop([2]) -> (); +storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>() -> ([3]); +storage_address_from_base([3]) -> ([4]); +u32_const<0>() -> ([5]); +store_temp([5]) -> ([5]); +store_temp([4]) -> ([4]); +storage_read_syscall([0], [1], [5], [4]) { fallthrough([6], [7], [8]) 2602([9], [10], [11]) }; +branch_align() -> (); +enum_init>, 0>([8]) -> ([12]); +store_temp([6]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>>([12]) -> ([15]); +jump() { 2607() }; +branch_align() -> (); +enum_init>, 1>([11]) -> ([16]); +store_temp([9]) -> ([13]); +store_temp([10]) -> ([14]); +store_temp>>([16]) -> ([15]); +rename>>([15]) -> ([18]); +function_call::unwrap_syscall>([18]) -> ([17]); +enum_match>([17]) { fallthrough([19]) 2618([20]) }; +branch_align() -> (); +struct_deconstruct>([19]) -> ([21]); +struct_construct>([21]) -> ([22]); +enum_init, 0>([22]) -> ([23]); +store_temp([13]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +branch_align() -> (); +enum_init, 1>([20]) -> ([27]); +store_temp([13]) -> ([28]); +store_temp([14]) -> ([29]); +store_temp>([27]) -> ([30]); +return([28], [29], [30]); +drop([2]) -> (); +storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>() -> ([3]); +storage_address_from_base([3]) -> ([4]); +u32_const<0>() -> ([5]); +store_temp([5]) -> ([5]); +store_temp([4]) -> ([4]); +storage_read_syscall([0], [1], [5], [4]) { fallthrough([6], [7], [8]) 2637([9], [10], [11]) }; +branch_align() -> (); +enum_init>, 0>([8]) -> ([12]); +store_temp([6]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>>([12]) -> ([15]); +jump() { 2642() }; +branch_align() -> (); +enum_init>, 1>([11]) -> ([16]); +store_temp([9]) -> ([13]); +store_temp([10]) -> ([14]); +store_temp>>([16]) -> ([15]); +rename>>([15]) -> ([18]); +function_call::unwrap_syscall>([18]) -> ([17]); +enum_match>([17]) { fallthrough([19]) 2653([20]) }; +branch_align() -> (); +struct_deconstruct>([19]) -> ([21]); +struct_construct>([21]) -> ([22]); +enum_init, 0>([22]) -> ([23]); +store_temp([13]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +branch_align() -> (); +enum_init, 1>([20]) -> ([27]); +store_temp([13]) -> ([28]); +store_temp([14]) -> ([29]); +store_temp>([27]) -> ([30]); +return([28], [29], [30]); +drop([3]) -> (); +storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>() -> ([4]); +u32_const<0>() -> ([5]); +store_temp([0]) -> ([10]); +store_temp([1]) -> ([11]); +store_temp([2]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([10], [11], [12], [13], [14]) -> ([6], [7], [8], [9]); +enum_match>,)>>([9]) { fallthrough([15]) 2690([16]) }; +branch_align() -> (); +struct_deconstruct>>>([15]) -> ([17]); +store_temp>>([17]) -> ([19]); +function_call::unwrap_syscall>([19]) -> ([18]); +enum_match>([18]) { fallthrough([20]) 2683([21]) }; +branch_align() -> (); +struct_deconstruct>([20]) -> ([22]); +struct_construct>([22]) -> ([23]); +enum_init, 0>([23]) -> ([24]); +store_temp([6]) -> ([25]); +store_temp([7]) -> ([26]); +store_temp([8]) -> ([27]); +store_temp>([24]) -> ([28]); +return([25], [26], [27], [28]); +branch_align() -> (); +enum_init, 1>([21]) -> ([29]); +store_temp([6]) -> ([30]); +store_temp([7]) -> ([31]); +store_temp([8]) -> ([32]); +store_temp>([29]) -> ([33]); +return([30], [31], [32], [33]); +branch_align() -> (); +enum_init, 1>([16]) -> ([34]); +store_temp([6]) -> ([35]); +store_temp([7]) -> ([36]); +store_temp([8]) -> ([37]); +store_temp>([34]) -> ([38]); +return([35], [36], [37], [38]); +drop([3]) -> (); +storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>() -> ([4]); +u32_const<0>() -> ([5]); +store_temp([0]) -> ([10]); +store_temp([1]) -> ([11]); +store_temp([2]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([10], [11], [12], [13], [14]) -> ([6], [7], [8], [9]); +enum_match>,)>>([9]) { fallthrough([15]) 2728([16]) }; +branch_align() -> (); +struct_deconstruct>>>([15]) -> ([17]); +store_temp>>([17]) -> ([19]); +function_call::unwrap_syscall>([19]) -> ([18]); +enum_match>([18]) { fallthrough([20]) 2721([21]) }; +branch_align() -> (); +struct_deconstruct>([20]) -> ([22]); +struct_construct>([22]) -> ([23]); +enum_init, 0>([23]) -> ([24]); +store_temp([6]) -> ([25]); +store_temp([7]) -> ([26]); +store_temp([8]) -> ([27]); +store_temp>([24]) -> ([28]); +return([25], [26], [27], [28]); +branch_align() -> (); +enum_init, 1>([21]) -> ([29]); +store_temp([6]) -> ([30]); +store_temp([7]) -> ([31]); +store_temp([8]) -> ([32]); +store_temp>([29]) -> ([33]); +return([30], [31], [32], [33]); +branch_align() -> (); +enum_init, 1>([16]) -> ([34]); +store_temp([6]) -> ([35]); +store_temp([7]) -> ([36]); +store_temp([8]) -> ([37]); +store_temp>([34]) -> ([38]); +return([35], [36], [37], [38]); +rename([0]) -> ([2]); +u128_to_felt252([2]) -> ([3]); +snapshot_take([3]) -> ([4], [5]); +drop([4]) -> (); +store_temp([5]) -> ([8]); +store_temp>([1]) -> ([9]); +function_call([8], [9]) -> ([6], [7]); +drop([7]) -> (); +struct_construct() -> ([10]); +store_temp>([6]) -> ([11]); +store_temp([10]) -> ([12]); +return([11], [12]); +store_temp([0]) -> ([9]); +store_temp([2]) -> ([10]); +store_temp([4]) -> ([11]); +store_temp([5]) -> ([12]); +function_call([9], [10], [11], [12]) -> ([6], [7], [8]); +u32_const<0>() -> ([13]); +store_temp([6]) -> ([18]); +store_temp([1]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([13]) -> ([21]); +store_temp([8]) -> ([22]); +function_call([18], [19], [20], [21], [22]) -> ([14], [15], [16], [17]); +enum_match>,)>>([17]) { fallthrough([23]) 2783([24]) }; +branch_align() -> (); +struct_deconstruct>>>([23]) -> ([25]); +store_temp>>([25]) -> ([27]); +function_call::unwrap_syscall>([27]) -> ([26]); +enum_match>([26]) { fallthrough([28]) 2775([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30]); +struct_construct>([30]) -> ([31]); +enum_init, 0>([31]) -> ([32]); +store_temp([14]) -> ([33]); +store_temp([15]) -> ([34]); +store_temp([7]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +enum_init, 1>([29]) -> ([38]); +store_temp([14]) -> ([39]); +store_temp([15]) -> ([40]); +store_temp([7]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp>([38]) -> ([43]); +return([39], [40], [41], [42], [43]); +branch_align() -> (); +enum_init, 1>([24]) -> ([44]); +store_temp([14]) -> ([45]); +store_temp([15]) -> ([46]); +store_temp([7]) -> ([47]); +store_temp([16]) -> ([48]); +store_temp>([44]) -> ([49]); +return([45], [46], [47], [48], [49]); +store_temp([0]) -> ([9]); +store_temp([2]) -> ([10]); +store_temp([4]) -> ([11]); +store_temp>([5]) -> ([12]); +function_call([9], [10], [11], [12]) -> ([6], [7], [8]); +u32_const<0>() -> ([13]); +store_temp([6]) -> ([18]); +store_temp([1]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([13]) -> ([21]); +store_temp([8]) -> ([22]); +function_call([18], [19], [20], [21], [22]) -> ([14], [15], [16], [17]); +enum_match>,)>>([17]) { fallthrough([23]) 2827([24]) }; +branch_align() -> (); +struct_deconstruct>>>([23]) -> ([25]); +store_temp>>([25]) -> ([27]); +function_call::unwrap_syscall>([27]) -> ([26]); +enum_match>([26]) { fallthrough([28]) 2819([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30]); +struct_construct>([30]) -> ([31]); +enum_init, 0>([31]) -> ([32]); +store_temp([14]) -> ([33]); +store_temp([15]) -> ([34]); +store_temp([7]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +enum_init, 1>([29]) -> ([38]); +store_temp([14]) -> ([39]); +store_temp([15]) -> ([40]); +store_temp([7]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp>([38]) -> ([43]); +return([39], [40], [41], [42], [43]); +branch_align() -> (); +enum_init, 1>([24]) -> ([44]); +store_temp([14]) -> ([45]); +store_temp([15]) -> ([46]); +store_temp([7]) -> ([47]); +store_temp([16]) -> ([48]); +store_temp>([44]) -> ([49]); +return([45], [46], [47], [48], [49]); +struct_deconstruct>([1]) -> ([2]); +array_snapshot_pop_front([2]) { fallthrough([3], [4]) 2842([5]) }; +branch_align() -> (); +enum_init>, 0>([4]) -> ([6]); +store_temp>>([3]) -> ([7]); +store_temp>>([6]) -> ([8]); +jump() { 2847() }; +branch_align() -> (); +struct_construct() -> ([9]); +enum_init>, 1>([9]) -> ([10]); +store_temp>>([5]) -> ([7]); +store_temp>>([10]) -> ([8]); +struct_construct>([7]) -> ([11]); +store_temp>([11]) -> ([11]); +enum_match>>([8]) { fallthrough([12]) 2869([13]) }; +branch_align() -> (); +unbox([12]) -> ([14]); +rename([14]) -> ([15]); +store_temp([0]) -> ([18]); +store_temp([15]) -> ([19]); +function_call([18], [19]) -> ([16], [17]); +enum_match>([17]) { fallthrough([20]) 2863([21]) }; +branch_align() -> (); +enum_init, 0>([20]) -> ([22]); +store_temp([16]) -> ([23]); +store_temp>([11]) -> ([24]); +store_temp>([22]) -> ([25]); +return([23], [24], [25]); +branch_align() -> (); +enum_init, 1>([21]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp>([11]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([13]) -> (); +struct_construct() -> ([30]); +enum_init, 1>([30]) -> ([31]); +store_temp([0]) -> ([32]); +store_temp>([11]) -> ([33]); +store_temp>([31]) -> ([34]); +return([32], [33], [34]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +function_call([5], [6]) -> ([2], [3], [4]); +enum_match,)>>([4]) { fallthrough([7]) 2895([8]) }; +branch_align() -> (); +struct_deconstruct>>([7]) -> ([9]); +unbox([9]) -> ([10]); +struct_deconstruct([10]) -> ([11], [12], [13], [14], [15]); +drop>([11]) -> (); +drop>([12]) -> (); +drop([14]) -> (); +drop([15]) -> (); +struct_construct>([13]) -> ([16]); +enum_init, 0>([16]) -> ([17]); +store_temp([2]) -> ([18]); +store_temp([3]) -> ([19]); +store_temp>([17]) -> ([20]); +return([18], [19], [20]); +branch_align() -> (); +enum_init, 1>([8]) -> ([21]); +store_temp([2]) -> ([22]); +store_temp([3]) -> ([23]); +store_temp>([21]) -> ([24]); +return([22], [23], [24]); +dup([5]) -> ([5], [9]); +contract_address_to_felt252([9]) -> ([8]); +snapshot_take([8]) -> ([10], [11]); +drop([10]) -> (); +felt252_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +felt252_sub([15], [16]) -> ([17]); +store_temp([17]) -> ([17]); +felt252_is_zero([17]) { fallthrough() 2918([18]) }; +branch_align() -> (); +struct_construct() -> ([19]); +enum_init([19]) -> ([20]); +store_temp([20]) -> ([21]); +jump() { 2923() }; +branch_align() -> (); +drop>([18]) -> (); +struct_construct() -> ([22]); +enum_init([22]) -> ([23]); +store_temp([23]) -> ([21]); +bool_not_impl([21]) -> ([24]); +store_temp([24]) -> ([24]); +enum_match([24]) { fallthrough([25]) 2945([26]) }; +branch_align() -> (); +drop([25]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +array_new() -> ([27]); +felt252_const<25936191677694277552149992725516921697451103245639728>() -> ([28]); +store_temp([28]) -> ([28]); +array_append([27], [28]) -> ([29]); +struct_construct() -> ([30]); +struct_construct>>([30], [29]) -> ([31]); +enum_init, 1>([31]) -> ([32]); +store_temp([0]) -> ([33]); +store_temp([1]) -> ([34]); +store_temp([2]) -> ([35]); +store_temp([3]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +drop([26]) -> (); +dup([6]) -> ([6], [39]); +contract_address_to_felt252([39]) -> ([38]); +snapshot_take([38]) -> ([40], [41]); +drop([40]) -> (); +felt252_const<0>() -> ([42]); +snapshot_take([42]) -> ([43], [44]); +drop([43]) -> (); +rename([41]) -> ([45]); +rename([44]) -> ([46]); +felt252_sub([45], [46]) -> ([47]); +store_temp([47]) -> ([47]); +felt252_is_zero([47]) { fallthrough() 2964([48]) }; +branch_align() -> (); +struct_construct() -> ([49]); +enum_init([49]) -> ([50]); +store_temp([50]) -> ([51]); +jump() { 2969() }; +branch_align() -> (); +drop>([48]) -> (); +struct_construct() -> ([52]); +enum_init([52]) -> ([53]); +store_temp([53]) -> ([51]); +bool_not_impl([51]) -> ([54]); +store_temp([54]) -> ([54]); +enum_match([54]) { fallthrough([55]) 2991([56]) }; +branch_align() -> (); +drop([55]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +array_new() -> ([57]); +felt252_const<395754877894504967531585582359572169455970492464>() -> ([58]); +store_temp([58]) -> ([58]); +array_append([57], [58]) -> ([59]); +struct_construct() -> ([60]); +struct_construct>>([60], [59]) -> ([61]); +enum_init, 1>([61]) -> ([62]); +store_temp([0]) -> ([63]); +store_temp([1]) -> ([64]); +store_temp([2]) -> ([65]); +store_temp([3]) -> ([66]); +store_temp>([62]) -> ([67]); +return([63], [64], [65], [66], [67]); +branch_align() -> (); +drop([56]) -> (); +struct_deconstruct([4]) -> ([68], [69], [70], [71], [72], [73]); +snapshot_take([72]) -> ([74], [75]); +store_temp([0]) -> ([81]); +store_temp([1]) -> ([82]); +store_temp([2]) -> ([83]); +store_temp([3]) -> ([84]); +store_temp([75]) -> ([85]); +dup([5]) -> ([5], [86]); +store_temp([86]) -> ([86]); +function_call([81], [82], [83], [84], [85], [86]) -> ([76], [77], [78], [79], [80]); +enum_match>([80]) { fallthrough([87]) 3171([88]) }; +branch_align() -> (); +struct_deconstruct>([87]) -> ([89]); +store_temp([76]) -> ([92]); +store_temp([89]) -> ([93]); +dup([7]) -> ([7], [94]); +store_temp([94]) -> ([94]); +function_call([92], [93], [94]) -> ([90], [91]); +enum_match>([91]) { fallthrough([95]) 3154([96]) }; +branch_align() -> (); +struct_deconstruct>([95]) -> ([97]); +store_temp([90]) -> ([103]); +store_temp([77]) -> ([104]); +store_temp([78]) -> ([105]); +store_temp([79]) -> ([106]); +store_temp([74]) -> ([107]); +dup([5]) -> ([5], [108]); +store_temp([108]) -> ([108]); +store_temp([97]) -> ([109]); +function_call([103], [104], [105], [106], [107], [108], [109]) -> ([98], [99], [100], [101], [102]); +enum_match>([102]) { fallthrough([110]) 3138([111]) }; +branch_align() -> (); +struct_deconstruct>([110]) -> ([112], [113]); +drop([113]) -> (); +snapshot_take([112]) -> ([114], [115]); +store_temp([98]) -> ([121]); +store_temp([99]) -> ([122]); +store_temp([100]) -> ([123]); +store_temp([101]) -> ([124]); +store_temp([115]) -> ([125]); +dup([6]) -> ([6], [126]); +store_temp([126]) -> ([126]); +function_call([121], [122], [123], [124], [125], [126]) -> ([116], [117], [118], [119], [120]); +enum_match>([120]) { fallthrough([127]) 3121([128]) }; +branch_align() -> (); +struct_deconstruct>([127]) -> ([129]); +store_temp([116]) -> ([132]); +store_temp([129]) -> ([133]); +dup([7]) -> ([7], [134]); +store_temp([134]) -> ([134]); +function_call([132], [133], [134]) -> ([130], [131]); +enum_match>([131]) { fallthrough([135]) 3104([136]) }; +branch_align() -> (); +struct_deconstruct>([135]) -> ([137]); +store_temp([130]) -> ([143]); +store_temp([117]) -> ([144]); +store_temp([118]) -> ([145]); +store_temp([119]) -> ([146]); +store_temp([114]) -> ([147]); +dup([6]) -> ([6], [148]); +store_temp([148]) -> ([148]); +store_temp([137]) -> ([149]); +function_call([143], [144], [145], [146], [147], [148], [149]) -> ([138], [139], [140], [141], [142]); +enum_match>([142]) { fallthrough([150]) 3088([151]) }; +branch_align() -> (); +struct_deconstruct>([150]) -> ([152], [153]); +drop([153]) -> (); +struct_construct([5], [6], [7]) -> ([154]); +struct_construct([68], [69], [70], [71], [152], [73]) -> ([155]); +store_temp([139]) -> ([159]); +store_temp([141]) -> ([160]); +store_temp([155]) -> ([161]); +store_temp([154]) -> ([162]); +function_call>([159], [160], [161], [162]) -> ([156], [157], [158]); +enum_match>([158]) { fallthrough([163]) 3080([164]) }; +branch_align() -> (); +struct_deconstruct>([163]) -> ([165], [166]); +drop([166]) -> (); +struct_construct() -> ([167]); +struct_construct>([165], [167]) -> ([168]); +enum_init, 0>([168]) -> ([169]); +store_temp([138]) -> ([170]); +store_temp([156]) -> ([171]); +store_temp([140]) -> ([172]); +store_temp([157]) -> ([173]); +store_temp>([169]) -> ([174]); +return([170], [171], [172], [173], [174]); +branch_align() -> (); +enum_init, 1>([164]) -> ([175]); +store_temp([138]) -> ([176]); +store_temp([156]) -> ([177]); +store_temp([140]) -> ([178]); +store_temp([157]) -> ([179]); +store_temp>([175]) -> ([180]); +return([176], [177], [178], [179], [180]); +branch_align() -> (); +drop([68]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([70]) -> (); +drop([69]) -> (); +drop([7]) -> (); +drop([6]) -> (); +enum_init, 1>([151]) -> ([181]); +store_temp([138]) -> ([182]); +store_temp([139]) -> ([183]); +store_temp([140]) -> ([184]); +store_temp([141]) -> ([185]); +store_temp>([181]) -> ([186]); +return([182], [183], [184], [185], [186]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([114]) -> (); +enum_init, 1>([136]) -> ([187]); +store_temp([130]) -> ([188]); +store_temp([117]) -> ([189]); +store_temp([118]) -> ([190]); +store_temp([119]) -> ([191]); +store_temp>([187]) -> ([192]); +return([188], [189], [190], [191], [192]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([114]) -> (); +enum_init, 1>([128]) -> ([193]); +store_temp([116]) -> ([194]); +store_temp([117]) -> ([195]); +store_temp([118]) -> ([196]); +store_temp([119]) -> ([197]); +store_temp>([193]) -> ([198]); +return([194], [195], [196], [197], [198]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +enum_init, 1>([111]) -> ([199]); +store_temp([98]) -> ([200]); +store_temp([99]) -> ([201]); +store_temp([100]) -> ([202]); +store_temp([101]) -> ([203]); +store_temp>([199]) -> ([204]); +return([200], [201], [202], [203], [204]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([74]) -> (); +enum_init, 1>([96]) -> ([205]); +store_temp([90]) -> ([206]); +store_temp([77]) -> ([207]); +store_temp([78]) -> ([208]); +store_temp([79]) -> ([209]); +store_temp>([205]) -> ([210]); +return([206], [207], [208], [209], [210]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([74]) -> (); +enum_init, 1>([88]) -> ([211]); +store_temp([76]) -> ([212]); +store_temp([77]) -> ([213]); +store_temp([78]) -> ([214]); +store_temp([79]) -> ([215]); +store_temp>([211]) -> ([216]); +return([212], [213], [214], [215], [216]); +struct_deconstruct([4]) -> ([8], [9], [10], [11], [12], [13]); +snapshot_take([13]) -> ([14], [15]); +dup([5]) -> ([5], [16]); +dup([6]) -> ([6], [17]); +struct_construct>([16], [17]) -> ([18]); +store_temp([0]) -> ([24]); +store_temp([1]) -> ([25]); +store_temp([2]) -> ([26]); +store_temp([3]) -> ([27]); +store_temp([15]) -> ([28]); +store_temp>([18]) -> ([29]); +function_call([24], [25], [26], [27], [28], [29]) -> ([19], [20], [21], [22], [23]); +enum_match>([23]) { fallthrough([30]) 3312([31]) }; +branch_align() -> (); +u128_const<340282366920938463463374607431768211455>() -> ([32]); +snapshot_take([32]) -> ([33], [34]); +struct_deconstruct>([30]) -> ([35]); +struct_deconstruct([35]) -> ([36], [37]); +snapshot_take([36]) -> ([38], [39]); +rename([39]) -> ([40]); +rename([34]) -> ([41]); +u128_eq([40], [41]) { fallthrough() 3218() }; +branch_align() -> (); +drop([33]) -> (); +struct_construct() -> ([42]); +enum_init([42]) -> ([43]); +struct_construct([38], [37]) -> ([44]); +store_temp([44]) -> ([45]); +store_temp([43]) -> ([46]); +jump() { 3237() }; +branch_align() -> (); +snapshot_take([37]) -> ([47], [48]); +snapshot_take([33]) -> ([49], [50]); +drop([49]) -> (); +rename([48]) -> ([51]); +rename([50]) -> ([52]); +u128_eq([51], [52]) { fallthrough() 3230() }; +branch_align() -> (); +struct_construct() -> ([53]); +enum_init([53]) -> ([54]); +store_temp([54]) -> ([55]); +jump() { 3234() }; +branch_align() -> (); +struct_construct() -> ([56]); +enum_init([56]) -> ([57]); +store_temp([57]) -> ([55]); +struct_construct([38], [47]) -> ([58]); +store_temp([58]) -> ([45]); +store_temp([55]) -> ([46]); +enum_match([46]) { fallthrough([59]) 3291([60]) }; +branch_align() -> (); +drop([59]) -> (); +store_temp([19]) -> ([63]); +store_temp([45]) -> ([64]); +store_temp([7]) -> ([65]); +function_call([63], [64], [65]) -> ([61], [62]); +enum_match>([62]) { fallthrough([66]) 3275([67]) }; +branch_align() -> (); +struct_deconstruct>([66]) -> ([68]); +struct_construct([8], [9], [10], [11], [12], [14]) -> ([69]); +store_temp([61]) -> ([75]); +store_temp([20]) -> ([76]); +store_temp([21]) -> ([77]); +store_temp([22]) -> ([78]); +store_temp([69]) -> ([79]); +store_temp([5]) -> ([80]); +store_temp([6]) -> ([81]); +store_temp([68]) -> ([82]); +function_call([75], [76], [77], [78], [79], [80], [81], [82]) -> ([70], [71], [72], [73], [74]); +enum_match>([74]) { fallthrough([83]) 3267([84]) }; +branch_align() -> (); +struct_deconstruct>([83]) -> ([85], [86]); +drop([86]) -> (); +store_temp([70]) -> ([87]); +store_temp([71]) -> ([88]); +store_temp([72]) -> ([89]); +store_temp([73]) -> ([90]); +store_temp([85]) -> ([91]); +jump() { 3303() }; +branch_align() -> (); +enum_init, 1>([84]) -> ([92]); +store_temp([70]) -> ([93]); +store_temp([71]) -> ([94]); +store_temp([72]) -> ([95]); +store_temp([73]) -> ([96]); +store_temp>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +branch_align() -> (); +drop([8]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([14]) -> (); +drop([12]) -> (); +drop([11]) -> (); +drop([10]) -> (); +drop([9]) -> (); +enum_init, 1>([67]) -> ([98]); +store_temp([61]) -> ([99]); +store_temp([20]) -> ([100]); +store_temp([21]) -> ([101]); +store_temp([22]) -> ([102]); +store_temp>([98]) -> ([103]); +return([99], [100], [101], [102], [103]); +branch_align() -> (); +drop([60]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([7]) -> (); +drop([45]) -> (); +struct_construct([8], [9], [10], [11], [12], [14]) -> ([104]); +store_temp([19]) -> ([87]); +store_temp([20]) -> ([88]); +store_temp([21]) -> ([89]); +store_temp([22]) -> ([90]); +store_temp([104]) -> ([91]); +struct_construct() -> ([105]); +struct_construct>([91], [105]) -> ([106]); +enum_init, 0>([106]) -> ([107]); +store_temp([87]) -> ([108]); +store_temp([88]) -> ([109]); +store_temp([89]) -> ([110]); +store_temp([90]) -> ([111]); +store_temp>([107]) -> ([112]); +return([108], [109], [110], [111], [112]); +branch_align() -> (); +drop([8]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([9]) -> (); +drop([14]) -> (); +drop([12]) -> (); +drop([11]) -> (); +drop([10]) -> (); +drop([7]) -> (); +enum_init, 1>([31]) -> ([113]); +store_temp([19]) -> ([114]); +store_temp([20]) -> ([115]); +store_temp([21]) -> ([116]); +store_temp([22]) -> ([117]); +store_temp>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +dup([6]) -> ([6], [9]); +contract_address_to_felt252([9]) -> ([8]); +snapshot_take([8]) -> ([10], [11]); +drop([10]) -> (); +felt252_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +felt252_sub([15], [16]) -> ([17]); +store_temp([17]) -> ([17]); +felt252_is_zero([17]) { fallthrough() 3346([18]) }; +branch_align() -> (); +struct_construct() -> ([19]); +enum_init([19]) -> ([20]); +store_temp([20]) -> ([21]); +jump() { 3351() }; +branch_align() -> (); +drop>([18]) -> (); +struct_construct() -> ([22]); +enum_init([22]) -> ([23]); +store_temp([23]) -> ([21]); +bool_not_impl([21]) -> ([24]); +store_temp([24]) -> ([24]); +enum_match([24]) { fallthrough([25]) 3373([26]) }; +branch_align() -> (); +drop([25]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +array_new() -> ([27]); +felt252_const<101313248740993271302566317381896466254801065025584>() -> ([28]); +store_temp([28]) -> ([28]); +array_append([27], [28]) -> ([29]); +struct_construct() -> ([30]); +struct_construct>>([30], [29]) -> ([31]); +enum_init, 1>([31]) -> ([32]); +store_temp([0]) -> ([33]); +store_temp([1]) -> ([34]); +store_temp([2]) -> ([35]); +store_temp([3]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +drop([26]) -> (); +struct_deconstruct([4]) -> ([38], [39], [40], [41], [42], [43]); +dup([5]) -> ([5], [44]); +dup([6]) -> ([6], [45]); +struct_construct>([44], [45]) -> ([46]); +store_temp([0]) -> ([52]); +store_temp([1]) -> ([53]); +store_temp([2]) -> ([54]); +store_temp([3]) -> ([55]); +store_temp([43]) -> ([56]); +store_temp>([46]) -> ([57]); +dup([7]) -> ([7], [58]); +store_temp([58]) -> ([58]); +function_call([52], [53], [54], [55], [56], [57], [58]) -> ([47], [48], [49], [50], [51]); +enum_match>([51]) { fallthrough([59]) 3420([60]) }; +branch_align() -> (); +struct_deconstruct>([59]) -> ([61], [62]); +drop([62]) -> (); +struct_construct([5], [6], [7]) -> ([63]); +struct_construct([38], [39], [40], [41], [42], [61]) -> ([64]); +store_temp([48]) -> ([68]); +store_temp([50]) -> ([69]); +store_temp([64]) -> ([70]); +store_temp([63]) -> ([71]); +function_call>([68], [69], [70], [71]) -> ([65], [66], [67]); +enum_match>([67]) { fallthrough([72]) 3412([73]) }; +branch_align() -> (); +struct_deconstruct>([72]) -> ([74], [75]); +drop([75]) -> (); +struct_construct() -> ([76]); +struct_construct>([74], [76]) -> ([77]); +enum_init, 0>([77]) -> ([78]); +store_temp([47]) -> ([79]); +store_temp([65]) -> ([80]); +store_temp([49]) -> ([81]); +store_temp([66]) -> ([82]); +store_temp>([78]) -> ([83]); +return([79], [80], [81], [82], [83]); +branch_align() -> (); +enum_init, 1>([73]) -> ([84]); +store_temp([47]) -> ([85]); +store_temp([65]) -> ([86]); +store_temp([49]) -> ([87]); +store_temp([66]) -> ([88]); +store_temp>([84]) -> ([89]); +return([85], [86], [87], [88], [89]); +branch_align() -> (); +drop([38]) -> (); +drop([5]) -> (); +drop([42]) -> (); +drop([41]) -> (); +drop([40]) -> (); +drop([39]) -> (); +drop([7]) -> (); +drop([6]) -> (); +enum_init, 1>([60]) -> ([90]); +store_temp([47]) -> ([91]); +store_temp([48]) -> ([92]); +store_temp([49]) -> ([93]); +store_temp([50]) -> ([94]); +store_temp>([90]) -> ([95]); +return([91], [92], [93], [94], [95]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +enum_match>([4]) { fallthrough([8]) 3447([9]) }; +branch_align() -> (); +struct_construct>([8]) -> ([10]); +enum_init, 0>([10]) -> ([11]); +store_temp([3]) -> ([12]); +store_temp>([11]) -> ([13]); +return([12], [13]); +branch_align() -> (); +drop([9]) -> (); +array_new() -> ([14]); +felt252_const<39879774624079483812136948410799859986295>() -> ([15]); +store_temp([15]) -> ([15]); +array_append([14], [15]) -> ([16]); +struct_construct() -> ([17]); +struct_construct>>([17], [16]) -> ([18]); +enum_init, 1>([18]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp>([19]) -> ([21]); +return([20], [21]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +enum_match>([4]) { fallthrough([8]) 3470([9]) }; +branch_align() -> (); +struct_construct>([8]) -> ([10]); +enum_init, 0>([10]) -> ([11]); +store_temp([3]) -> ([12]); +store_temp>([11]) -> ([13]); +return([12], [13]); +branch_align() -> (); +drop([9]) -> (); +array_new() -> ([14]); +felt252_const<39879774624085075084607933104993585622903>() -> ([15]); +store_temp([15]) -> ([15]); +array_append([14], [15]) -> ([16]); +struct_construct() -> ([17]); +struct_construct>>([17], [16]) -> ([18]); +enum_init, 1>([18]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp>([19]) -> ([21]); +return([20], [21]); +u8_try_from_felt252([0], [1]) { fallthrough([2], [3]) 3488([4]) }; +branch_align() -> (); +enum_init, 0>([3]) -> ([5]); +store_temp([2]) -> ([6]); +store_temp>([5]) -> ([7]); +jump() { 3493() }; +branch_align() -> (); +struct_construct() -> ([8]); +enum_init, 1>([8]) -> ([9]); +store_temp([4]) -> ([6]); +store_temp>([9]) -> ([7]); +rename([6]) -> ([10]); +rename>([7]) -> ([11]); +return([10], [11]); +storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>() -> ([4]); +storage_address_from_base([4]) -> ([5]); +u32_const<0>() -> ([6]); +snapshot_take([2]) -> ([7], [8]); +drop([8]) -> (); +store_temp([6]) -> ([6]); +store_temp([5]) -> ([5]); +storage_write_syscall([0], [1], [6], [5], [3]) { fallthrough([9], [10]) 3511([11], [12], [13]) }; +branch_align() -> (); +struct_construct() -> ([14]); +enum_init>, 0>([14]) -> ([15]); +store_temp([9]) -> ([16]); +store_temp([10]) -> ([17]); +store_temp>>([15]) -> ([18]); +jump() { 3516() }; +branch_align() -> (); +enum_init>, 1>([13]) -> ([19]); +store_temp([11]) -> ([16]); +store_temp([12]) -> ([17]); +store_temp>>([19]) -> ([18]); +rename>>([18]) -> ([21]); +function_call::unwrap_syscall>([21]) -> ([20]); +enum_match>([20]) { fallthrough([22]) 3527([23]) }; +branch_align() -> (); +struct_deconstruct>([22]) -> ([24]); +struct_construct>([7], [24]) -> ([25]); +enum_init, 0>([25]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp([17]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([23]) -> ([30]); +store_temp([16]) -> ([31]); +store_temp([17]) -> ([32]); +store_temp>([30]) -> ([33]); +return([31], [32], [33]); +storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>() -> ([4]); +storage_address_from_base([4]) -> ([5]); +u32_const<0>() -> ([6]); +snapshot_take([2]) -> ([7], [8]); +drop([8]) -> (); +store_temp([6]) -> ([6]); +store_temp([5]) -> ([5]); +storage_write_syscall([0], [1], [6], [5], [3]) { fallthrough([9], [10]) 3549([11], [12], [13]) }; +branch_align() -> (); +struct_construct() -> ([14]); +enum_init>, 0>([14]) -> ([15]); +store_temp([9]) -> ([16]); +store_temp([10]) -> ([17]); +store_temp>>([15]) -> ([18]); +jump() { 3554() }; +branch_align() -> (); +enum_init>, 1>([13]) -> ([19]); +store_temp([11]) -> ([16]); +store_temp([12]) -> ([17]); +store_temp>>([19]) -> ([18]); +rename>>([18]) -> ([21]); +function_call::unwrap_syscall>([21]) -> ([20]); +enum_match>([20]) { fallthrough([22]) 3565([23]) }; +branch_align() -> (); +struct_deconstruct>([22]) -> ([24]); +struct_construct>([7], [24]) -> ([25]); +enum_init, 0>([25]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp([17]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([23]) -> ([30]); +store_temp([16]) -> ([31]); +store_temp([17]) -> ([32]); +store_temp>([30]) -> ([33]); +return([31], [32], [33]); +storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>() -> ([4]); +u8_to_felt252([3]) -> ([5]); +storage_address_from_base([4]) -> ([6]); +u32_const<0>() -> ([7]); +snapshot_take([2]) -> ([8], [9]); +drop([9]) -> (); +store_temp([7]) -> ([7]); +store_temp([6]) -> ([6]); +storage_write_syscall([0], [1], [7], [6], [5]) { fallthrough([10], [11]) 3588([12], [13], [14]) }; +branch_align() -> (); +struct_construct() -> ([15]); +enum_init>, 0>([15]) -> ([16]); +store_temp([10]) -> ([17]); +store_temp([11]) -> ([18]); +store_temp>>([16]) -> ([19]); +jump() { 3593() }; +branch_align() -> (); +enum_init>, 1>([14]) -> ([20]); +store_temp([12]) -> ([17]); +store_temp([13]) -> ([18]); +store_temp>>([20]) -> ([19]); +rename>>([19]) -> ([22]); +function_call::unwrap_syscall>([22]) -> ([21]); +enum_match>([21]) { fallthrough([23]) 3604([24]) }; +branch_align() -> (); +struct_deconstruct>([23]) -> ([25]); +struct_construct>([8], [25]) -> ([26]); +enum_init, 0>([26]) -> ([27]); +store_temp([17]) -> ([28]); +store_temp([18]) -> ([29]); +store_temp>([27]) -> ([30]); +return([28], [29], [30]); +branch_align() -> (); +drop([8]) -> (); +enum_init, 1>([24]) -> ([31]); +store_temp([17]) -> ([32]); +store_temp([18]) -> ([33]); +store_temp>([31]) -> ([34]); +return([32], [33], [34]); +storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>() -> ([4]); +u32_const<0>() -> ([5]); +store_temp([0]) -> ([9]); +store_temp([1]) -> ([10]); +store_temp([5]) -> ([11]); +store_temp([4]) -> ([12]); +store_temp([3]) -> ([13]); +function_call([9], [10], [11], [12], [13]) -> ([6], [7], [8]); +rename>>([8]) -> ([15]); +function_call::unwrap_syscall>([15]) -> ([14]); +enum_match>([14]) { fallthrough([16]) 3632([17]) }; +branch_align() -> (); +snapshot_take([2]) -> ([18], [19]); +drop([19]) -> (); +struct_deconstruct>([16]) -> ([20]); +struct_construct>([18], [20]) -> ([21]); +enum_init, 0>([21]) -> ([22]); +store_temp([6]) -> ([23]); +store_temp([7]) -> ([24]); +store_temp>([22]) -> ([25]); +return([23], [24], [25]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([17]) -> ([26]); +store_temp([6]) -> ([27]); +store_temp([7]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +snapshot_take([4]) -> ([7], [8]); +store_temp([0]) -> ([12]); +store_temp([2]) -> ([13]); +store_temp([8]) -> ([14]); +store_temp([5]) -> ([15]); +function_call([12], [13], [14], [15]) -> ([9], [10], [11]); +u32_const<0>() -> ([16]); +store_temp([1]) -> ([20]); +store_temp([3]) -> ([21]); +store_temp([16]) -> ([22]); +store_temp([11]) -> ([23]); +store_temp([6]) -> ([24]); +function_call([20], [21], [22], [23], [24]) -> ([17], [18], [19]); +rename>>([19]) -> ([26]); +function_call::unwrap_syscall>([26]) -> ([25]); +enum_match>([25]) { fallthrough([27]) 3665([28]) }; +branch_align() -> (); +struct_deconstruct>([27]) -> ([29]); +struct_construct>([7], [29]) -> ([30]); +enum_init, 0>([30]) -> ([31]); +store_temp([9]) -> ([32]); +store_temp([17]) -> ([33]); +store_temp([10]) -> ([34]); +store_temp([18]) -> ([35]); +store_temp>([31]) -> ([36]); +return([32], [33], [34], [35], [36]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([28]) -> ([37]); +store_temp([9]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp([18]) -> ([41]); +store_temp>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +store_temp([3]) -> ([5]); +function_call::into>([5]) -> ([4]); +array_new() -> ([6]); +array_new() -> ([7]); +snapshot_take([4]) -> ([8], [9]); +drop([8]) -> (); +store_temp([9]) -> ([13]); +store_temp>([6]) -> ([14]); +store_temp>([7]) -> ([15]); +function_call([13], [14], [15]) -> ([10], [11], [12]); +drop([12]) -> (); +snapshot_take>([10]) -> ([16], [17]); +drop>([16]) -> (); +struct_construct>([17]) -> ([18]); +snapshot_take>([11]) -> ([19], [20]); +drop>([19]) -> (); +struct_construct>([20]) -> ([21]); +store_temp>([18]) -> ([18]); +store_temp>([21]) -> ([21]); +emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 3701([24], [25], [26]) }; +branch_align() -> (); +struct_construct() -> ([27]); +enum_init>, 0>([27]) -> ([28]); +store_temp([22]) -> ([29]); +store_temp([23]) -> ([30]); +store_temp>>([28]) -> ([31]); +jump() { 3706() }; +branch_align() -> (); +enum_init>, 1>([26]) -> ([32]); +store_temp([24]) -> ([29]); +store_temp([25]) -> ([30]); +store_temp>>([32]) -> ([31]); +rename>>([31]) -> ([34]); +function_call::unwrap_syscall>([34]) -> ([33]); +enum_match>([33]) { fallthrough([35]) 3717([36]) }; +branch_align() -> (); +struct_deconstruct>([35]) -> ([37]); +struct_construct>([2], [37]) -> ([38]); +enum_init, 0>([38]) -> ([39]); +store_temp([29]) -> ([40]); +store_temp([30]) -> ([41]); +store_temp>([39]) -> ([42]); +return([40], [41], [42]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([36]) -> ([43]); +store_temp([29]) -> ([44]); +store_temp([30]) -> ([45]); +store_temp>([43]) -> ([46]); +return([44], [45], [46]); +enum_match>>([0]) { fallthrough([1]) 3730([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +storage_address_from_base([4]) -> ([5]); +storage_read_syscall([1], [2], [3], [5]) { fallthrough([6], [7], [8]) 3768([9], [10], [11]) }; +branch_align() -> (); +store_temp([0]) -> ([14]); +store_temp([8]) -> ([15]); +function_call([14], [15]) -> ([12], [13]); +store_temp([6]) -> ([6]); +store_temp([7]) -> ([7]); +enum_match>([13]) { fallthrough([16]) 3754([17]) }; +branch_align() -> (); +enum_init>, 0>([16]) -> ([18]); +struct_construct>>>([18]) -> ([19]); +enum_init>,)>, 0>([19]) -> ([20]); +store_temp([12]) -> ([21]); +store_temp([6]) -> ([22]); +store_temp([7]) -> ([23]); +store_temp>,)>>([20]) -> ([24]); +return([21], [22], [23], [24]); +branch_align() -> (); +drop([17]) -> (); +array_new() -> ([25]); +felt252_const<110930490496575599150170734222081291576>() -> ([26]); +store_temp([26]) -> ([26]); +array_append([25], [26]) -> ([27]); +struct_construct() -> ([28]); +struct_construct>>([28], [27]) -> ([29]); +enum_init>,)>, 1>([29]) -> ([30]); +store_temp([12]) -> ([31]); +store_temp([6]) -> ([32]); +store_temp([7]) -> ([33]); +store_temp>,)>>([30]) -> ([34]); +return([31], [32], [33], [34]); +branch_align() -> (); +enum_init>, 1>([11]) -> ([35]); +struct_construct>>>([35]) -> ([36]); +enum_init>,)>, 0>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([9]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp>,)>>([37]) -> ([41]); +return([38], [39], [40], [41]); +enum_match>>([0]) { fallthrough([1]) 3783([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +store_temp([0]) -> ([9]); +store_temp([1]) -> ([10]); +store_temp([2]) -> ([11]); +dup([3]) -> ([3], [12]); +store_temp([12]) -> ([12]); +dup([4]) -> ([4], [13]); +store_temp([13]) -> ([13]); +function_call([9], [10], [11], [12], [13]) -> ([5], [6], [7], [8]); +enum_match>,)>>([8]) { fallthrough([14]) 3859([15]) }; +branch_align() -> (); +struct_deconstruct>>>([14]) -> ([16]); +enum_match>>([16]) { fallthrough([17]) 3848([18]) }; +branch_align() -> (); +u8_const<1>() -> ([19]); +storage_address_from_base_and_offset([4], [19]) -> ([20]); +store_temp([20]) -> ([20]); +storage_read_syscall([6], [7], [3], [20]) { fallthrough([21], [22], [23]) 3838([24], [25], [26]) }; +branch_align() -> (); +store_temp([5]) -> ([29]); +store_temp([23]) -> ([30]); +function_call([29], [30]) -> ([27], [28]); +store_temp([21]) -> ([21]); +store_temp([22]) -> ([22]); +enum_match>([28]) { fallthrough([31]) 3823([32]) }; +branch_align() -> (); +struct_construct([17], [31]) -> ([33]); +enum_init>, 0>([33]) -> ([34]); +struct_construct>>>([34]) -> ([35]); +enum_init>,)>, 0>([35]) -> ([36]); +store_temp([27]) -> ([37]); +store_temp([21]) -> ([38]); +store_temp([22]) -> ([39]); +store_temp>,)>>([36]) -> ([40]); +return([37], [38], [39], [40]); +branch_align() -> (); +drop([32]) -> (); +drop([17]) -> (); +array_new() -> ([41]); +felt252_const<476442828812030857794232422692155113556837216824>() -> ([42]); +store_temp([42]) -> ([42]); +array_append([41], [42]) -> ([43]); +struct_construct() -> ([44]); +struct_construct>>([44], [43]) -> ([45]); +enum_init>,)>, 1>([45]) -> ([46]); +store_temp([27]) -> ([47]); +store_temp([21]) -> ([48]); +store_temp([22]) -> ([49]); +store_temp>,)>>([46]) -> ([50]); +return([47], [48], [49], [50]); +branch_align() -> (); +drop([17]) -> (); +enum_init>, 1>([26]) -> ([51]); +struct_construct>>>([51]) -> ([52]); +enum_init>,)>, 0>([52]) -> ([53]); +store_temp([5]) -> ([54]); +store_temp([24]) -> ([55]); +store_temp([25]) -> ([56]); +store_temp>,)>>([53]) -> ([57]); +return([54], [55], [56], [57]); +branch_align() -> (); +drop([4]) -> (); +drop([3]) -> (); +enum_init>, 1>([18]) -> ([58]); +struct_construct>>>([58]) -> ([59]); +enum_init>,)>, 0>([59]) -> ([60]); +store_temp([5]) -> ([61]); +store_temp([6]) -> ([62]); +store_temp([7]) -> ([63]); +store_temp>,)>>([60]) -> ([64]); +return([61], [62], [63], [64]); +branch_align() -> (); +drop([4]) -> (); +drop([3]) -> (); +enum_init>,)>, 1>([15]) -> ([65]); +store_temp([5]) -> ([66]); +store_temp([6]) -> ([67]); +store_temp([7]) -> ([68]); +store_temp>,)>>([65]) -> ([69]); +return([66], [67], [68], [69]); +enum_match>>([0]) { fallthrough([1]) 3874([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +drop([2]) -> (); +felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564>() -> ([4]); +store_temp([1]) -> ([7]); +store_temp([4]) -> ([8]); +store_temp([3]) -> ([9]); +function_call([7], [8], [9]) -> ([5], [6]); +storage_base_address_from_felt252([0], [6]) -> ([10], [11]); +store_temp([10]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([11]) -> ([14]); +return([12], [13], [14]); +drop([2]) -> (); +felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719>() -> ([4]); +store_temp([1]) -> ([7]); +store_temp([4]) -> ([8]); +store_temp>([3]) -> ([9]); +function_call::hash>([7], [8], [9]) -> ([5], [6]); +storage_base_address_from_felt252([0], [6]) -> ([10], [11]); +store_temp([10]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([11]) -> ([14]); +return([12], [13], [14]); +u128s_from_felt252([0], [1]) { fallthrough([2], [3]) 3908([4], [5], [6]) }; +branch_align() -> (); +enum_init, 0>([3]) -> ([7]); +store_temp([2]) -> ([8]); +store_temp>([7]) -> ([9]); +jump() { 3915() }; +branch_align() -> (); +drop([5]) -> (); +drop([6]) -> (); +struct_construct() -> ([10]); +enum_init, 1>([10]) -> ([11]); +store_temp([4]) -> ([8]); +store_temp>([11]) -> ([9]); +rename([8]) -> ([12]); +rename>([9]) -> ([13]); +return([12], [13]); +get_execution_info_syscall([0], [1]) { fallthrough([2], [3], [4]) 3925([5], [6], [7]) }; +branch_align() -> (); +enum_init, core::array::Array::>, 0>([4]) -> ([8]); +store_temp([2]) -> ([9]); +store_temp([3]) -> ([10]); +store_temp, core::array::Array::>>([8]) -> ([11]); +jump() { 3930() }; +branch_align() -> (); +enum_init, core::array::Array::>, 1>([7]) -> ([12]); +store_temp([5]) -> ([9]); +store_temp([6]) -> ([10]); +store_temp, core::array::Array::>>([12]) -> ([11]); +rename, core::array::Array::>>([11]) -> ([14]); +function_call>::unwrap_syscall>([14]) -> ([13]); +enum_match,)>>([13]) { fallthrough([15]) 3941([16]) }; +branch_align() -> (); +struct_deconstruct>>([15]) -> ([17]); +struct_construct>>([17]) -> ([18]); +enum_init,)>, 0>([18]) -> ([19]); +store_temp([9]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp,)>>([19]) -> ([22]); +return([20], [21], [22]); +branch_align() -> (); +enum_init,)>, 1>([16]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([10]) -> ([25]); +store_temp,)>>([23]) -> ([26]); +return([24], [25], [26]); +store_temp([3]) -> ([5]); +function_call([5]) -> ([4]); +array_new() -> ([6]); +array_new() -> ([7]); +snapshot_take([4]) -> ([8], [9]); +drop([8]) -> (); +store_temp([9]) -> ([13]); +store_temp>([6]) -> ([14]); +store_temp>([7]) -> ([15]); +function_call([13], [14], [15]) -> ([10], [11], [12]); +drop([12]) -> (); +snapshot_take>([10]) -> ([16], [17]); +drop>([16]) -> (); +struct_construct>([17]) -> ([18]); +snapshot_take>([11]) -> ([19], [20]); +drop>([19]) -> (); +struct_construct>([20]) -> ([21]); +store_temp>([18]) -> ([18]); +store_temp>([21]) -> ([21]); +emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 3974([24], [25], [26]) }; +branch_align() -> (); +struct_construct() -> ([27]); +enum_init>, 0>([27]) -> ([28]); +store_temp([22]) -> ([29]); +store_temp([23]) -> ([30]); +store_temp>>([28]) -> ([31]); +jump() { 3979() }; +branch_align() -> (); +enum_init>, 1>([26]) -> ([32]); +store_temp([24]) -> ([29]); +store_temp([25]) -> ([30]); +store_temp>>([32]) -> ([31]); +rename>>([31]) -> ([34]); +function_call::unwrap_syscall>([34]) -> ([33]); +enum_match>([33]) { fallthrough([35]) 3990([36]) }; +branch_align() -> (); +struct_deconstruct>([35]) -> ([37]); +struct_construct>([2], [37]) -> ([38]); +enum_init, 0>([38]) -> ([39]); +store_temp([29]) -> ([40]); +store_temp([30]) -> ([41]); +store_temp>([39]) -> ([42]); +return([40], [41], [42]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([36]) -> ([43]); +store_temp([29]) -> ([44]); +store_temp([30]) -> ([45]); +store_temp>([43]) -> ([46]); +return([44], [45], [46]); +snapshot_take([4]) -> ([7], [8]); +store_temp([0]) -> ([12]); +store_temp([2]) -> ([13]); +store_temp([8]) -> ([14]); +store_temp>([5]) -> ([15]); +function_call([12], [13], [14], [15]) -> ([9], [10], [11]); +u32_const<0>() -> ([16]); +store_temp([1]) -> ([20]); +store_temp([3]) -> ([21]); +store_temp([16]) -> ([22]); +store_temp([11]) -> ([23]); +store_temp([6]) -> ([24]); +function_call([20], [21], [22], [23], [24]) -> ([17], [18], [19]); +rename>>([19]) -> ([26]); +function_call::unwrap_syscall>([26]) -> ([25]); +enum_match>([25]) { fallthrough([27]) 4023([28]) }; +branch_align() -> (); +struct_deconstruct>([27]) -> ([29]); +struct_construct>([7], [29]) -> ([30]); +enum_init, 0>([30]) -> ([31]); +store_temp([9]) -> ([32]); +store_temp([17]) -> ([33]); +store_temp([10]) -> ([34]); +store_temp([18]) -> ([35]); +store_temp>([31]) -> ([36]); +return([32], [33], [34], [35], [36]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([28]) -> ([37]); +store_temp([9]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp([18]) -> ([41]); +store_temp>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +store_temp([3]) -> ([5]); +function_call([5]) -> ([4]); +array_new() -> ([6]); +array_new() -> ([7]); +snapshot_take([4]) -> ([8], [9]); +drop([8]) -> (); +store_temp([9]) -> ([13]); +store_temp>([6]) -> ([14]); +store_temp>([7]) -> ([15]); +function_call([13], [14], [15]) -> ([10], [11], [12]); +drop([12]) -> (); +snapshot_take>([10]) -> ([16], [17]); +drop>([16]) -> (); +struct_construct>([17]) -> ([18]); +snapshot_take>([11]) -> ([19], [20]); +drop>([19]) -> (); +struct_construct>([20]) -> ([21]); +store_temp>([18]) -> ([18]); +store_temp>([21]) -> ([21]); +emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 4059([24], [25], [26]) }; +branch_align() -> (); +struct_construct() -> ([27]); +enum_init>, 0>([27]) -> ([28]); +store_temp([22]) -> ([29]); +store_temp([23]) -> ([30]); +store_temp>>([28]) -> ([31]); +jump() { 4064() }; +branch_align() -> (); +enum_init>, 1>([26]) -> ([32]); +store_temp([24]) -> ([29]); +store_temp([25]) -> ([30]); +store_temp>>([32]) -> ([31]); +rename>>([31]) -> ([34]); +function_call::unwrap_syscall>([34]) -> ([33]); +enum_match>([33]) { fallthrough([35]) 4075([36]) }; +branch_align() -> (); +struct_deconstruct>([35]) -> ([37]); +struct_construct>([2], [37]) -> ([38]); +enum_init, 0>([38]) -> ([39]); +store_temp([29]) -> ([40]); +store_temp([30]) -> ([41]); +store_temp>([39]) -> ([42]); +return([40], [41], [42]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([36]) -> ([43]); +store_temp([29]) -> ([44]); +store_temp([30]) -> ([45]); +store_temp>([43]) -> ([46]); +return([44], [45], [46]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +struct_deconstruct>([4]) -> ([8], [9]); +enum_match([9]) { fallthrough([10]) 4093([11]) }; +branch_align() -> (); +drop([10]) -> (); +enum_init, 0>([8]) -> ([12]); +store_temp>([12]) -> ([13]); +jump() { 4099() }; +branch_align() -> (); +drop([11]) -> (); +drop([8]) -> (); +struct_construct() -> ([14]); +enum_init, 1>([14]) -> ([15]); +store_temp>([15]) -> ([13]); +store_temp([3]) -> ([16]); +store_temp>([13]) -> ([17]); +return([16], [17]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +struct_deconstruct>([4]) -> ([8], [9]); +enum_match([9]) { fallthrough([10]) 4113([11]) }; +branch_align() -> (); +drop([10]) -> (); +enum_init, 0>([8]) -> ([12]); +store_temp>([12]) -> ([13]); +jump() { 4119() }; +branch_align() -> (); +drop([11]) -> (); +drop([8]) -> (); +struct_construct() -> ([14]); +enum_init, 1>([14]) -> ([15]); +store_temp>([15]) -> ([13]); +store_temp([3]) -> ([16]); +store_temp>([13]) -> ([17]); +return([16], [17]); +enum_match>>([0]) { fallthrough([1]) 4128([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +struct_deconstruct([4]) -> ([5], [6]); +u128_to_felt252([5]) -> ([7]); +dup([3]) -> ([3], [9]); +storage_address_from_base([9]) -> ([8]); +dup([2]) -> ([2], [10]); +storage_write_syscall([0], [1], [10], [8], [7]) { fallthrough([11], [12]) 4160([13], [14], [15]) }; +branch_align() -> (); +u128_to_felt252([6]) -> ([16]); +u8_const<1>() -> ([17]); +storage_address_from_base_and_offset([3], [17]) -> ([18]); +store_temp([11]) -> ([11]); +store_temp([18]) -> ([18]); +storage_write_syscall([11], [12], [2], [18], [16]) { fallthrough([19], [20]) 4154([21], [22], [23]) }; +branch_align() -> (); +struct_construct() -> ([24]); +enum_init>, 0>([24]) -> ([25]); +store_temp([19]) -> ([26]); +store_temp([20]) -> ([27]); +store_temp>>([25]) -> ([28]); +return([26], [27], [28]); +branch_align() -> (); +enum_init>, 1>([23]) -> ([29]); +store_temp([21]) -> ([30]); +store_temp([22]) -> ([31]); +store_temp>>([29]) -> ([32]); +return([30], [31], [32]); +branch_align() -> (); +drop([3]) -> (); +drop([6]) -> (); +drop([2]) -> (); +enum_init>, 1>([15]) -> ([33]); +store_temp([13]) -> ([34]); +store_temp([14]) -> ([35]); +store_temp>>([33]) -> ([36]); +return([34], [35], [36]); +store_temp([0]) -> ([1]); +return([1]); +enum_match([0]) { fallthrough([3]) 4184([4]) }; +branch_align() -> (); +felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697>() -> ([5]); +store_temp([5]) -> ([5]); +array_append([1], [5]) -> ([6]); +store_temp([3]) -> ([10]); +store_temp>([6]) -> ([11]); +store_temp>([2]) -> ([12]); +function_call([10], [11], [12]) -> ([7], [8], [9]); +drop([9]) -> (); +store_temp>([7]) -> ([13]); +store_temp>([8]) -> ([14]); +jump() { 4195() }; +branch_align() -> (); +felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999>() -> ([15]); +store_temp([15]) -> ([15]); +array_append([1], [15]) -> ([16]); +store_temp([4]) -> ([20]); +store_temp>([16]) -> ([21]); +store_temp>([2]) -> ([22]); +function_call([20], [21], [22]) -> ([17], [18], [19]); +drop([19]) -> (); +store_temp>([17]) -> ([13]); +store_temp>([18]) -> ([14]); +struct_construct() -> ([23]); +rename>([13]) -> ([24]); +rename>([14]) -> ([25]); +store_temp([23]) -> ([26]); +return([24], [25], [26]); +storage_address_from_base([4]) -> ([5]); +storage_read_syscall([1], [2], [3], [5]) { fallthrough([6], [7], [8]) 4232([9], [10], [11]) }; +branch_align() -> (); +store_temp([0]) -> ([14]); +store_temp([8]) -> ([15]); +function_call([14], [15]) -> ([12], [13]); +store_temp([6]) -> ([6]); +store_temp([7]) -> ([7]); +enum_match>([13]) { fallthrough([16]) 4218([17]) }; +branch_align() -> (); +enum_init>, 0>([16]) -> ([18]); +struct_construct>>>([18]) -> ([19]); +enum_init>,)>, 0>([19]) -> ([20]); +store_temp([12]) -> ([21]); +store_temp([6]) -> ([22]); +store_temp([7]) -> ([23]); +store_temp>,)>>([20]) -> ([24]); +return([21], [22], [23], [24]); +branch_align() -> (); +drop([17]) -> (); +array_new() -> ([25]); +felt252_const<476442828812030857794232422692155113556837216824>() -> ([26]); +store_temp([26]) -> ([26]); +array_append([25], [26]) -> ([27]); +struct_construct() -> ([28]); +struct_construct>>([28], [27]) -> ([29]); +enum_init>,)>, 1>([29]) -> ([30]); +store_temp([12]) -> ([31]); +store_temp([6]) -> ([32]); +store_temp([7]) -> ([33]); +store_temp>,)>>([30]) -> ([34]); +return([31], [32], [33], [34]); +branch_align() -> (); +enum_init>, 1>([11]) -> ([35]); +struct_construct>>>([35]) -> ([36]); +enum_init>,)>, 0>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([9]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp>,)>>([37]) -> ([41]); +return([38], [39], [40], [41]); +contract_address_to_felt252([2]) -> ([3]); +pedersen([0], [1], [3]) -> ([4], [5]); +store_temp([4]) -> ([6]); +store_temp([5]) -> ([7]); +return([6], [7]); +struct_deconstruct>([2]) -> ([3], [4]); +store_temp([0]) -> ([7]); +store_temp([1]) -> ([8]); +store_temp([3]) -> ([9]); +function_call([7], [8], [9]) -> ([5], [6]); +rename([5]) -> ([12]); +rename([6]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([12], [13], [14]) -> ([10], [11]); +rename([10]) -> ([15]); +rename([11]) -> ([16]); +return([15], [16]); +enum_match, core::array::Array::>>([0]) { fallthrough([1]) 4264([2]) }; +branch_align() -> (); +struct_construct>>([1]) -> ([3]); +enum_init,)>, 0>([3]) -> ([4]); +store_temp,)>>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init,)>, 1>([7]) -> ([8]); +store_temp,)>>([8]) -> ([9]); +return([9]); +enum_init([0]) -> ([1]); +store_temp([1]) -> ([2]); +return([2]); +enum_init([0]) -> ([1]); +store_temp([1]) -> ([2]); +return([2]); +struct_deconstruct([1]) -> ([3], [4]); +struct_deconstruct([2]) -> ([5], [6]); +u128_overflowing_add([0], [4], [6]) { fallthrough([7], [8]) 4286([9], [10]) }; +branch_align() -> (); +struct_construct() -> ([11]); +enum_init([11]) -> ([12]); +struct_construct>([8], [12]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>([13]) -> ([15]); +jump() { 4292() }; +branch_align() -> (); +struct_construct() -> ([16]); +enum_init([16]) -> ([17]); +struct_construct>([10], [17]) -> ([18]); +store_temp([9]) -> ([14]); +store_temp>([18]) -> ([15]); +struct_deconstruct>([15]) -> ([19], [20]); +u128_overflowing_add([14], [3], [5]) { fallthrough([21], [22]) 4300([23], [24]) }; +branch_align() -> (); +struct_construct([22], [19]) -> ([25]); +struct_construct>([25], [20]) -> ([26]); +store_temp([21]) -> ([27]); +store_temp>([26]) -> ([28]); +jump() { 4320() }; +branch_align() -> (); +u128_const<1>() -> ([29]); +store_temp([29]) -> ([29]); +u128_overflowing_add([23], [19], [29]) { fallthrough([30], [31]) 4310([32], [33]) }; +branch_align() -> (); +struct_construct([24], [31]) -> ([34]); +struct_construct>([34], [20]) -> ([35]); +store_temp([30]) -> ([36]); +store_temp>([35]) -> ([37]); +jump() { 4318() }; +branch_align() -> (); +drop([20]) -> (); +struct_construct([24], [33]) -> ([38]); +struct_construct() -> ([39]); +enum_init([39]) -> ([40]); +struct_construct>([38], [40]) -> ([41]); +store_temp([32]) -> ([36]); +store_temp>([41]) -> ([37]); +rename([36]) -> ([27]); +rename>([37]) -> ([28]); +rename([27]) -> ([42]); +rename>([28]) -> ([43]); +return([42], [43]); +struct_deconstruct([1]) -> ([3], [4]); +struct_deconstruct([2]) -> ([5], [6]); +u128_overflowing_sub([0], [4], [6]) { fallthrough([7], [8]) 4333([9], [10]) }; +branch_align() -> (); +struct_construct() -> ([11]); +enum_init([11]) -> ([12]); +struct_construct>([8], [12]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>([13]) -> ([15]); +jump() { 4339() }; +branch_align() -> (); +struct_construct() -> ([16]); +enum_init([16]) -> ([17]); +struct_construct>([10], [17]) -> ([18]); +store_temp([9]) -> ([14]); +store_temp>([18]) -> ([15]); +struct_deconstruct>([15]) -> ([19], [20]); +u128_overflowing_sub([14], [3], [5]) { fallthrough([21], [22]) 4347([23], [24]) }; +branch_align() -> (); +struct_construct([22], [19]) -> ([25]); +struct_construct>([25], [20]) -> ([26]); +store_temp([21]) -> ([27]); +store_temp>([26]) -> ([28]); +jump() { 4367() }; +branch_align() -> (); +u128_const<1>() -> ([29]); +store_temp([29]) -> ([29]); +u128_overflowing_sub([23], [19], [29]) { fallthrough([30], [31]) 4357([32], [33]) }; +branch_align() -> (); +struct_construct([24], [31]) -> ([34]); +struct_construct>([34], [20]) -> ([35]); +store_temp([30]) -> ([36]); +store_temp>([35]) -> ([37]); +jump() { 4365() }; +branch_align() -> (); +drop([20]) -> (); +struct_construct([24], [33]) -> ([38]); +struct_construct() -> ([39]); +enum_init([39]) -> ([40]); +struct_construct>([38], [40]) -> ([41]); +store_temp([32]) -> ([36]); +store_temp>([41]) -> ([37]); +rename([36]) -> ([27]); +rename>([37]) -> ([28]); +rename([27]) -> ([42]); +rename>([28]) -> ([43]); +return([42], [43]); +dup([0]) -> ([0], [3]); +struct_deconstruct([3]) -> ([4], [5], [6]); +drop([5]) -> (); +drop([6]) -> (); +store_temp([4]) -> ([9]); +store_temp>([2]) -> ([10]); +function_call([9], [10]) -> ([7], [8]); +drop([8]) -> (); +dup([0]) -> ([0], [11]); +struct_deconstruct([11]) -> ([12], [13], [14]); +drop([12]) -> (); +drop([14]) -> (); +store_temp([13]) -> ([17]); +store_temp>([7]) -> ([18]); +function_call([17], [18]) -> ([15], [16]); +drop([16]) -> (); +struct_deconstruct([0]) -> ([19], [20], [21]); +drop([19]) -> (); +drop([20]) -> (); +store_temp([21]) -> ([24]); +store_temp>([15]) -> ([25]); +function_call([24], [25]) -> ([22], [23]); +drop([23]) -> (); +struct_construct() -> ([26]); +store_temp>([1]) -> ([27]); +store_temp>([22]) -> ([28]); +store_temp([26]) -> ([29]); +return([27], [28], [29]); +dup([0]) -> ([0], [3]); +struct_deconstruct([3]) -> ([4], [5], [6]); +drop([5]) -> (); +drop([6]) -> (); +store_temp([4]) -> ([9]); +store_temp>([2]) -> ([10]); +function_call([9], [10]) -> ([7], [8]); +drop([8]) -> (); +dup([0]) -> ([0], [11]); +struct_deconstruct([11]) -> ([12], [13], [14]); +drop([12]) -> (); +drop([14]) -> (); +store_temp([13]) -> ([17]); +store_temp>([7]) -> ([18]); +function_call([17], [18]) -> ([15], [16]); +drop([16]) -> (); +struct_deconstruct([0]) -> ([19], [20], [21]); +drop([19]) -> (); +drop([20]) -> (); +store_temp([21]) -> ([24]); +store_temp>([15]) -> ([25]); +function_call([24], [25]) -> ([22], [23]); +drop([23]) -> (); +struct_construct() -> ([26]); +store_temp>([1]) -> ([27]); +store_temp>([22]) -> ([28]); +store_temp([26]) -> ([29]); +return([27], [28], [29]); +rename([0]) -> ([2]); +contract_address_to_felt252([2]) -> ([3]); +snapshot_take([3]) -> ([4], [5]); +drop([4]) -> (); +store_temp([5]) -> ([8]); +store_temp>([1]) -> ([9]); +function_call([8], [9]) -> ([6], [7]); +drop([7]) -> (); +struct_construct() -> ([10]); +store_temp>([6]) -> ([11]); +store_temp([10]) -> ([12]); +return([11], [12]); + +erc20::erc20::erc_20::__external::get_name@0([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::get_symbol@101([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::get_decimals@202([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::get_total_supply@303([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::balance_of@404([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::allowance@534([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::transfer@689([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::transfer_from@836([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::approve@1009([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::increase_allowance@1156([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::decrease_allowance@1303([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__constructor::constructor@1450([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::IERC20Impl::get_name@1677([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +core::Felt252Serde::serialize@1702([0]: felt252, [1]: Array) -> (Array, Unit); +erc20::erc20::erc_20::IERC20Impl::get_symbol@1708([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +erc20::erc20::erc_20::IERC20Impl::get_decimals@1733([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u8,)>); +core::integer::U8Serde::serialize@1761([0]: u8, [1]: Array) -> (Array, Unit); +erc20::erc20::erc_20::IERC20Impl::get_total_supply@1773([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::u256Serde::serialize@1801([0]: core::integer::u256, [1]: Array) -> (Array, Unit); +core::starknet::contract_address::ContractAddressSerde::deserialize@1816([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +erc20::erc20::erc_20::IERC20Impl::balance_of@1840([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +erc20::erc20::erc_20::IERC20Impl::allowance@1872([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::u256Serde::deserialize@1905([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +erc20::erc20::erc_20::IERC20Impl::transfer@1934([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::transfer_from@1981([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::approve@2055([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::increase_allowance@2102([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::decrease_allowance@2205([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::Felt252Serde::deserialize@2308([0]: core::array::Span::) -> (core::array::Span::, core::option::Option::); +core::integer::U8Serde::deserialize@2337([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +erc20::erc20::erc_20::constructor@2379([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: felt252, [6]: felt252, [7]: u8, [8]: core::integer::u256, [9]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::name::InternalContractStateImpl::read@2589([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::name::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +erc20::erc20::erc_20::symbol::InternalContractStateImpl::read@2624([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::symbol::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +erc20::erc20::erc_20::decimals::InternalContractStateImpl::read@2659([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::decimals::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u8,)>); +erc20::erc20::erc_20::total_supply::InternalContractStateImpl::read@2697([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::total_supply::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::U128Serde::serialize@2735([0]: u128, [1]: Array) -> (Array, Unit); +erc20::erc20::erc_20::balances::InternalContractStateImpl::read@2747([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::balances::ContractState, [5]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +erc20::erc20::erc_20::allowances::InternalContractStateImpl::read@2791([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::allowances::ContractState, [5]: Tuple) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::U128Serde::deserialize@2835([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +core::starknet::info::get_caller_address@2877([0]: GasBuiltin, [1]: System) -> (GasBuiltin, System, core::panics::PanicResult::<(core::starknet::contract_address::ContractAddress,)>); +erc20::erc20::erc_20::StorageImpl::transfer_helper@2901([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::StorageImpl::spend_allowance@3188([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::StorageImpl::approve_helper@3329([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::integer::U256Add::add@3436([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::U256Sub::sub@3459([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::Felt252TryIntoU8::try_into@3482([0]: RangeCheck, [1]: felt252) -> (RangeCheck, core::option::Option::); +erc20::erc20::erc_20::name::InternalContractStateImpl::write@3496([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::name::ContractState, [3]: felt252) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::name::ContractState, ())>); +erc20::erc20::erc_20::symbol::InternalContractStateImpl::write@3534([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::symbol::ContractState, [3]: felt252) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::symbol::ContractState, ())>); +erc20::erc20::erc_20::decimals::InternalContractStateImpl::write@3572([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::decimals::ContractState, [3]: u8) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::decimals::ContractState, ())>); +erc20::erc20::erc_20::total_supply::InternalContractStateImpl::write@3611([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::total_supply::ContractState, [3]: core::integer::u256) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::total_supply::ContractState, ())>); +erc20::erc20::erc_20::balances::InternalContractStateImpl::write@3639([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::balances::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::balances::ContractState, ())>); +erc20::erc20::erc_20::ContractStateEventEmitter::emit::>@3674([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Event) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3724([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::felt252,)>); +core::starknet::storage_access::StoreU8::read@3736([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); +core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3777([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::integer::u8,)>); +core::integer::Storeu256::read@3789([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); +core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3868([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::integer::u256,)>); +erc20::erc20::erc_20::balances::InternalContractStateImpl::address@3880([0]: RangeCheck, [1]: Pedersen, [2]: erc20::erc20::erc_20::balances::ContractState, [3]: ContractAddress) -> (RangeCheck, Pedersen, StorageBaseAddress); +erc20::erc20::erc_20::allowances::InternalContractStateImpl::address@3891([0]: RangeCheck, [1]: Pedersen, [2]: erc20::erc20::erc_20::allowances::ContractState, [3]: Tuple) -> (RangeCheck, Pedersen, StorageBaseAddress); +core::integer::u128_try_from_felt252@3902([0]: RangeCheck, [1]: felt252) -> (RangeCheck, core::option::Option::); +core::starknet::info::get_execution_info@3918([0]: GasBuiltin, [1]: System) -> (GasBuiltin, System, core::panics::PanicResult::<(core::box::Box::,)>); +erc20::erc20::erc_20::ContractStateEventEmitter::emit::@3947([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Transfer) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::allowances::InternalContractStateImpl::write@3997([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::allowances::ContractState, [5]: Tuple, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::allowances::ContractState, ())>); +erc20::erc20::erc_20::ContractStateEventEmitter::emit::@4032([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Approval) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::integer::u256_checked_add@4082([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::option::Option::); +core::integer::u256_checked_sub@4102([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::option::Option::); +core::starknet::SyscallResultTraitImpl::<()>::unwrap_syscall@4122([0]: core::result::Result::<(), core::array::Array::>) -> (core::panics::PanicResult::<((),)>); +core::integer::Storeu256::write@4134([0]: GasBuiltin, [1]: System, [2]: u32, [3]: StorageBaseAddress, [4]: core::integer::u256) -> (GasBuiltin, System, core::result::Result::<(), core::array::Array::>); +core::traits::TIntoT::::into@4169([0]: erc20::erc20::erc_20::Event) -> (erc20::erc20::erc_20::Event); +erc20::erc20::erc_20::EventIsEvent::append_keys_and_data@4171([0]: erc20::erc20::erc_20::Event, [1]: Array, [2]: Array) -> (Array, Array, Unit); +core::starknet::storage_access::StoreU128::read@4200([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); +core::hash::LegacyHashContractAddress::hash@4241([0]: Pedersen, [1]: felt252, [2]: ContractAddress) -> (Pedersen, felt252); +core::hash::TupleSize2LegacyHash::::hash@4246([0]: Pedersen, [1]: felt252, [2]: Tuple) -> (Pedersen, felt252); +core::starknet::SyscallResultTraitImpl::>::unwrap_syscall@4258([0]: core::result::Result::, core::array::Array::>) -> (core::panics::PanicResult::<(core::box::Box::,)>); +erc20::erc20::erc_20::EventTransferIntoEvent::into@4270([0]: erc20::erc20::erc_20::Transfer) -> (erc20::erc20::erc_20::Event); +erc20::erc20::erc_20::EventApprovalIntoEvent::into@4273([0]: erc20::erc20::erc_20::Approval) -> (erc20::erc20::erc_20::Event); +core::integer::u256_overflowing_add@4276([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, Tuple); +core::integer::u256_overflow_sub@4323([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, Tuple); +erc20::erc20::erc_20::TransferIsEvent::append_keys_and_data@4370([0]: erc20::erc20::erc_20::Transfer, [1]: Array, [2]: Array) -> (Array, Array, Unit); +erc20::erc20::erc_20::ApprovalIsEvent::append_keys_and_data@4398([0]: erc20::erc20::erc_20::Approval, [1]: Array, [2]: Array) -> (Array, Array, Unit); +core::starknet::contract_address::ContractAddressSerde::serialize@4426([0]: ContractAddress, [1]: Array) -> (Array, Unit); diff --git a/cairo_programs/wallet.sierra b/cairo_programs/wallet.sierra new file mode 100644 index 000000000..51f9a924c --- /dev/null +++ b/cairo_programs/wallet.sierra @@ -0,0 +1,1430 @@ +{ + "sierra_program": [ + "0x1", + "0x3", + "0x0", + "0x2", + "0x2", + "0x0", + "0x110", + "0xf0", + "0x25", + "0x52616e6765436865636b", + "0x800000000000000100000000000000000000000000000000", + "0x537472756374", + "0x800000000000000f00000000000000000000000000000001", + "0x0", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x800000000000000f00000000000000000000000000000002", + "0x1", + "0x16a4c8d7c05909052238a862d8cc3e7975bf05a07b3a69c6b28951083a6d672", + "0x4172726179", + "0x800000000000000300000000000000000000000000000001", + "0x8", + "0x800000000000000300000000000000000000000000000003", + "0x3", + "0x4", + "0x456e756d", + "0xcc5e86243f861d2d64b08c35db21013e773ac5cf10097946fe0011304886d5", + "0x2", + "0x5", + "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", + "0x66656c74323532", + "0x800000000000000700000000000000000000000000000000", + "0x90d0203c41ad646d024845257a6eceb2f8b59b29ce7420dd518053d2edeedc", + "0x53746f7261676541646472657373", + "0x53746f726167654261736541646472657373", + "0x2633efa4b25602d1290a27d6aeb948fa53ef8a1976814cd1d78ed018207d9cd", + "0x800000000000000f00000000000000000000000000000003", + "0xc", + "0x289f3ec570490cc3a75d679992a6fbe6de8132318d9d268c66b360184dfa286", + "0xd", + "0x75313238", + "0x800000000000000700000000000000000000000000000003", + "0x25e2ca4b84968c2d8b83ef476ca8549410346b00836ce79beaf538155990bb2", + "0xf", + "0x800000000000000700000000000000000000000000000002", + "0x33dd38c898783061cd5539eddd96ee07d9522f364cb597d41a5d52b5c33314d", + "0x10", + "0x38ebd195e334343351be418d9529f6ec84f863f4b4de353979c00728b133d95", + "0x11", + "0x426f78", + "0x800000000000000700000000000000000000000000000001", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x13", + "0x10203be321c62a7bd4c060d69539c1fbe065baa9e253c74d2cc48be163e259", + "0x15", + "0x3520cd02f0e8297127614983b88bdaefde065b3fb4003d1a9d69b11592f6415", + "0x17", + "0x208991af02aa9b701a77c2c14af12d805ccecd643d794ba6794d824caf0095c", + "0x18", + "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", + "0x536e617073686f74", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x1b", + "0x1c", + "0x39d7e2f385e5d511ae0a83d1ae4f716c2c908fa7833dd212825a421b655f6c8", + "0x1e", + "0x4275696c74696e436f737473", + "0x53797374656d", + "0x9931c641b913035ae674b400b61a51476d506bbe8bba2ff8a6272790aba9e6", + "0x1d", + "0x753332", + "0x4761734275696c74696e", + "0x92", + "0x7265766f6b655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x23", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x73746f72655f74656d70", + "0x7533325f6571", + "0x61727261795f6e6577", + "0x66656c743235325f636f6e7374", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x61727261795f617070656e64", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x22", + "0x24", + "0x21", + "0x6765745f6275696c74696e5f636f737473", + "0x20", + "0x77697468647261775f6761735f616c6c", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x1f", + "0x4f7574206f6620676173", + "0x1a", + "0x6", + "0x19", + "0x4661696c656420746f20646573657269616c697a6520706172616d202331", + "0x7", + "0x16", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x14", + "0x6a756d70", + "0x756e626f78", + "0x753132385f636f6e7374", + "0x12", + "0x9", + "0x66656c743235325f616464", + "0xa", + "0xe", + "0x73746f726167655f626173655f616464726573735f636f6e7374", + "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091", + "0x73746f726167655f616464726573735f66726f6d5f62617365", + "0x73746f726167655f726561645f73797363616c6c", + "0xb", + "0x656d69745f6576656e745f73797363616c6c", + "0x73746f726167655f77726974655f73797363616c6c", + "0x155e08616bcbb7488110b83d2b0fbb666a76c8444c7199784579e8339c7e629", + "0x647570", + "0x753132385f746f5f66656c74323532", + "0x295", + "0xffffffffffffffff", + "0x51", + "0x44", + "0x26", + "0x27", + "0x28", + "0x3d", + "0x29", + "0x2a", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x31", + "0x32", + "0x2f", + "0x30", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x39", + "0x3a", + "0x3b", + "0x3c", + "0x3e", + "0x3f", + "0x40", + "0x41", + "0x42", + "0x43", + "0x45", + "0x46", + "0x47", + "0x48", + "0x49", + "0x4a", + "0x4b", + "0x4c", + "0x4d", + "0x4e", + "0x4f", + "0x50", + "0x52", + "0x53", + "0x54", + "0xbf", + "0xb0", + "0x80", + "0xa2", + "0x9b", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5b", + "0x5c", + "0x12d", + "0x11e", + "0xee", + "0x110", + "0x109", + "0x14b", + "0x15f", + "0x164", + "0x16e", + "0x1ac", + "0x1a4", + "0x19e", + "0x5d", + "0x1c6", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x1d9", + "0x62", + "0x63", + "0x1de", + "0x64", + "0x65", + "0x66", + "0x1e9", + "0x67", + "0x68", + "0x69", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x20a", + "0x70", + "0x71", + "0x20f", + "0x72", + "0x73", + "0x74", + "0x75", + "0x21a", + "0x76", + "0x77", + "0x230", + "0x235", + "0x240", + "0x78", + "0x79", + "0x7a", + "0x7b", + "0x7c", + "0x24d", + "0x7d", + "0x7e", + "0x7f", + "0x81", + "0x26a", + "0x82", + "0x83", + "0x84", + "0x85", + "0x86", + "0x87", + "0x88", + "0x89", + "0x8a", + "0x8b", + "0x8c", + "0x8d", + "0x8e", + "0x8f", + "0x90", + "0x91", + "0xcd", + "0x13b", + "0x152", + "0x158", + "0x175", + "0x1b4", + "0x1cc", + "0x1ef", + "0x221", + "0x247", + "0x253", + "0x255", + "0x264", + "0x270", + "0x27a", + "0x289", + "0x1815", + "0x38100602834060c0402c1409028100608040180a07018180a04018080200", + "0x2018080b8141a100b0541e08040202805068402608090202205068401e08", + "0x583e1304078101d0283420080407010060286c061a0281006160c858300f", + "0x144010060205228138204c05118404a08120144603110204408108144003", + "0x6c061c040b80a070184c102d040b00a0d0803010060288c0608040ac102a", + "0xc1e08148cc1008060206405100402608188206005068401008178200c05", + "0x4c1038040dc0a0d08030102f040180a20018d810060288c0635040d00a23", + "0xd8100821814840520814803f010f82c3d0982078081d8141a10010e82c39", + "0x20104a23020104a230201049028481048230201047230201045060201044", + "0x4c1008280381008280301008278301008251382408268301008260149605", + "0x1400a572b020104a02954a40804128a80804128a608041281012290202451", + "0xbc1008238e010082196810082c8381c082c0bc1008250bc1008280701008", + "0x20104707820104504020104707838105807820104a060201047060201045", + "0xd81008250d810082396c240826814245204048a23c04020a03604020a00f", + "0x3810582f848104d1882010472f02010592e83810582e0201059098381058", + "0x20a02d04020866104020b20c07020b01c04020941c040208a2f040208660", + "0x14018080412410122d02024510e02010472d020104a02848b408091447008", + "0x14c8630402094350402094050918c1012288301008310201008250201008", + "0x2024512e020104a02848b80809144180804194c608041641012318202451", + "0x2094050919c10122889c100828094100828014240833048240833020245c", + "0x2010500f0201043358201059350381058188201043029a4d00e04160ce08", + "0x14dc6d09020d82d040208e0809178101228978100825014245e04048a231", + "0x160d00804124101234020245134020104a02848d008091440a6f35020104a", + "0x701c082c020246104048a261040209405091841012288b41008281c01c08", + "0x20245130020104a02848c008091440a710f0381058338201047338201045", + "0x48a21e04020a0053904810082197410082c9ac1c082c1801008248202460", + "0x128e61204134ce0804164d00804164101235820245135820104a02848d608", + "0x48a25d0402094050917410122884810082818010082c8881c082c09c1008", + "0x20104712820104312820107412838105812820104a13820104304048ba08", + "0x140a053b014ea2204020920804020920f04020922707020b022040209422", + "0x38100e02814ee08028480a602e848f01307848ee1204014240802814ee08", + "0x1dc106a041740a7035048ee0834020260534020ee08060201e0506020ee08", + "0x201805029dc101e041740a6b0f048ee080e02026050e020ee08029800a05", + "0x1dc100f041a80a22041dc1022041a00a25041dc106b040300a22041dc1070", + "0x780a27041dc10050e0140a77040142405028d80a77090944412380141e08", + "0x1dc10051281456083b820ce27090880a67041dc1067041ac0a67041dc1005", + "0xbc10770403c106a029841077040b41067028b41077040acc61213814c608", + "0xbc1e082e020ee08308205a052f020ee0809020c60518820ee08098205605", + "0x3862051a820ee081a8205e051a820ee08029840a053b8200a1202970bc31", + "0x1700a56041dc10052f0140a770401424052d0e024791e0d82477090d4260f", + "0x20a8081a814f4083b82024083181400083b820780815814a8083b820ac08", + "0x14c103c028d81077040d8106a0294c8c52071dc107b3d0001c36029ec1077", + "0x48ee083e02070053f820ee08028700a053b8200a12029f8107d3e020ee12", + "0x1ac0a053b82104082a0150682091dc1081041580a053b82100082d0150280", + "0x20a60543a182477042150812230150a083b820fe082901508083b8210608", + "0x20ee0844820f605029dc1088041e80a8944048ee08430200005029dc1087", + "0xac0a8d041dc1036041a80a8c041dc108b041f80a8b041dc108a041f00a8a", + "0x23d1c8d0782120083b8211808168151e083b8208c08318151c083b820a408", + "0x148102b029f41077040d8106a02a441077041f8106702814ee08028480a90", + "0x152893491f41e084a020ee08488205a0549820ee0823020c60549020ee08", + "0x258107704258106b02a58107704014fe054a820ee08028700a053b8200a12", + "0x19c0a98041dc10973c8484e053c820ee08028940a97041dc10964a8484405", + "0x2024083181536083b820b4081581534083b82070083501532083b8213008", + "0x38108002814ee08028480a9d4e26d340f04274107704264102d02a701077", + "0x880a9f041dc109f041ac0a9f041dc10053f8153c083b8200a1c02814ee08", + "0x288106702a8810770428142121381542083b8200a2502a8010770427d3c12", + "0x20ee0809020c60552020ee083002056053c020ee082e820d40551820ee08", + "0x481005090200a053b8200a0502a994aa43c03c10a6041dc10a3040b40aa5", + "0x20d40841014d4083b8201c08408140a770401424053017424a70983c2477", + "0x200a120287010a838020ee1234021060507820ee0807820d405340302477", + "0x9444123b820d60809814d6083b8203c08078143c083b8201808070140a77", + "0x19c105d028acce123b8204e08098144e083b8200a6002814ee0811020ba05", + "0x18c10770418c1068028b41077040ac100c0298c107704094100c02814ee08", + "0x200a1c02814ee0838020a805029dc1005090140aa9029dc242d31848e005", + "0xc41077040bcc212110145e083b8205e08358145e083b8200a1e029841077", + "0x20d4051a820ee082e020ce052e020ee08189782427029781077040144a05", + "0x1dc1035040b40a38041dc10120418c0a3c041dc1013040ac0a36041dc100f", + "0x1dc1056040bc0a56041dc1005308140a770401424052d0e0783607820b408", + "0x200a5e02814ee08028480a532304954522a048ee122b04c1e0e18814ac08", + "0x2001077040481063029fc107704148102b029e8107704000105c028001077", + "0x1ec1c770420902803f83d0c0541020ee0838020d60540820ee083d0206a05", + "0x14ee08028480a86042ad06083b848fc0843814a8083b820a80835014fc7c", + "0x210107a02a1508123b8210e08000150e083b8200a1c02814ee08418210805", + "0x228107704224107e02a24107704220107c02a20107704214107b02814ee08", + "0x205a0546820ee083e020c60546020ee083d820560545820ee082a020d405", + "0x1a80a8f041dc10860419c0a053b8200a1202a391a8c4583c108e041dc108a", + "0x211e0816814fa083b820f8083181522083b820f6081581520083b820a808", + "0x1dc10050e0140a77041c0105402814ee08028480a923ea45200f042481077", + "0x152a083b8212893090880a94041dc1094041ac0a94041dc10053f8152608", + "0x118106a029e410770425c106702a5c1077042552c12138152c083b8200a25", + "0x20ee083c8205a054d020ee0809020c6054c820ee082982056054c020ee08", + "0x14ee08060210005029dc101c0414c0a053b8200a1202a6d34994c03c109b", + "0x2753812110153a083b8213a08358153a083b8200a8502a701077040143805", + "0x20ee0850020ce0550020ee084f27c242702a7c1077040144a054f020ee08", + "0xb40a78041dc10120418c0aa3041dc1013040ac0aa2041dc100f041a80aa1", + "0x700a053b8201c08400140a77040142405521e146a20782148083b8214208", + "0x1dc10a652848440553020ee0853020d60553020ee08029fc0aa5041dc1005", + "0x155e083b8215c08338155c083b82158ad0909c0aad041dc1005128155808", + "0x2bc102d02ac8107704048106302ac4107704180102b02ac0107704174106a", + "0x2d0260f091dc2408028481005029dc10050281566b258ac01e0859820ee08", + "0x14d00c091dc106a042080a6a041dc100e042040a053b8200a1202980ba12", + "0x201c05029dc10050901438085a9c01077091a010830283c10770403c106a", + "0x2044082e8144a22091dc106b0404c0a6b041dc101e0403c0a1e041dc100c", + "0x300a053b820ce082e8145667091dc10270404c0a27041dc1005300140a77", + "0xb4c61238014c6083b820c608340145a083b820560806014c6083b8204a08", + "0x780a61041dc10050e0140a77041c0105402814ee08028480a055b014ee12", + "0x1dc10051281462083b8205e61090880a2f041dc102f041ac0a2f041dc1005", + "0xd810770403c106a028d41077041701067029701077040c4bc1213814bc08", + "0xd81e082d020ee081a8205a051c020ee0809020c6051e020ee08098205605", + "0x3862052b020ee082b0205e052b020ee08029840a053b8200a1202968703c", + "0x1700a00041dc10052f0140a770401424052991824b729150247709158260f", + "0x20f4081a81500083b820240831814fe083b820a40815814f4083b8200008", + "0x20d4053f1f0f60e3b8210481401fc1e8802a081077041c0106b02a041077", + "0x210608420140a77040142405430217083041dc247e0421c0a54041dc1054", + "0x1ec0a053b82108083d0150a84091dc1087040000a87041dc10050e0140a77", + "0x20a8083501514083b82112083f01512083b82110083e01510083b8210a08", + "0x238107704228102d02a341077041f0106302a301077041ec102b02a2c1077", + "0x20ee082a020d40547820ee0843020ce05029dc1005090151c8d4622c1e08", + "0x3c1092041dc108f040b40a7d041dc107c0418c0a91041dc107b040ac0a90", + "0x14fe0549820ee08028700a053b820e0082a0140a77040142405491f52290", + "0x20ee08028940a95041dc10944984844054a020ee084a020d6054a020ee08", + "0x1530083b8208c0835014f2083b8212e08338152e083b8212a960909c0a96", + "0x265300f0426c1077041e4102d02a68107704048106302a6410770414c102b", + "0x1dc10050e0140a7704030108002814ee080e020a605029dc100509015369a", + "0x153c083b8213a9c090880a9d041dc109d041ac0a9d041dc1005428153808", + "0x3c106a02a84107704280106702a801077042793e12138153e083b8200a25", + "0x20ee08508205a053c020ee0809020c60551820ee0809820560551020ee08", + "0x2941077040143805029dc100e042000a053b8200a1202a90f0a35103c10a4", + "0x144a0556020ee0853294242202a98107704298106b02a98107704014fe05", + "0x1dc105d041a80aaf041dc10ae0419c0aae041dc10ac568484e0556820ee08", + "0x2166083b8215e081681564083b82024083181562083b820c008158156008", + "0x200a0815814260f091dc100e042280a0e041dc1012042240ab3592c5600f", + "0x1dc1070351a01c8c029c010770404c108b029a81077040201063029a01077", + "0x1dc101c042380a053b8200a120287810b90e020ee12060211a0506180ba0e", + "0x9c1077040941090028941077041ac44124781444083b8201e082e014d608", + "0x19c1c0831820ee0813821220515820ee0830020c60533820ee082e8205605", + "0x174102b028b4107704078109202814ee0807820fa05029dc100509014c62b", + "0x24c0a31179841c0818820ee0816821220517820ee0830020c60530820ee08", + "0x201c08290141e083b8200a940283810770404810121101424083b8200a08", + "0x20109602820107704014100e0297426120417410770403c10950284c1077", + "0x2024083c81426083b8201c084b8140a7704014240507821740e09048ee12", + "0x200a9402814ee08028480a055d8200a990298010770404c1098029741077", + "0x1801077041a010980297410770403c1079029a0107704030109a028301077", + "0x7010bc38020ee1230021360535020ee0835021020535020ee082e820f605", + "0x20d6084e814d6083b8203c08498143c083b820e0084e0140a77040142405", + "0x200a120289c4a120409c107704088109e028941077041a81081028881077", + "0x21020515820ee08338213e0533820ee0802a500a053b8203808298140a77", + "0x2280a0f041dc1012042240a2d31848102d041dc102b042780a63041dc106a", + "0x174108b029c01077040201063029a8107704014102b0297426123b8201e08", + "0x1ac10bd0f020ee12340211a0534030c00e3b82038703503918050e020ee08", + "0x1dc102511049440512820ee0802a840a22041dc1005500140a77040142405", + "0x14c6083b82026082e01456083b820ce083c014ce083b8204e08518144e08", + "0xac10a40297010770418c1035029781077040301063028c4107704180102b", + "0x217c36041dc242f0421c0a2f308b41c77040d4b85e1883d4a051a820ee08", + "0x2158052d020ee08070e024a6028e0107704078108e02814ee08028480a3c", + "0x1dc102d040ac0a52041dc1056042240a053b820a80829814a856091dc1036", + "0x14fc083b820b40835814f8083b820a40845814f6083b820c20831814f408", + "0x200a1202a0010bf3f820ee12000215c050014c8c0e3b820fc7c3d9e81ead", + "0x20ee084120c24b002a0c107704204105c02a0902123b820fe08578140a77", + "0x2c80a85041dc10530418c0a84041dc1046040ac0a87041dc1086042c40a86", + "0xac0a89041dc1080042cc0a053b8200a1202a210a840702110083b8210e08", + "0x231168a0702118083b82112085901516083b820a6083181514083b8208c08", + "0x20ee081e0216605029dc100e041500a053b8203c08600140a77040142405", + "0x381090041dc108d042c80a8f041dc10610418c0a8e041dc102d040ac0a8d", + "0x1ac10b302814ee0809820fa05029dc100e041500a053b8200a1202a411e8e", + "0x20ee0848821640549020ee0806020c6053e820ee0830020560548820ee08", + "0x2010083181418083b8200a08158141e083b82024084481526923e8381093", + "0x20e06a340301ead029c0107704038106b029a810770403c108b029a01077", + "0x203808578140a770401424050f021821c041dc2460042b80a602e84c1c77", + "0x144e083b820d6082e0144a083b8200a9402814ee0811020a605111ac2477", + "0x20c60531820ee0809820560515820ee0833821620533820ee081289c24b0", + "0x216605029dc100509014c22d318381061041dc102b042c80a2d041dc105d", + "0x1dc102f042c80a5e041dc105d0418c0a31041dc1013040ac0a2f041dc101e", + "0x1dc100e0430c0a0e041dc1005610140a7704048107d02970bc3107020b808", + "0x3140a0f041dc100f043100a13041dc1013041a00a13041dc1005300141e08", + "0x201808638140a77040142405381a8d00e63030c05d071dc240f098200a0f", + "0x8810770407010c8029ac107704180106302878107704174102b028701077", + "0x20ee0834020560512820ee08380219405029dc1005090140ac9040153205", + "0x3300a67041dc10220432c0a22041dc1025043200a6b041dc106a0418c0a1e", + "0xac108e02814ee08028480a630433456083b8484e08468144e083b820ce08", + "0x20ee080f020560517820ee08308219e0530820ee08168219c0516820ee08", + "0x1dc100509014b85e18838105c041dc102f043400a5e041dc106b0418c0a31", + "0x3400a3c041dc106b0418c0a36041dc101e040ac0a35041dc1063043440a05", + "0x3c10770404c10d20284c10770403810a4028e078360702070083b8206a08", + "0x3010d4029a018123b8201e0869814c0083b8200a1c029741077040143805", + "0x881077041801052029ac1077041741052028781077041a010a402814ee08", + "0x942477041a8100002814ee080e020a6050e1c0d40e3b820446b0f039aa05", + "0x1e80a6315848ee0838020000533820ee0813820f605029dc1025041e80a27", + "0x1dc102d042040a67041dc1067042040a2d041dc1063041ec0a053b8205608", + "0x2500a053b8200a1202970bc310735c5e61091dc242d338200a0f6b0145a08", + "0x1dc102f0418c0a3c041dc1061040ac0a36041dc1035043600a35041dc1005", + "0x20b8086d8140a7704014240502b6810054c814b4083b8206c086c8147008", + "0x16810770415810d9028e01077041781063028f01077040c4102b029581077", + "0x14c10df23020ee122a021bc052a020ee0829021ba0529020ee082d021b805", + "0x1e810b1029e810770400024125801400083b8208c08700140a77040142405", + "0x20ee083d82164053f020ee081c020c6053e020ee081e02056053d820ee08", + "0x20010770414c10b302814ee0809020b405029dc100509014fe7e3e038107f", + "0x2041c0841820ee0840021640541020ee081c020c60540820ee081e0205605", + "0x2114052e820ee08029800a13041dc100f0430c0a0f041dc1005610150682", + "0x1dc1013043100a5d041dc105d041a00a053b82018083e8141860091dc1012", + "0x140a770401424050f070e00e711a8d0123b8481c132e8200a13708142608", + "0x20d408318144a083b820d0081581444083b820d6086c014d6083b8200a94", + "0x7810db02814ee08028480a05718200a990299c10770408810d90289c1077", + "0x20ee0815821b20513820ee080e020c60512820ee0838020560515820ee08", + "0x21c861041dc2463043780a63041dc102d043740a2d041dc1067043700a67", + "0x21cc052f020ee081898024e5028c410770418410e002814ee08028480a2f", + "0x1dc105c0439c0a36041dc10270418c0a35041dc1025040ac0a5c041dc105e", + "0x20ee0817821d005029dc1060041f40a053b8200a12028f06c35070207808", + "0x381054041dc10380439c0a56041dc10270418c0a5a041dc1025040ac0a38", + "0x20ee08040219c05029dc10050901424087502010770901410e902950ac5a", + "0x140a77040142405098201013041dc100f043400a0f041dc100e0433c0a0e", + "0x3010d00283010770418010d102980107704048ba1213814ba083b8200a25", + "0x141c083b8200a087581410080402010770401410a4029a0100834020ee08", + "0x1dc100f04048440507820ee0807820d60507820ee0802bb00a053b8200a12", + "0x14e0083b820240829014d4083b820260829014d0083b8201c08768142608", + "0x1480a1c041dc10054a0140a7704030105302830c05d071dc1070351a01ca9", + "0x88d61e0702044083b82038084a814d6083b820c008290143c083b820ba08", + "0x3c40a0e041dc1008043c00a053b8200a120284810ef04020ee1202821dc05", + "0x200a2502814ee08028480a130402026083b8201e08790141e083b8201c08", + "0x20ee0806021e40506020ee0830021e60530020ee08091742427029741077", + "0x20ee0809020a4052e820ee0807021ea0507020ee0802821e805340201068", + "0x1480a0c041dc10054a0140a770404c10530284c1e123b820c05d093d80a60", + "0x1c0d46807020e0083b82018084a814d4083b8201e0829014d0083b8201008", + "0x3e80a053b8201e087c8141e0e091dc1012043e00a1202848ee0802821ee05", + "0x20a6052e84c247704030c0127d81418083b820100829014c0083b8201c08", + "0x20ee0835021f405029dc1068043e40a6a34048ee0802821f005029dc105d", + "0x881077041c010fc02870e0123b820d61e093ec0a6b041dc1013041480a1e", + "0x20ee0809021fe0509020ee0802821fc0512888240812820ee080e021fa05", + "0x1480a0c041dc1013041ac0a053b8201e082a014260f091dc100e041580a0e", + "0x200a9402814ee0830020a605301742477041a0181223014d0083b8201008", + "0x14c0a0f33870e012040701077041a81095029c01077041741052029a81077", + "0x30c1c1204014a454298141e362a14c0a0f02838240802948a8530283c6c54", + "0x404240802968a853070bca853074001c1204014a454298141e362a14c0a0f", + "0x200a5e2a14c1c0c17950a60f81814b836090d8110204014100f0903c1812", + "0x200a612a14c1c1c2a14c1d050704810052f150a60e060bca85307c101c12", + "0x200a6b2a14c1c0c0e150a60f83838240802978a8530719c5e542983e0c12", + "0x42c2408028201e0f0703c1e67074280a670419c1109029841068044201c12", + "0x43810050403c240f1284a1a1204014100f078381e0f1383a18052e820c008", + "0x10f04014100f0903c4412" + ], + "sierra_program_debug_info": { + "type_names": [ + [ + 0, + "RangeCheck" + ], + [ + 1, + "Unit" + ], + [ + 2, + "Tuple" + ], + [ + 3, + "core::panics::Panic" + ], + [ + 4, + "Array" + ], + [ + 5, + "Tuple>" + ], + [ + 6, + "core::panics::PanicResult::<((),)>" + ], + [ + 7, + "core::result::Result::<(), core::array::Array::>" + ], + [ + 8, + "felt252" + ], + [ + 9, + "core::result::Result::>" + ], + [ + 10, + "StorageAddress" + ], + [ + 11, + "StorageBaseAddress" + ], + [ + 12, + "wallet::wallet::SimpleWallet::balance::ContractMemberState" + ], + [ + 13, + "Tuple" + ], + [ + 14, + "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::balance::ContractMemberState, ())>" + ], + [ + 15, + "u128" + ], + [ + 16, + "core::integer::u256" + ], + [ + 17, + "wallet::wallet::SimpleWallet::DummyEvent" + ], + [ + 18, + "wallet::wallet::SimpleWallet::Event" + ], + [ + 19, + "Box" + ], + [ + 20, + "core::option::Option::>" + ], + [ + 21, + "Tuple" + ], + [ + 22, + "core::panics::PanicResult::<(core::felt252,)>" + ], + [ + 23, + "wallet::wallet::SimpleWallet::ContractState" + ], + [ + 24, + "Tuple" + ], + [ + 25, + "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::ContractState, ())>" + ], + [ + 26, + "core::option::Option::" + ], + [ + 27, + "Snapshot>" + ], + [ + 28, + "core::array::Span::" + ], + [ + 29, + "Tuple>" + ], + [ + 30, + "Tuple" + ], + [ + 31, + "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::ContractState, core::felt252)>" + ], + [ + 32, + "BuiltinCosts" + ], + [ + 33, + "System" + ], + [ + 34, + "core::panics::PanicResult::<(core::array::Span::,)>" + ], + [ + 35, + "u32" + ], + [ + 36, + "GasBuiltin" + ] + ], + "libfunc_names": [ + [ + 0, + "revoke_ap_tracking" + ], + [ + 1, + "withdraw_gas" + ], + [ + 2, + "branch_align" + ], + [ + 3, + "struct_deconstruct>" + ], + [ + 4, + "array_len" + ], + [ + 5, + "snapshot_take" + ], + [ + 6, + "drop" + ], + [ + 7, + "u32_const<0>" + ], + [ + 8, + "rename" + ], + [ + 9, + "store_temp" + ], + [ + 10, + "store_temp" + ], + [ + 11, + "u32_eq" + ], + [ + 12, + "array_new" + ], + [ + 13, + "felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>" + ], + [ + 14, + "store_temp" + ], + [ + 15, + "array_append" + ], + [ + 16, + "struct_construct" + ], + [ + 17, + "struct_construct>>" + ], + [ + 18, + "enum_init,)>, 1>" + ], + [ + 19, + "store_temp" + ], + [ + 20, + "store_temp" + ], + [ + 21, + "store_temp,)>>" + ], + [ + 22, + "get_builtin_costs" + ], + [ + 23, + "store_temp" + ], + [ + 24, + "withdraw_gas_all" + ], + [ + 25, + "struct_construct" + ], + [ + 26, + "struct_construct" + ], + [ + 27, + "store_temp" + ], + [ + 28, + "function_call" + ], + [ + 29, + "enum_match>" + ], + [ + 30, + "struct_deconstruct>" + ], + [ + 31, + "drop" + ], + [ + 32, + "snapshot_take" + ], + [ + 33, + "drop" + ], + [ + 34, + "store_temp>" + ], + [ + 35, + "function_call" + ], + [ + 36, + "drop" + ], + [ + 37, + "snapshot_take>" + ], + [ + 38, + "drop>" + ], + [ + 39, + "struct_construct>" + ], + [ + 40, + "struct_construct>>" + ], + [ + 41, + "enum_init,)>, 0>" + ], + [ + 42, + "felt252_const<375233589013918064796019>" + ], + [ + 43, + "drop>" + ], + [ + 44, + "store_temp>" + ], + [ + 45, + "function_call" + ], + [ + 46, + "enum_match>" + ], + [ + 47, + "function_call" + ], + [ + 48, + "enum_match>" + ], + [ + 49, + "drop>" + ], + [ + 50, + "felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>" + ], + [ + 51, + "function_call" + ], + [ + 52, + "struct_deconstruct" + ], + [ + 53, + "snapshot_take" + ], + [ + 54, + "store_temp" + ], + [ + 55, + "function_call" + ], + [ + 56, + "enum_match>" + ], + [ + 57, + "struct_deconstruct>" + ], + [ + 58, + "struct_construct>" + ], + [ + 59, + "enum_init, 0>" + ], + [ + 60, + "store_temp>" + ], + [ + 61, + "drop" + ], + [ + 62, + "enum_init, 1>" + ], + [ + 63, + "rename" + ], + [ + 64, + "struct_construct" + ], + [ + 65, + "store_temp" + ], + [ + 66, + "array_snapshot_pop_front" + ], + [ + 67, + "enum_init>, 0>" + ], + [ + 68, + "store_temp>>" + ], + [ + 69, + "store_temp>>" + ], + [ + 70, + "jump" + ], + [ + 71, + "enum_init>, 1>" + ], + [ + 72, + "enum_match>>" + ], + [ + 73, + "unbox" + ], + [ + 74, + "enum_init, 0>" + ], + [ + 75, + "store_temp>" + ], + [ + 76, + "enum_init, 1>" + ], + [ + 77, + "u128_const<2>" + ], + [ + 78, + "u128_const<0>" + ], + [ + 79, + "struct_construct" + ], + [ + 80, + "struct_construct" + ], + [ + 81, + "enum_init" + ], + [ + 82, + "store_temp" + ], + [ + 83, + "function_call>>" + ], + [ + 84, + "felt252_add" + ], + [ + 85, + "struct_deconstruct>" + ], + [ + 86, + "function_call" + ], + [ + 87, + "enum_match>" + ], + [ + 88, + "struct_deconstruct>" + ], + [ + 89, + "struct_construct>" + ], + [ + 90, + "enum_init, 0>" + ], + [ + 91, + "store_temp>" + ], + [ + 92, + "enum_init, 1>" + ], + [ + 93, + "drop>" + ], + [ + 94, + "storage_base_address_const<916907772491729262376534102982219947830828984996257231353398618781993312401>" + ], + [ + 95, + "storage_address_from_base" + ], + [ + 96, + "store_temp" + ], + [ + 97, + "storage_read_syscall" + ], + [ + 98, + "enum_init>, 0>" + ], + [ + 99, + "store_temp>>" + ], + [ + 100, + "enum_init>, 1>" + ], + [ + 101, + "rename>>" + ], + [ + 102, + "function_call::unwrap_syscall>" + ], + [ + 103, + "struct_construct>" + ], + [ + 104, + "enum_init, 0>" + ], + [ + 105, + "store_temp>" + ], + [ + 106, + "enum_init, 1>" + ], + [ + 107, + "function_call::into>" + ], + [ + 108, + "snapshot_take" + ], + [ + 109, + "drop" + ], + [ + 110, + "function_call" + ], + [ + 111, + "emit_event_syscall" + ], + [ + 112, + "enum_init>, 0>" + ], + [ + 113, + "store_temp>>" + ], + [ + 114, + "enum_init>, 1>" + ], + [ + 115, + "rename>>" + ], + [ + 116, + "function_call::unwrap_syscall>" + ], + [ + 117, + "enum_match>" + ], + [ + 118, + "struct_deconstruct>" + ], + [ + 119, + "storage_write_syscall" + ], + [ + 120, + "struct_construct>" + ], + [ + 121, + "enum_init, 0>" + ], + [ + 122, + "store_temp>" + ], + [ + 123, + "enum_init, 1>" + ], + [ + 124, + "enum_match>>" + ], + [ + 125, + "enum_match" + ], + [ + 126, + "felt252_const<604044455298473900658797727502986337863043931241839670982572839358997980713>" + ], + [ + 127, + "store_temp" + ], + [ + 128, + "function_call" + ], + [ + 129, + "enum_match>>" + ], + [ + 130, + "struct_construct>" + ], + [ + 131, + "enum_init, 0>" + ], + [ + 132, + "store_temp>" + ], + [ + 133, + "enum_init, 1>" + ], + [ + 134, + "struct_deconstruct" + ], + [ + 135, + "store_temp" + ], + [ + 136, + "function_call" + ], + [ + 137, + "dup" + ], + [ + 138, + "struct_deconstruct" + ], + [ + 139, + "drop" + ], + [ + 140, + "store_temp" + ], + [ + 141, + "function_call" + ], + [ + 142, + "rename>" + ], + [ + 143, + "rename" + ], + [ + 144, + "rename" + ], + [ + 145, + "u128_to_felt252" + ] + ], + "user_func_names": [ + [ + 0, + "wallet::wallet::SimpleWallet::__wrapper_get_balance" + ], + [ + 1, + "wallet::wallet::SimpleWallet::__wrapper_increase_balance" + ], + [ + 2, + "wallet::wallet::SimpleWallet::__wrapper_constructor" + ], + [ + 3, + "wallet::wallet::SimpleWallet::SimpleWallet::get_balance" + ], + [ + 4, + "core::Felt252Serde::serialize" + ], + [ + 5, + "core::Felt252Serde::deserialize" + ], + [ + 6, + "wallet::wallet::SimpleWallet::SimpleWallet::increase_balance" + ], + [ + 7, + "wallet::wallet::SimpleWallet::constructor" + ], + [ + 8, + "wallet::wallet::SimpleWallet::balance::InternalContractMemberStateImpl::read" + ], + [ + 9, + "wallet::wallet::SimpleWallet::ContractStateEventEmitter::emit::>" + ], + [ + 10, + "wallet::wallet::SimpleWallet::balance::InternalContractMemberStateImpl::write" + ], + [ + 11, + "core::starknet::SyscallResultTraitImpl::::unwrap_syscall" + ], + [ + 12, + "core::traits::TIntoT::::into" + ], + [ + 13, + "wallet::wallet::SimpleWallet::EventIsEvent::append_keys_and_data" + ], + [ + 14, + "core::starknet::SyscallResultTraitImpl::<()>::unwrap_syscall" + ], + [ + 15, + "wallet::wallet::SimpleWallet::DummyEventIsEvent::append_keys_and_data" + ], + [ + 16, + "core::integer::u256Serde::serialize" + ], + [ + 17, + "core::integer::U128Serde::serialize" + ] + ] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320", + "function_idx": 1 + }, + { + "selector": "0x39e11d48192e4333233c7eb19d10ad67c362bb28580c604d67884c85da39695", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "function_idx": 2 + } + ] + }, + "abi": [ + { + "type": "impl", + "name": "SimpleWallet", + "interface_name": "wallet::wallet::ISimpleWallet" + }, + { + "type": "interface", + "name": "wallet::wallet::ISimpleWallet", + "items": [ + { + "type": "function", + "name": "get_balance", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "increase_balance", + "inputs": [ + { + "name": "amount", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "initial_balance", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "event", + "name": "wallet::wallet::SimpleWallet::DummyEvent", + "kind": "struct", + "members": [ + { + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "wallet::wallet::SimpleWallet::Event", + "kind": "enum", + "variants": [ + { + "name": "DummyEvent", + "type": "wallet::wallet::SimpleWallet::DummyEvent", + "kind": "nested" + } + ] + } + ] +} \ No newline at end of file diff --git a/cli/src/main.rs b/cli/src/main.rs index c2dcbe052..177f70f55 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -202,7 +202,7 @@ fn invoke_parser( Some(Felt252::zero()), transaction_hash.unwrap(), )?; - let mut transactional_state = cached_state.create_transactional(); + let mut transactional_state = cached_state.create_transactional()?; let _tx_info = internal_invoke.apply(&mut transactional_state, &BlockContext::default(), 0)?; cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state)?)?; diff --git a/examples/contract_execution/main.rs b/examples/contract_execution/main.rs index cc7bb8a02..0bea3e760 100644 --- a/examples/contract_execution/main.rs +++ b/examples/contract_execution/main.rs @@ -24,7 +24,16 @@ use starknet_in_rust::{ }; use std::{path::Path, sync::Arc}; +use tracing_subscriber::EnvFilter; + fn main() { + tracing::subscriber::set_global_default( + tracing_subscriber::FmtSubscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .finish(), + ) + .unwrap(); + // replace this with the path to your compiled contract let contract_path = "starknet_programs/fibonacci.json"; diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index f1ab212ff..266ad1074 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -96,7 +96,7 @@ fn run_contract( // Store the local cache changes into the shared cache. This updates the shared cache with all // the contracts used on this state. - contract_cache.extend(state.drain_private_contract_class_cache()); + contract_cache.extend(state.drain_private_contract_class_cache().unwrap()); invoke_tx_execution_info.call_info.unwrap().retdata } diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 8bac1f09e..319652bc3 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -176,7 +176,7 @@ fn main() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [Felt252::from_bytes_be(data_to_ascii(data).as_bytes())].to_vec(), - execution_resources: ExecutionResources::default(), + execution_resources: Some(ExecutionResources::default()), class_hash: Some(class_hash), storage_read_values: vec![Felt252::from_bytes_be(data_to_ascii(data).as_bytes())], accessed_storage_keys: expected_accessed_storage_keys, diff --git a/rpc_state_reader/Cargo.toml b/rpc_state_reader/Cargo.toml index 370ee93d4..0cdbbf8ef 100644 --- a/rpc_state_reader/Cargo.toml +++ b/rpc_state_reader/Cargo.toml @@ -21,7 +21,7 @@ flate2 = "1.0.25" serde_with = "3.0.0" dotenv = "0.15.0" cairo-vm = "0.8.5" -blockifier = "0.2.0-rc0" +blockifier = "=0.2.0-rc0" starknet_in_rust = { path = "../", version = "0.4.0" } [dev-dependencies] diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 2ae84fab1..094029c55 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -138,7 +138,7 @@ mod tests { ); assert_eq!( - tx_trace.validate_invocation.calldata, + tx_trace.validate_invocation.as_ref().unwrap().calldata, Some(vec![ stark_felt!("1"), stark_felt!("690c876e61beda61e994543af68038edac4e1cb1990ab06e52a2d27e56a1232"), @@ -157,9 +157,16 @@ mod tests { stark_felt!("38bd34c31a0a5c"), ]) ); - assert_eq!(tx_trace.validate_invocation.retdata, Some(vec![])); + assert_eq!( + tx_trace.validate_invocation.as_ref().unwrap().retdata, + Some(vec![]) + ); assert_eq_sorted!( - tx_trace.validate_invocation.execution_resources, + tx_trace + .validate_invocation + .as_ref() + .unwrap() + .execution_resources, ExecutionResources { n_steps: 790, n_memory_holes: 51, @@ -170,7 +177,15 @@ mod tests { ]), } ); - assert_eq!(tx_trace.validate_invocation.internal_calls.len(), 1); + assert_eq!( + tx_trace + .validate_invocation + .as_ref() + .unwrap() + .internal_calls + .len(), + 1 + ); assert_eq!( tx_trace.function_invocation.as_ref().unwrap().calldata, @@ -243,7 +258,7 @@ mod tests { ); assert_eq!( - tx_trace.fee_transfer_invocation.calldata, + tx_trace.fee_transfer_invocation.as_ref().unwrap().calldata, Some(vec![ stark_felt!("1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"), stark_felt!("2b0322a23ba4"), @@ -251,11 +266,15 @@ mod tests { ]) ); assert_eq!( - tx_trace.fee_transfer_invocation.retdata, + tx_trace.fee_transfer_invocation.as_ref().unwrap().retdata, Some(vec![1u128.into()]) ); assert_eq_sorted!( - tx_trace.fee_transfer_invocation.execution_resources, + tx_trace + .fee_transfer_invocation + .as_ref() + .unwrap() + .execution_resources, ExecutionResources { n_steps: 586, n_memory_holes: 42, @@ -265,7 +284,15 @@ mod tests { ]), } ); - assert_eq!(tx_trace.fee_transfer_invocation.internal_calls.len(), 1); + assert_eq!( + tx_trace + .fee_transfer_invocation + .as_ref() + .unwrap() + .internal_calls + .len(), + 1 + ); } #[test] diff --git a/rpc_state_reader/src/rpc_state.rs b/rpc_state_reader/src/rpc_state.rs index 3ff561339..60bfd21b2 100644 --- a/rpc_state_reader/src/rpc_state.rs +++ b/rpc_state_reader/src/rpc_state.rs @@ -11,6 +11,7 @@ use starknet_api::{ state::StorageKey, transaction::{Transaction as SNTransaction, TransactionHash}, }; +use starknet_in_rust::definitions::block_context::StarknetChainId; use std::{collections::HashMap, env, fmt::Display}; use thiserror::Error; @@ -24,6 +25,16 @@ pub enum RpcChain { TestNet2, } +impl From for StarknetChainId { + fn from(network: RpcChain) -> StarknetChainId { + match network { + RpcChain::MainNet => StarknetChainId::MainNet, + RpcChain::TestNet => StarknetChainId::TestNet, + RpcChain::TestNet2 => StarknetChainId::TestNet2, + } + } +} + impl fmt::Display for RpcChain { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -147,9 +158,9 @@ pub struct RpcResponse { #[derive(Debug, Deserialize, Clone, Eq, PartialEq)] pub struct TransactionTrace { - pub validate_invocation: RpcCallInfo, + pub validate_invocation: Option, pub function_invocation: Option, - pub fee_transfer_invocation: RpcCallInfo, + pub fee_transfer_invocation: Option, pub signature: Vec, pub revert_error: Option, } @@ -390,12 +401,12 @@ impl RpcState { } } - pub fn get_contract_class(&self, class_hash: &ClassHash) -> SNContractClass { + pub fn get_contract_class(&self, class_hash: &ClassHash) -> Option { self.rpc_call_result( "starknet_getClass", &json!([self.block.to_value().unwrap(), class_hash.0.to_string()]), ) - .unwrap() + .ok() } pub fn get_class_hash_at(&self, contract_address: &ContractAddress) -> ClassHash { @@ -407,7 +418,7 @@ impl RpcState { contract_address.0.key().clone().to_string() ]), ) - .unwrap(); + .unwrap_or_default(); ClassHash(hash) } @@ -420,7 +431,8 @@ impl RpcState { contract_address.0.key().clone().to_string() ]), ) - .unwrap() + // When running deploy_account transactions, the nonce doesn't exist on the previous block so we return 0 + .unwrap_or_default() } pub fn get_storage_at( @@ -439,7 +451,7 @@ impl RpcState { self.block.to_value().unwrap() ]), ) - .unwrap() + .unwrap_or_default() } /// Requests the given transaction to the Feeder Gateway API. diff --git a/rpc_state_reader/src/utils.rs b/rpc_state_reader/src/utils.rs index a56d9f3b7..1a5ecffb4 100644 --- a/rpc_state_reader/src/utils.rs +++ b/rpc_state_reader/src/utils.rs @@ -11,7 +11,7 @@ use starknet_api::{ core::EntryPointSelector, deprecated_contract_class::{EntryPoint, EntryPointOffset, EntryPointType}, hash::{StarkFelt, StarkHash}, - transaction::{InvokeTransaction, Transaction}, + transaction::{DeclareTransaction, InvokeTransaction, Transaction}, }; #[derive(Debug, Deserialize)] @@ -82,6 +82,24 @@ pub fn deserialize_transaction_json( "unimplemented invoke version: {x}" ))), }, + "DEPLOY_ACCOUNT" => Ok(Transaction::DeployAccount(serde_json::from_value( + transaction, + )?)), + "DECLARE" => match tx_version.as_str() { + "0x0" => Ok(Transaction::Declare(DeclareTransaction::V0( + serde_json::from_value(transaction)?, + ))), + "0x1" => Ok(Transaction::Declare(DeclareTransaction::V1( + serde_json::from_value(transaction)?, + ))), + "0x2" => Ok(Transaction::Declare(DeclareTransaction::V2( + serde_json::from_value(transaction)?, + ))), + x => Err(serde::de::Error::custom(format!( + "unimplemented declare version: {x}" + ))), + }, + "L1_HANDLER" => Ok(Transaction::L1Handler(serde_json::from_value(transaction)?)), x => Err(serde::de::Error::custom(format!( "unimplemented transaction type deserialization: {x}" ))), diff --git a/rpc_state_reader/tests/blockifier_tests.rs b/rpc_state_reader/tests/blockifier_tests.rs index a32139934..584464929 100644 --- a/rpc_state_reader/tests/blockifier_tests.rs +++ b/rpc_state_reader/tests/blockifier_tests.rs @@ -3,11 +3,16 @@ use blockifier::{ execution::{contract_class::ContractClass, entry_point::CallInfo}, state::{ cached_state::{CachedState, GlobalContractCache}, + errors::StateError, state_api::{StateReader, StateResult}, }, transaction::{ - account_transaction::AccountTransaction, objects::TransactionExecutionInfo, - transactions::ExecutableTransaction, + account_transaction::AccountTransaction, + objects::TransactionExecutionInfo, + transactions::{ + DeclareTransaction, DeployAccountTransaction, ExecutableTransaction, + L1HandlerTransaction, + }, }, }; use blockifier::{ @@ -27,7 +32,10 @@ use starknet::core::types::ContractClass as SNContractClass; use starknet_api::{ block::BlockNumber, contract_address, - core::{ClassHash, CompiledClassHash, ContractAddress, Nonce, PatriciaKey}, + core::{ + calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, + PatriciaKey, + }, hash::{StarkFelt, StarkHash}, patricia_key, stark_felt, state::StorageKey, @@ -62,7 +70,7 @@ impl StateReader for RpcStateReader { class_hash: &ClassHash, ) -> StateResult { Ok(match self.0.get_contract_class(class_hash) { - SNContractClass::Legacy(compressed_legacy_cc) => { + Some(SNContractClass::Legacy(compressed_legacy_cc)) => { let as_str = utils::decode_reader(compressed_legacy_cc.program).unwrap(); let program = Program::from_bytes(as_str.as_bytes(), None).unwrap(); let entry_points_by_type = utils::map_entry_points_by_type_legacy( @@ -74,7 +82,7 @@ impl StateReader for RpcStateReader { }); BlockifierContractClass::V0(ContractClassV0(inner)) } - SNContractClass::Sierra(flattened_sierra_cc) => { + Some(SNContractClass::Sierra(flattened_sierra_cc)) => { let middle_sierra: utils::MiddleSierraContractClass = { let v = serde_json::to_value(flattened_sierra_cc).unwrap(); serde_json::from_value(v).unwrap() @@ -89,6 +97,7 @@ impl StateReader for RpcStateReader { let casm_cc = CasmContractClass::from_contract_class(sierra_cc, false).unwrap(); BlockifierContractClass::V1(casm_cc.try_into().unwrap()) } + None => return Err(StateError::UndeclaredClassHash(*class_hash)), }) } @@ -176,6 +185,46 @@ pub fn execute_tx( let invoke = InvokeTransaction { tx, tx_hash }; AccountTransaction::Invoke(invoke) } + SNTransaction::DeployAccount(tx) => { + let contract_address = calculate_contract_address( + tx.contract_address_salt, + tx.class_hash, + &tx.constructor_calldata, + ContractAddress::default(), + ) + .unwrap(); + AccountTransaction::DeployAccount(DeployAccountTransaction { + tx, + tx_hash, + contract_address, + }) + } + SNTransaction::Declare(tx) => { + // Fetch the contract_class from the next block (as we don't have it in the previous one) + let mut next_block_state_reader = + RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); + let contract_class = next_block_state_reader + .get_compiled_contract_class(&tx.class_hash()) + .unwrap(); + + let declare = DeclareTransaction::new(tx, tx_hash, contract_class).unwrap(); + AccountTransaction::Declare(declare) + } + SNTransaction::L1Handler(tx) => { + // As L1Hanlder is not an account transaction we execute it here and return the result + let blockifier_tx = L1HandlerTransaction { + tx, + tx_hash, + paid_fee_on_l1: starknet_api::transaction::Fee(u128::MAX), + }; + return ( + blockifier_tx + .execute(&mut state, &block_context, true, true) + .unwrap(), + trace, + receipt, + ); + } _ => unimplemented!(), }; @@ -286,6 +335,46 @@ fn blockifier_test_recent_tx() { 186551, // real block 186552 RpcChain::MainNet )] +#[test_case( + "0x1cbc74e101a1533082a021ce53235cfd744899b0ff948d1949a64646e0f15c2", + 885298, // real block 885299 + RpcChain::TestNet +)] +#[test_case( + "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", + 281513, // real block 281514 + RpcChain::MainNet +)] +#[test_case( + "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", + 351268, // real block 351269 + RpcChain::MainNet +)] +#[test_case( + "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", + 351225, // real block 351226 + RpcChain::MainNet +)] +// DeployAccount for different account providers (as of October 2023): +// All of them were deployed on testnet using starkli +// OpenZeppelin (v0.7.0) +#[test_case( + "0x0012696c03a0f0301af190288d9824583be813b71882308e4c5d686bf5967ec5", + 889866, // real block 889867 + RpcChain::TestNet +)] +// Braavos (v3.21.10) +#[test_case( + "0x04dc838fd4ed265ab2ea5fbab08e67b398e3caaedf75c548113c6b2f995fc9db", + 889858, // real block 889859 + RpcChain::TestNet +)] +// Argent X (v5.7.0) +#[test_case( + "0x01583c47a929f81f6a8c74d31708a7f161603893435d51b6897017fdcdaafee4", + 889897, // real block 889898 + RpcChain::TestNet +)] fn blockifier_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) { let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -357,3 +446,38 @@ fn blockifier_test_case_reverted_tx(hash: &str, block_number: u64, chain: RpcCha ); } } + +#[test_case( + // Declare tx + "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", + 347899, // real block 347900 + RpcChain::MainNet +)] +#[test_case( + // Declare tx + "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", + 271887, // real block 271888 + RpcChain::MainNet +)] +fn blockifier_test_case_declare_tx(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); + let TransactionExecutionInfo { + execute_call_info, + actual_fee, + .. + } = tx_info; + + assert!(execute_call_info.is_none()); + + let actual_fee = actual_fee.0; + if receipt.actual_fee != actual_fee { + let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; + + if diff >= 5 { + assert_eq!( + actual_fee, receipt.actual_fee, + "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", + ); + } + } +} diff --git a/rpc_state_reader/tests/sir_tests.rs b/rpc_state_reader/tests/sir_tests.rs index 8e49d1aaa..44d480490 100644 --- a/rpc_state_reader/tests/sir_tests.rs +++ b/rpc_state_reader/tests/sir_tests.rs @@ -8,10 +8,10 @@ use starknet_api::{ hash::{StarkFelt, StarkHash}, stark_felt, state::StorageKey, - transaction::{Transaction as SNTransaction, TransactionHash}, + transaction::{Transaction as SNTransaction, TransactionHash, TransactionVersion}, }; use starknet_in_rust::{ - core::errors::state_errors::StateError, + core::{contract_address::compute_casm_class_hash, errors::state_errors::StateError}, definitions::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, constants::{ @@ -26,7 +26,7 @@ use starknet_in_rust::{ cached_state::CachedState, contract_class_cache::PermanentContractClassCache, state_api::StateReader, state_cache::StorageEntry, BlockInfo, }, - transaction::{InvokeFunction, Transaction}, + transaction::{Declare, DeclareV2, DeployAccount, InvokeFunction, L1Handler}, utils::{Address, ClassHash}, }; @@ -34,12 +34,15 @@ use test_case::test_case; use rpc_state_reader::rpc_state::*; +#[derive(Debug)] pub struct RpcStateReader(RpcState); impl StateReader for RpcStateReader { fn get_contract_class(&self, class_hash: &ClassHash) -> Result { let hash = SNClassHash(StarkHash::new(*class_hash).unwrap()); - Ok(CompiledClass::from(self.0.get_contract_class(&hash))) + Ok(CompiledClass::from( + self.0.get_contract_class(&hash).unwrap(), + )) } fn get_class_hash_at(&self, contract_address: &Address) -> Result { @@ -84,10 +87,12 @@ impl StateReader for RpcStateReader { } #[allow(unused)] -pub fn execute_tx( +pub fn execute_tx_configurable( tx_hash: &str, network: RpcChain, block_number: BlockNumber, + skip_validate: bool, + skip_nonce_check: bool, ) -> ( TransactionExecutionInfo, TransactionTrace, @@ -135,9 +140,79 @@ pub fn execute_tx( // Get transaction before giving ownership of the reader let tx_hash = TransactionHash(stark_felt!(tx_hash)); let tx = match rpc_reader.0.get_transaction(&tx_hash) { - SNTransaction::Invoke(tx) => Transaction::InvokeFunction( - InvokeFunction::from_invoke_transaction(tx, chain_id).unwrap(), - ), + SNTransaction::Invoke(tx) => InvokeFunction::from_invoke_transaction(tx, chain_id) + .unwrap() + .create_for_simulation(skip_validate, false, false, false, skip_nonce_check), + SNTransaction::DeployAccount(tx) => { + DeployAccount::from_sn_api_transaction(tx, chain_id.to_felt()) + .unwrap() + .create_for_simulation(skip_validate, false, false, false) + } + SNTransaction::Declare(tx) => { + // Fetch the contract_class from the next block (as we don't have it in the previous one) + let next_block_state_reader = + RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); + let contract_class = next_block_state_reader + .get_contract_class(tx.class_hash().0.bytes().try_into().unwrap()) + .unwrap(); + + if tx.version() != TransactionVersion(2_u8.into()) { + let contract_class = match contract_class { + CompiledClass::Deprecated(cc) => cc.as_ref().clone(), + _ => unreachable!(), + }; + + let declare = Declare::new_with_tx_and_class_hash( + contract_class, + Address(Felt252::from_bytes_be(tx.sender_address().0.key().bytes())), + tx.max_fee().0, + Felt252::from_bytes_be(tx.version().0.bytes()), + tx.signature() + .0 + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(), + Felt252::from_bytes_be(tx.nonce().0.bytes()), + Felt252::from_bytes_be(tx_hash.0.bytes()), + tx.class_hash().0.bytes().try_into().unwrap(), + ) + .unwrap(); + declare.create_for_simulation(skip_validate, false, false, false) + } else { + let contract_class = match contract_class { + CompiledClass::Casm(cc) => cc.as_ref().clone(), + _ => unreachable!(), + }; + + let compiled_class_hash = compute_casm_class_hash(&contract_class).unwrap(); + + let declare = DeclareV2::new_with_sierra_class_hash_and_tx_hash( + None, + Felt252::from_bytes_be(tx.class_hash().0.bytes()), + Some(contract_class), + compiled_class_hash, + Address(Felt252::from_bytes_be(tx.sender_address().0.key().bytes())), + tx.max_fee().0, + Felt252::from_bytes_be(tx.version().0.bytes()), + tx.signature() + .0 + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(), + Felt252::from_bytes_be(tx.nonce().0.bytes()), + Felt252::from_bytes_be(tx_hash.0.bytes()), + ) + .unwrap(); + declare.create_for_simulation(skip_validate, false, false, false) + } + } + SNTransaction::L1Handler(tx) => L1Handler::from_sn_api_tx( + tx, + Felt252::from_bytes_be(tx_hash.0.bytes()), + Some(Felt252::from(u128::MAX)), + ) + .unwrap() + .create_for_simulation(skip_validate, false), _ => unimplemented!(), }; @@ -166,6 +241,30 @@ pub fn execute_tx( ) } +pub fn execute_tx( + tx_hash: &str, + network: RpcChain, + block_number: BlockNumber, +) -> ( + TransactionExecutionInfo, + TransactionTrace, + RpcTransactionReceipt, +) { + execute_tx_configurable(tx_hash, network, block_number, false, false) +} + +pub fn execute_tx_without_validate( + tx_hash: &str, + network: RpcChain, + block_number: BlockNumber, +) -> ( + TransactionExecutionInfo, + TransactionTrace, + RpcTransactionReceipt, +) { + execute_tx_configurable(tx_hash, network, block_number, true, true) +} + #[test] fn test_get_transaction_try_from() { let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); @@ -243,6 +342,51 @@ fn test_get_gas_price() { 186551, // real block 186552 RpcChain::MainNet )] +#[test_case( + "0x176a92e8df0128d47f24eebc17174363457a956fa233cc6a7f8561bfbd5023a", + 317092, // real block 317093 + RpcChain::MainNet +)] +#[test_case( + "0x1cbc74e101a1533082a021ce53235cfd744899b0ff948d1949a64646e0f15c2", + 885298, // real block 885299 + RpcChain::TestNet +)] +#[test_case( + "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", + 281513, // real block 281514 + RpcChain::MainNet +)] +#[test_case( + "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", + 351268, // real block 351269 + RpcChain::MainNet +)] +#[test_case( + "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", + 351225, // real block 351226 + RpcChain::MainNet +)] +// DeployAccount for different account providers (as of October 2023): +// All of them were deployed on testnet using starkli +// OpenZeppelin (v0.7.0) +#[test_case( + "0x0012696c03a0f0301af190288d9824583be813b71882308e4c5d686bf5967ec5", + 889866, // real block 889867 + RpcChain::TestNet +)] +// Braavos (v3.21.10) +#[test_case( + "0x04dc838fd4ed265ab2ea5fbab08e67b398e3caaedf75c548113c6b2f995fc9db", + 889858, // real block 889859 + RpcChain::TestNet +)] +// Argent X (v5.7.0) +#[test_case( + "0x01583c47a929f81f6a8c74d31708a7f161603893435d51b6897017fdcdaafee4", + 889897, // real block 889898 + RpcChain::TestNet +)] fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) { let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -260,12 +404,14 @@ fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) // check Cairo VM execution resources assert_eq_sorted!( - execution_resources, - trace - .function_invocation - .as_ref() - .unwrap() - .execution_resources, + execution_resources.as_ref(), + Some( + &trace + .function_invocation + .as_ref() + .unwrap() + .execution_resources + ), "execution resources mismatch" ); @@ -356,3 +502,52 @@ fn starknet_in_rust_test_case_reverted_tx(hash: &str, block_number: u64, chain: ); } } + +#[test_case( + "0x038c307a0a324dc92778820f2c6317f40157c06b12a7e537f7a16b2c015f64e7", + 274333-1, + RpcChain::MainNet +)] +fn test_validate_fee(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); + let (tx_info_without_fee, _trace, _receipt) = + execute_tx_without_validate(hash, chain, BlockNumber(block_number)); + + assert_eq!(tx_info.actual_fee, receipt.actual_fee); + assert!(tx_info_without_fee.actual_fee < tx_info.actual_fee); +} + +#[test_case( + // Declare tx + "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", + 347899, // real block 347900 + RpcChain::MainNet +)] +#[test_case( + // Declare tx + "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", + 271887, // real block 271888 + RpcChain::MainNet +)] +fn starknet_in_rust_test_case_declare_tx(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); + let TransactionExecutionInfo { + call_info, + actual_fee, + .. + } = tx_info; + + assert!(call_info.is_none()); + + let actual_fee = actual_fee; + if receipt.actual_fee != actual_fee { + let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; + + if diff >= 5 { + assert_eq!( + actual_fee, receipt.actual_fee, + "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", + ); + } + } +} diff --git a/rust-toolchain b/rust-toolchain index 2d24a1e07..baa36b056 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.72.1" components = ["rustfmt", "clippy"] profile = "minimal" diff --git a/src/core/contract_address/casm_contract_address.rs b/src/core/contract_address/casm_contract_address.rs index 537146e23..23dc701e8 100644 --- a/src/core/contract_address/casm_contract_address.rs +++ b/src/core/contract_address/casm_contract_address.rs @@ -112,7 +112,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/contract_a.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm").unwrap(); expected_result = felt_str!( "321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f", 16 @@ -144,7 +144,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/deploy.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm").unwrap(); expected_result = felt_str!( "53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0", 16 @@ -177,7 +177,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/fibonacci.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm").unwrap(); expected_result = felt_str!( "6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89", 16 @@ -210,7 +210,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/factorial.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm").unwrap(); expected_result = felt_str!( "7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641", 16 @@ -243,7 +243,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/emit_event.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm").unwrap(); expected_result = felt_str!( "3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2", 16 @@ -271,7 +271,7 @@ mod tests { #[test] fn test_declare_tx_class_hash() { - let file = File::open("starknet_programs/cairo2/events.casm").unwrap(); + let file = File::open("starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm").unwrap(); let reader = BufReader::new(file); let contract_class: CasmContractClass = serde_json::from_reader(reader).unwrap(); diff --git a/src/core/contract_address/deprecated_contract_address.rs b/src/core/contract_address/deprecated_contract_address.rs index 325902d45..07e7e2911 100644 --- a/src/core/contract_address/deprecated_contract_address.rs +++ b/src/core/contract_address/deprecated_contract_address.rs @@ -158,7 +158,7 @@ impl serde_json::ser::Formatter for PythonDefaultFormatter { } else { let buf = c.encode_utf16(&mut buf); for i in buf { - write!(writer, r"\u{:4x}", i)?; + write!(writer, r"\u{:04x}", i)?; } } } diff --git a/src/core/contract_address/sierra_contract_address.rs b/src/core/contract_address/sierra_contract_address.rs index 1bbcfb1e9..a4df995c2 100644 --- a/src/core/contract_address/sierra_contract_address.rs +++ b/src/core/contract_address/sierra_contract_address.rs @@ -4,7 +4,10 @@ use cairo_lang_starknet::{ contract_class::{ContractClass as SierraContractClass, ContractEntryPoint}, }; use cairo_vm::felt::Felt252; +use serde::Serialize; +use serde_json::ser::Formatter; use starknet_crypto::{poseidon_hash_many, FieldElement, PoseidonHasher}; +use std::io::{self, Cursor}; const CONTRACT_CLASS_VERSION: &[u8] = b"CONTRACT_CLASS_V0.1.0"; @@ -60,14 +63,22 @@ pub fn compute_sierra_class_hash( hasher.update(constructors); // Hash abi - let abi = serde_json_pythonic::to_string_pythonic( - &contract_class + let abi = { + let mut buf = Cursor::new(Vec::new()); + let mut fmt = serde_json::Serializer::with_formatter(&mut buf, PythonJsonFormatter); + + contract_class .abi .as_ref() .ok_or(ContractAddressError::MissingAbi)? - .items, - ) - .map_err(|_| ContractAddressError::MissingAbi)?; + .items + .serialize(&mut fmt) + .map_err(|_| ContractAddressError::MissingAbi)?; + + // Note: The following unwrap should never be triggered as long as serde_json generates + // UTF-8 encoded data, which in practice means it should never panic. + String::from_utf8(buf.into_inner()).unwrap() + }; let abi_hash = FieldElement::from_byte_slice_be(&starknet_keccak(abi.as_bytes()).to_bytes_be()) .map_err(|_err| { @@ -126,7 +137,8 @@ mod tests { /// Test the correctness of the compute_sierra_class_hash function for a specific testnet contract. #[test] fn test_declare_tx_from_testnet() { - let file = File::open("starknet_programs/cairo2/events.sierra").unwrap(); + let file = File::open("starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra").unwrap(); + // 0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3 let reader = BufReader::new(file); let sierra_contract_class: SierraContractClass = serde_json::from_reader(reader).unwrap(); @@ -142,3 +154,56 @@ mod tests { ) } } + +struct PythonJsonFormatter; + +impl Formatter for PythonJsonFormatter { + fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> + where + W: ?Sized + io::Write, + { + if first { + Ok(()) + } else { + writer.write_all(b", ") + } + } + + fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> + where + W: ?Sized + io::Write, + { + if first { + Ok(()) + } else { + writer.write_all(b", ") + } + } + + fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> + where + W: ?Sized + io::Write, + { + writer.write_all(b": ") + } + + fn write_string_fragment(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> + where + W: ?Sized + io::Write, + { + let mut buf = [0, 0]; + + for c in fragment.chars() { + if c.is_ascii() { + writer.write_all(&[c as u8])?; + } else { + let buf = c.encode_utf16(&mut buf); + for i in buf { + write!(writer, r"\u{i:04x}")?; + } + } + } + + Ok(()) + } +} diff --git a/src/core/errors/state_errors.rs b/src/core/errors/state_errors.rs index 7d6b3aa89..ba09e3e51 100644 --- a/src/core/errors/state_errors.rs +++ b/src/core/errors/state_errors.rs @@ -48,4 +48,6 @@ pub enum StateError { CustomError(String), #[error(transparent)] ByteArray(#[from] FromByteArrayError), + #[error("Failed to read contract class cache")] + FailedToReadContractClassCache, } diff --git a/src/definitions/constants.rs b/src/definitions/constants.rs index 77bf941c9..4087af325 100644 --- a/src/definitions/constants.rs +++ b/src/definitions/constants.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; pub(crate) const L2_TO_L1_MSG_HEADER_SIZE: usize = 3; pub(crate) const L1_TO_L2_MSG_HEADER_SIZE: usize = 5; -pub(crate) const DEPLOYMENT_INFO_SIZE: usize = 2; +pub(crate) const CLASS_UPDATE_SIZE: usize = 1; pub(crate) const CONSUMED_MSG_TO_L2_N_TOPICS: usize = 3; pub(crate) const LOG_MSG_TO_L1_N_TOPICS: usize = 2; pub(crate) const N_DEFAULT_TOPICS: usize = 1; // Events have one default topic. @@ -37,9 +37,9 @@ lazy_static! { 0.into(), 1.into(), 2.into(), - &0.into() | &QUERY_VERSION_BASE.clone(), - &1.into() | &QUERY_VERSION_BASE.clone(), - &2.into() | &QUERY_VERSION_BASE.clone(), + &Into::::into(0) | &QUERY_VERSION_BASE.clone(), + &Into::::into(1) | &QUERY_VERSION_BASE.clone(), + &Into::::into(2) | &QUERY_VERSION_BASE.clone(), ]; } diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 30c86cc91..c13994ca9 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -13,7 +13,7 @@ use crate::{ contract_class_cache::ContractClassCache, contract_storage_state::ContractStorageState, state_api::{State, StateReader}, - ExecutionResourcesManager, + ExecutionResourcesManager, StateDiff, }, syscalls::{ business_logic_syscall_handler::BusinessLogicSyscallHandler, @@ -41,6 +41,16 @@ use cairo_vm::{ }; use std::sync::Arc; +#[cfg(feature = "cairo-native")] +use { + crate::syscalls::native_syscall_handler::NativeSyscallHandler, + cairo_native::{ + context::NativeContext, execution_result::NativeExecutionResult, executor::NativeExecutor, + metadata::syscall_handler::SyscallHandlerMeta, utils::felt252_bigint, + }, + serde_json::Value, +}; + #[derive(Debug, Default)] pub struct ExecutionResult { pub call_info: Option, @@ -146,6 +156,45 @@ impl ExecutionEntryPoint { return Err(e); } + let n_reverted_steps = + (max_steps as usize) - resources_manager.cairo_usage.n_steps; + Ok(ExecutionResult { + call_info: None, + revert_error: Some(e.to_string()), + n_reverted_steps, + }) + } + } + } + CompiledClass::Sierra(sierra_contract_class) => { + let mut transactional_state = state.create_transactional()?; + + match self.native_execute( + &mut transactional_state, + sierra_contract_class, + tx_execution_context, + block_context, + ) { + Ok(call_info) => { + state.apply_state_update(&StateDiff::from_cached_state( + transactional_state, + )?)?; + + Ok(ExecutionResult { + call_info: Some(call_info), + revert_error: None, + n_reverted_steps: 0, + }) + } + Err(e) => { + if !support_reverted { + state.apply_state_update(&StateDiff::from_cached_state( + transactional_state, + )?)?; + + return Err(e); + } + let n_reverted_steps = (max_steps as usize) - resources_manager.cairo_usage.n_steps; Ok(ExecutionResult { @@ -174,15 +223,15 @@ impl ExecutionEntryPoint { let mut default_entry_point = None; let entry_point = entry_points .iter() - .filter_map(|x| { + .filter(|x| { if x.selector() == &*DEFAULT_ENTRY_POINT_SELECTOR { - default_entry_point = Some(x); + default_entry_point = Some(*x); } - (x.selector() == &self.entry_point_selector).then_some(x) + x.selector() == &self.entry_point_selector }) - .fold(Ok(None), |acc, x| match acc { - Ok(None) => Ok(Some(x)), + .try_fold(None, |acc, x| match acc { + None => Ok(Some(x)), _ => Err(TransactionError::NonUniqueEntryPoint), })?; @@ -206,15 +255,15 @@ impl ExecutionEntryPoint { let mut default_entry_point = None; let entry_point = entry_points .iter() - .filter_map(|x| { + .filter(|x| { if x.selector == DEFAULT_ENTRY_POINT_SELECTOR.to_biguint() { - default_entry_point = Some(x); + default_entry_point = Some(*x); } - (x.selector == self.entry_point_selector.to_biguint()).then_some(x) + x.selector == self.entry_point_selector.to_biguint() }) - .fold(Ok(None), |acc, x| match acc { - Ok(None) => Ok(Some(x)), + .try_fold(None, |acc, x| match acc { + None => Ok(Some(x)), _ => Err(TransactionError::NonUniqueEntryPoint), })?; entry_point @@ -245,7 +294,7 @@ impl ExecutionEntryPoint { entry_point_type: Some(self.entry_point_type), calldata: self.calldata.clone(), retdata, - execution_resources: execution_resources.filter_unused_builtins(), + execution_resources: Some(execution_resources.filter_unused_builtins()), events, l2_to_l1_messages, storage_read_values: starknet_storage_state.read_values, @@ -282,7 +331,7 @@ impl ExecutionEntryPoint { .iter() .map(|n| n.get_int_ref().cloned().unwrap_or_default()) .collect(), - execution_resources: execution_resources.filter_unused_builtins(), + execution_resources: Some(execution_resources.filter_unused_builtins()), events, l2_to_l1_messages, storage_read_values: starknet_storage_state.read_values, @@ -569,4 +618,183 @@ impl ExecutionEntryPoint { call_result, ) } + + #[cfg(not(feature = "cairo-native"))] + #[inline(always)] + fn native_execute( + &self, + _state: &mut CachedState, + _contract_class: Arc, + _tx_execution_context: &mut TransactionExecutionContext, + _block_context: &BlockContext, + ) -> Result { + Err(TransactionError::SierraCompileError( + "This version of SiR was compiled without the Cairo Native feature".to_string(), + )) + } + + #[cfg(feature = "cairo-native")] + #[inline(always)] + fn native_execute( + &self, + state: &mut CachedState, + contract_class: Arc, + tx_execution_context: &TransactionExecutionContext, + block_context: &BlockContext, + ) -> Result { + use cairo_lang_sierra::{ + extensions::core::{CoreLibfunc, CoreType, CoreTypeConcrete}, + program_registry::ProgramRegistry, + }; + use serde_json::json; + + use crate::syscalls::business_logic_syscall_handler::SYSCALL_BASE; + + let entry_point = match self.entry_point_type { + EntryPointType::External => contract_class + .entry_points_by_type + .external + .iter() + .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) + .unwrap(), + EntryPointType::Constructor => contract_class + .entry_points_by_type + .constructor + .iter() + .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) + .unwrap(), + EntryPointType::L1Handler => contract_class + .entry_points_by_type + .l1_handler + .iter() + .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) + .unwrap(), + }; + + let sierra_program = contract_class.extract_sierra_program().unwrap(); + let program_registry: ProgramRegistry = + ProgramRegistry::new(&sierra_program).unwrap(); + + let native_context = NativeContext::new(); + let mut native_program = native_context.compile(&sierra_program).unwrap(); + let contract_storage_state = + ContractStorageState::new(state, self.contract_address.clone()); + + let syscall_handler = NativeSyscallHandler { + starknet_storage_state: contract_storage_state, + events: Vec::new(), + l2_to_l1_messages: Vec::new(), + contract_address: self.contract_address.clone(), + internal_calls: Vec::new(), + caller_address: self.caller_address.clone(), + entry_point_selector: self.entry_point_selector.clone(), + tx_execution_context: tx_execution_context.clone(), + block_context: block_context.clone(), + resources_manager: Default::default(), + }; + + native_program + .insert_metadata(SyscallHandlerMeta::new(&syscall_handler)) + .unwrap(); + + let syscall_addr = native_program + .get_metadata::() + .unwrap() + .as_ptr() + .as_ptr() as *const () as usize; + + let entry_point_fn = &sierra_program + .funcs + .iter() + .find(|x| x.id.id == (entry_point.function_idx as u64)) + .unwrap(); + let ret_types: Vec<&CoreTypeConcrete> = entry_point_fn + .signature + .ret_types + .iter() + .map(|x| program_registry.get_type(x).unwrap()) + .collect(); + let entry_point_id = &entry_point_fn.id; + + let required_init_gas = native_program.get_required_init_gas(entry_point_id); + + let calldata: Vec<_> = self + .calldata + .iter() + .map(|felt| felt252_bigint(felt.to_bigint())) + .collect(); + + /* + Below we construct `params`, the Serde value that MLIR expects. It consists of the following: + + - One `null` value for each builtin that is going to be used. + - The maximum amout of gas allowed by the call. + - `syscall_addr`, the address of the syscall handler. + - `calldata`, an array of Felt arguments to the method being called. + */ + + let wrapped_calldata = vec![calldata]; + let params: Vec = sierra_program.funcs[entry_point_id.id as usize] + .params + .iter() + .map(|param| { + match param.ty.debug_name.as_ref().unwrap().as_str() { + "GasBuiltin" => { + json!(self.initial_gas) + } + "Pedersen" | "SegmentArena" | "RangeCheck" | "Bitwise" | "Poseidon" => { + json!(null) + } + "System" => { + json!(syscall_addr) + } + // calldata + "core::array::Span::" => json!(wrapped_calldata), + x => { + unimplemented!("unhandled param type: {:?}", x); + } + } + }) + .collect(); + + let mut writer: Vec = Vec::new(); + let returns = &mut serde_json::Serializer::new(&mut writer); + + let native_executor = NativeExecutor::new(native_program); + + native_executor + .execute(entry_point_id, json!(params), returns, required_init_gas) + .map_err(|e| TransactionError::CustomError(format!("cairo-native error: {:?}", e)))?; + + let value = NativeExecutionResult::deserialize_from_ret_types( + &mut serde_json::Deserializer::from_slice(&writer), + &ret_types, + ) + .expect("failed to serialize starknet execution result"); + + Ok(CallInfo { + caller_address: self.caller_address.clone(), + call_type: Some(self.call_type.clone()), + contract_address: self.contract_address.clone(), + code_address: self.code_address.clone(), + class_hash: Some( + self.get_code_class_hash(syscall_handler.starknet_storage_state.state)?, + ), + entry_point_selector: Some(self.entry_point_selector.clone()), + entry_point_type: Some(self.entry_point_type), + calldata: self.calldata.clone(), + retdata: value.return_values, + execution_resources: None, + events: syscall_handler.events, + storage_read_values: syscall_handler.starknet_storage_state.read_values, + accessed_storage_keys: syscall_handler.starknet_storage_state.accessed_keys, + failure_flag: value.failure_flag, + l2_to_l1_messages: syscall_handler.l2_to_l1_messages, + internal_calls: syscall_handler.internal_calls, + gas_consumed: self + .initial_gas + .saturating_sub(SYSCALL_BASE) + .saturating_sub(value.remaining_gas), + }) + } } diff --git a/src/execution/gas_usage.rs b/src/execution/gas_usage.rs index f0d254dc7..85e26a90a 100644 --- a/src/execution/gas_usage.rs +++ b/src/execution/gas_usage.rs @@ -1,6 +1,7 @@ use crate::definitions::constants::*; use crate::execution::L2toL1MessageInfo; use crate::services::eth_definitions::eth_gas_constants::*; +use crate::state::state_api::StateChangesCount; /// Estimates L1 gas usage by Starknet's update state and the verifier /// @@ -19,16 +20,13 @@ use crate::services::eth_definitions::eth_gas_constants::*; /// The estimation of L1 gas usage as a `usize` value. pub fn calculate_tx_gas_usage( l2_to_l1_messages: Vec, - n_modified_contracts: usize, - n_storage_changes: usize, + state_changes: &StateChangesCount, l1_handler_payload_size: Option, - n_deployments: usize, ) -> usize { let residual_message_segment_length = get_message_segment_lenght(&l2_to_l1_messages, l1_handler_payload_size); - let residual_onchain_data_segment_length = - get_onchain_data_segment_length(n_modified_contracts, n_storage_changes, n_deployments); + let residual_onchain_data_segment_length = get_onchain_data_segment_length(state_changes); let n_l2_to_l1_messages = l2_to_l1_messages.len(); let n_l1_to_l2_messages = match l1_handler_payload_size { @@ -95,22 +93,18 @@ pub fn get_message_segment_lenght( } /// Calculates the amount of `felt252` added to the output message's segment by the given operations. -/// -/// # Parameters: -/// -/// - `n_modified_contracts`: The number of contracts modified by the transaction. -/// - `n_storage_changes`: The number of storage changes made by the transaction. -/// - `n_deployments`: The number of contracts deployed by the transaction. -/// -/// # Returns: -/// -/// The on-chain data segment length -pub const fn get_onchain_data_segment_length( - n_modified_contracts: usize, - n_storage_changes: usize, - n_deployments: usize, -) -> usize { - n_modified_contracts * 2 + n_storage_changes * 2 + n_deployments * DEPLOYMENT_INFO_SIZE +pub const fn get_onchain_data_segment_length(state_changes: &StateChangesCount) -> usize { + // For each newly modified contract: + // contract address (1 word). + // + 1 word with the following info: A flag indicating whether the class hash was updated, the + // number of entry updates, and the new nonce. + state_changes.n_modified_contracts * 2 + // For each class updated (through a deploy or a class replacement). + + state_changes.n_class_hash_updates * CLASS_UPDATE_SIZE + // For each modified storage cell: key, new value. + + state_changes.n_storage_updates * 2 + // For each compiled class updated (through declare): class_hash, compiled_class_hash + + state_changes.n_compiled_class_hash_updates * 2 } /// Calculates the cost of ConsumedMessageToL2 event emissions caused by an L1 handler with the given @@ -261,8 +255,17 @@ mod test { let message2 = L2toL1MessageInfo::new(ord_ev2, Address(1235.into())); assert_eq!( - calculate_tx_gas_usage(vec![message1, message2], 2, 2, Some(2), 1), - 77051 + calculate_tx_gas_usage( + vec![message1, message2], + &StateChangesCount { + n_storage_updates: 2, + n_class_hash_updates: 1, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 2 + }, + Some(2) + ), + 76439 ) } } diff --git a/src/execution/mod.rs b/src/execution/mod.rs index 9fed18a67..5c9774517 100644 --- a/src/execution/mod.rs +++ b/src/execution/mod.rs @@ -43,7 +43,7 @@ pub struct CallInfo { pub entry_point_type: Option, pub calldata: Vec, pub retdata: Vec, - pub execution_resources: ExecutionResources, + pub execution_resources: Option, pub events: Vec, pub l2_to_l1_messages: Vec, pub storage_read_values: Vec, @@ -73,11 +73,11 @@ impl CallInfo { entry_point_type, calldata: Vec::new(), retdata: Vec::new(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 0, builtin_instance_counter: HashMap::new(), n_memory_holes: 0, - }, + }), events: Vec::new(), l2_to_l1_messages: Vec::new(), storage_read_values: Vec::new(), @@ -238,11 +238,11 @@ impl Default for CallInfo { l2_to_l1_messages: Vec::new(), accessed_storage_keys: HashSet::new(), calldata: Vec::new(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 0, n_memory_holes: 0, builtin_instance_counter: HashMap::new(), - }, + }), events: Vec::new(), gas_consumed: 0, failure_flag: false, @@ -291,7 +291,7 @@ impl<'de> Deserialize<'de> for CallInfo { } Ok(CallInfo { - execution_resources, + execution_resources: Some(execution_resources), retdata, calldata, internal_calls, @@ -370,6 +370,7 @@ pub struct TransactionExecutionContext { pub(crate) nonce: Felt252, pub(crate) n_sent_messages: usize, pub(crate) _n_steps: u64, + // pub(crate) use_cairo_native: bool, } impl TransactionExecutionContext { diff --git a/src/lib.rs b/src/lib.rs index b14dfc402..205b218a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -436,9 +436,10 @@ mod test { let block_context = BlockContext::default(); let Transaction::InvokeFunction(simul_invoke) = - invoke.create_for_simulation(true, false, false, false, false) else { - unreachable!() - }; + invoke.create_for_simulation(true, false, false, false, false) + else { + unreachable!() + }; let call_info = simul_invoke .run_validate_entrypoint( @@ -711,7 +712,7 @@ mod test { simulate_transaction( &[&internal_deploy], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -752,7 +753,7 @@ mod test { simulate_transaction( &[&declare_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -820,7 +821,7 @@ mod test { simulate_transaction( &[&invoke_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -867,7 +868,7 @@ mod test { simulate_transaction( &[&deploy_account_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -896,7 +897,7 @@ mod test { nonce: 0.into(), hash_value: 0.into(), compiled_class_hash: TEST_FIB_COMPILED_CONTRACT_CLASS_HASH.clone(), - sierra_contract_class, + sierra_contract_class: Some(sierra_contract_class), sierra_class_hash, casm_class: Default::default(), skip_execute: false, @@ -912,7 +913,7 @@ mod test { simulate_transaction( &[&declare_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -981,7 +982,7 @@ mod test { simulate_transaction( &[&l1_handler_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -1042,7 +1043,7 @@ mod test { simulate_transaction( &[&deploy, &invoke_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -1056,7 +1057,7 @@ mod test { assert_eq!( estimate_fee(&[deploy, invoke_tx], state, block_context,).unwrap(), - [(0, 2448), (0, 2448)] + [(0, 1836), (0, 2448)] ); } @@ -1081,4 +1082,119 @@ mod test { ) ); } + + #[test] + fn test_simulate_declare_v1_compare_fees() { + // accounts contract class must be stored before running declaration of fibonacci + let contract_class = ContractClass::from_path("starknet_programs/Account.json").unwrap(); + + // Instantiate CachedState + let contract_class_cache = PermanentContractClassCache::default(); + + // ------------ contract data -------------------- + let hash = compute_deprecated_class_hash(&contract_class).unwrap(); + let class_hash = hash.to_be_bytes(); + + contract_class_cache.set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); + + // store sender_address + let sender_address = Address(1.into()); + // this is not conceptually correct as the sender address would be an + // Account contract (not the contract that we are currently declaring) + // but for testing reasons its ok + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(sender_address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(sender_address.clone(), Felt252::new(1)); + + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + // Insert pubkey storage var to pass validation + let storage_entry = &( + sender_address, + felt_str!( + "1672321442399497129215646424919402195095307045612040218489019266998007191460" + ) + .to_be_bytes(), + ); + state.set_storage_at( + storage_entry, + felt_str!( + "1735102664668487605176656616876767369909409133946409161569774794110049207117" + ), + ); + + //* --------------------------------------- + //* Test declare with previous data + //* --------------------------------------- + + let fib_contract_class = + ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); + + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + // Signature & tx hash values are hand-picked for account validations to pass + let mut declare = Declare::new( + fib_contract_class, + chain_id, + Address(Felt252::one()), + 60000, + 1.into(), + vec![ + felt_str!( + "3086480810278599376317923499561306189851900463386393948998357832163236918254" + ), + felt_str!( + "598673427589502599949712887611119751108407514580626464031881322743364689811" + ), + ], + Felt252::one(), + ) + .unwrap(); + declare.hash_value = felt_str!("2718"); + + let mut block_context = BlockContext::default(); + block_context.starknet_os_config_mut().gas_price = 12; + + let declare_tx = Transaction::Declare(declare); + + let without_validate_fee = simulate_transaction( + &[&declare_tx], + state.clone_for_testing(), + state.clone_for_testing().contract_class_cache().clone(), + &block_context, + 100_000_000, + true, + false, + true, + false, + false, + ) + .unwrap()[0] + .actual_fee; + + let with_validate_fee = simulate_transaction( + &[&declare_tx], + state.clone_for_testing(), + state.contract_class_cache().clone(), + &block_context, + 100_000_000, + false, + false, + true, + false, + false, + ) + .unwrap()[0] + .actual_fee; + + assert!(with_validate_fee > without_validate_fee) + } } diff --git a/src/services/api/contract_classes/compiled_class.rs b/src/services/api/contract_classes/compiled_class.rs index 035a96fbb..26b56281f 100644 --- a/src/services/api/contract_classes/compiled_class.rs +++ b/src/services/api/contract_classes/compiled_class.rs @@ -24,6 +24,7 @@ use starknet::core::types::ContractClass::{Legacy, Sierra}; pub enum CompiledClass { Deprecated(Arc), Casm(Arc), + Sierra(Arc), } impl TryInto for CompiledClass { @@ -129,7 +130,7 @@ impl From for CompiledClass { ) }) .collect::>(); - entry_points_by_type.insert(EntryPointType::Constructor, l1_handler_entries); + entry_points_by_type.insert(EntryPointType::L1Handler, l1_handler_entries); let v = serde_json::to_value(&_deprecated_contract_class.abi).unwrap(); let abi: Option = serde_json::from_value(v).unwrap(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index c453e1a96..1f8394bbb 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -1,6 +1,6 @@ use super::{ contract_class_cache::ContractClassCache, - state_api::{State, StateReader}, + state_api::{State, StateChangesCount, StateReader}, state_cache::{StateCache, StorageEntry}, }; use crate::{ @@ -12,19 +12,19 @@ use crate::{ to_cache_state_storage_mapping, Address, ClassHash, }, }; +use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; use getset::{Getters, MutGetters}; use num_traits::Zero; use std::{ - cell::RefCell, collections::{HashMap, HashSet}, - sync::Arc, + sync::{Arc, RwLock}, }; pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; /// Represents a cached state of contract classes with optional caches. -#[derive(Default, Clone, Debug, Getters, MutGetters)] +#[derive(Default, Debug, Getters, MutGetters)] pub struct CachedState { pub state_reader: Arc, #[getset(get = "pub", get_mut = "pub")] @@ -32,7 +32,7 @@ pub struct CachedState { #[getset(get = "pub", get_mut = "pub")] pub(crate) contract_class_cache: Arc, - pub(crate) contract_class_cache_private: RefCell>, + pub(crate) contract_class_cache_private: RwLock>, #[cfg(feature = "metrics")] cache_hits: usize, @@ -73,7 +73,7 @@ impl CachedState { cache: StateCache::default(), state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RefCell::new(HashMap::new()), + contract_class_cache_private: RwLock::new(HashMap::new()), #[cfg(feature = "metrics")] cache_hits: 0, @@ -92,7 +92,7 @@ impl CachedState { cache, state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RefCell::new(HashMap::new()), + contract_class_cache_private: RwLock::new(HashMap::new()), #[cfg(feature = "metrics")] cache_hits: 0, @@ -101,28 +101,51 @@ impl CachedState { } } + /// Clones a CachedState for testing purposes. + pub fn clone_for_testing(&self) -> Self { + Self { + state_reader: self.state_reader.clone(), + cache: self.cache.clone(), + contract_class_cache: self.contract_class_cache.clone(), + contract_class_cache_private: RwLock::new( + self.contract_class_cache_private.read().unwrap().clone(), + ), + #[cfg(feature = "metrics")] + cache_hits: self.cache_hits, + #[cfg(feature = "metrics")] + cache_misses: self.cache_misses, + } + } + pub fn drain_private_contract_class_cache( &self, - ) -> impl Iterator { - self.contract_class_cache_private.take().into_iter() + ) -> Result, StateError> { + Ok(self + .contract_class_cache_private + .read() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .clone() + .into_iter()) } /// Creates a copy of this state with an empty cache for saving changes and applying them /// later. - pub fn create_transactional(&self) -> TransactionalCachedState { - let state_reader = Arc::new(TransactionalCachedStateReader::new(self)); - CachedState { - state_reader, + pub fn create_transactional(&self) -> Result, StateError> { + Ok(CachedState { + state_reader: self.state_reader.clone(), cache: self.cache.clone(), contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RefCell::new( - self.contract_class_cache_private.borrow().clone(), + contract_class_cache_private: RwLock::new( + self.contract_class_cache_private + .read() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .clone(), ), #[cfg(feature = "metrics")] cache_hits: 0, #[cfg(feature = "metrics")] cache_misses: 0, - } + }) } } @@ -177,7 +200,10 @@ impl StateReader for CachedState { } // I: FETCHING FROM CACHE - let mut private_cache = self.contract_class_cache_private.borrow_mut(); + let mut private_cache = self + .contract_class_cache_private + .write() + .map_err(|_| StateError::FailedToReadContractClassCache)?; if let Some(compiled_class) = private_cache.get(class_hash) { return Ok(compiled_class.clone()); } else if let Some(compiled_class) = @@ -221,6 +247,7 @@ impl State for CachedState { // have a mutable reference to the `RefCell` available. self.contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, contract_class.clone()); Ok(()) @@ -294,7 +321,7 @@ impl State for CachedState { let compiled_class_hash = compiled_class_hash.to_be_bytes(); self.cache - .class_hash_to_compiled_class_hash + .compiled_class_hash_writes .insert(class_hash, compiled_class_hash); Ok(()) } @@ -311,10 +338,10 @@ impl State for CachedState { Ok(()) } - fn count_actual_storage_changes( + fn count_actual_state_changes( &mut self, fee_token_and_sender_address: Option<(&Address, &Address)>, - ) -> Result<(usize, usize), StateError> { + ) -> Result { self.update_initial_values_of_write_only_accesses()?; let mut storage_updates = subtract_mappings( @@ -324,9 +351,16 @@ impl State for CachedState { let storage_unique_updates = storage_updates.keys().map(|k| k.0.clone()); - let class_hash_updates = subtract_mappings_keys( + let class_hash_updates: Vec<&Address> = subtract_mappings_keys( &self.cache.class_hash_writes, &self.cache.class_hash_initial_values, + ) + .collect(); + let n_class_hash_updates = class_hash_updates.len(); + + let compiled_class_hash_updates = subtract_mappings_keys( + &self.cache.compiled_class_hash_writes, + &self.cache.compiled_class_hash_initial_values, ); let nonce_updates = @@ -334,7 +368,7 @@ impl State for CachedState { let mut modified_contracts: HashSet
= HashSet::new(); modified_contracts.extend(storage_unique_updates); - modified_contracts.extend(class_hash_updates.cloned()); + modified_contracts.extend(class_hash_updates.into_iter().cloned()); modified_contracts.extend(nonce_updates.cloned()); // Add fee transfer storage update before actually charging it, as it needs to be included in the @@ -348,7 +382,12 @@ impl State for CachedState { modified_contracts.remove(fee_token_address); } - Ok((modified_contracts.len(), storage_updates.len())) + Ok(StateChangesCount { + n_storage_updates: storage_updates.len(), + n_class_hash_updates, + n_compiled_class_hash_updates: compiled_class_hash_updates.count(), + n_modified_contracts: modified_contracts.len(), + }) } /// Returns the class hash for a given contract address. @@ -446,6 +485,7 @@ impl State for CachedState { if let Some(compiled_class) = self .contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .get(class_hash) .cloned() { @@ -457,6 +497,7 @@ impl State for CachedState { self.add_hit(); self.contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, compiled_class.clone()); return Ok(compiled_class); } @@ -465,14 +506,14 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when - // we have a mutable reference to the `RefCell` available. - if let Some(casm_class) = self + let write_guard = self .contract_class_cache_private .get_mut() - .get(compiled_class_hash) - .cloned() - { + .map_err(|_| StateError::FailedToReadContractClassCache)?; + + // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when + // we have a mutable reference to the `RefCell` available. + if let Some(casm_class) = write_guard.get(compiled_class_hash).cloned() { self.add_hit(); return Ok(casm_class); } else if let Some(casm_class) = self @@ -482,11 +523,21 @@ impl State for CachedState { self.add_hit(); self.contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, casm_class.clone()); return Ok(casm_class); } } + // if let Some(sierra_compiled_class) = self + // .sierra_programs + // .as_ref() + // .and_then(|x| x.get(class_hash)) + // { + // return Ok(CompiledClass::Sierra(Arc::new( + // sierra_compiled_class.clone(), + // ))); + // } // II: FETCHING FROM STATE_READER let contract = self.state_reader.get_contract_class(class_hash)?; match contract { @@ -501,137 +552,34 @@ impl State for CachedState { CompiledClass::Deprecated(ref contract) => { self.set_contract_class(class_hash, &CompiledClass::Deprecated(contract.clone()))? } + CompiledClass::Sierra(ref sierra_compiled_class) => self.set_contract_class( + class_hash, + &CompiledClass::Sierra(sierra_compiled_class.clone()), + )?, } Ok(contract) } -} -/// A CachedState which has access to another, "parent" state, used for executing transactions -/// without commiting changes to the parent. -pub type TransactionalCachedState<'a, T, C> = - CachedState, C>; - -/// State reader used for transactional states which allows to check the parent state's cache and -/// state reader if a transactional cache miss happens. -/// -/// In practice this will act as a way to access the parent state's cache and other fields, -/// without referencing the whole parent state, so there's no need to adapt state-modifying -/// functions in the case that a transactional state is needed. -#[derive(Debug, MutGetters, Getters, PartialEq, Clone)] -pub struct TransactionalCachedStateReader<'a, T: StateReader, C: ContractClassCache> { - /// The parent state's state_reader - #[get(get = "pub")] - pub(crate) state_reader: Arc, - /// The parent state's cache - #[get(get = "pub")] - pub(crate) cache: &'a StateCache, - - /// The parent state's contract_classes - #[get(get = "pub")] - pub(crate) contract_class_cache: Arc, - pub(crate) contract_class_cache_private: &'a RefCell>, -} - -impl<'a, T: StateReader, C: ContractClassCache> TransactionalCachedStateReader<'a, T, C> { - fn new(state: &'a CachedState) -> Self { - Self { - state_reader: state.state_reader.clone(), - cache: &state.cache, - contract_class_cache: state.contract_class_cache.clone(), - contract_class_cache_private: &state.contract_class_cache_private, - } - } -} - -impl<'a, T: StateReader, C: ContractClassCache> StateReader - for TransactionalCachedStateReader<'a, T, C> -{ - /// Returns the class hash for a given contract address. - /// Returns zero as default value if missing - fn get_class_hash_at(&self, contract_address: &Address) -> Result { - self.cache - .get_class_hash(contract_address) - .map(|a| Ok(*a)) - .unwrap_or_else(|| self.state_reader.get_class_hash_at(contract_address)) - } - - /// Returns the nonce for a given contract address. - fn get_nonce_at(&self, contract_address: &Address) -> Result { - if self.cache.get_nonce(contract_address).is_none() { - return self.state_reader.get_nonce_at(contract_address); - } - self.cache - .get_nonce(contract_address) - .ok_or_else(|| StateError::NoneNonce(contract_address.clone())) - .cloned() - } - - /// Returns storage data for a given storage entry. - /// Returns zero as default value if missing - fn get_storage_at(&self, storage_entry: &StorageEntry) -> Result { - self.cache - .get_storage(storage_entry) - .map(|v| Ok(v.clone())) - .unwrap_or_else(|| self.state_reader.get_storage_at(storage_entry)) - } + fn set_sierra_program( + &mut self, + compiled_class_hash: &Felt252, + _sierra_program: Vec, + ) -> Result<(), StateError> { + let _compiled_class_hash = compiled_class_hash.to_be_bytes(); - // TODO: check if that the proper way to store it (converting hash to address) - /// Returned the compiled class hash for a given class hash. - fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Result { - if self - .cache - .class_hash_to_compiled_class_hash - .get(class_hash) - .is_none() - { - return self.state_reader.get_compiled_class_hash(class_hash); - } - self.cache - .class_hash_to_compiled_class_hash - .get(class_hash) - .ok_or_else(|| StateError::NoneCompiledClass(*class_hash)) - .cloned() + // TODO implement + // self.sierra_programs + // .as_mut() + // .ok_or(StateError::MissingSierraProgramsCache)? + // .insert(compiled_class_hash, sierra_program); + Ok(()) } - /// Returns the contract class for a given class hash. - fn get_contract_class(&self, class_hash: &ClassHash) -> Result { - // This method can receive both compiled_class_hash & class_hash and return both casm and deprecated contract classes - //, which can be on the cache or on the state_reader, different cases will be described below: - if class_hash == UNINITIALIZED_CLASS_HASH { - return Err(StateError::UninitiaizedClassHash); - } - - // I: FETCHING FROM CACHE - let mut private_cache = self.contract_class_cache_private.borrow_mut(); - if let Some(compiled_class) = private_cache.get(class_hash) { - return Ok(compiled_class.clone()); - } else if let Some(compiled_class) = - self.contract_class_cache().get_contract_class(*class_hash) - { - private_cache.insert(*class_hash, compiled_class.clone()); - return Ok(compiled_class); - } - - // I: CASM CONTRACT CLASS : CLASS_HASH - if let Some(compiled_class_hash) = - self.cache.class_hash_to_compiled_class_hash.get(class_hash) - { - if let Some(casm_class) = private_cache.get(compiled_class_hash) { - return Ok(casm_class.clone()); - } else if let Some(casm_class) = self - .contract_class_cache() - .get_contract_class(*compiled_class_hash) - { - private_cache.insert(*class_hash, casm_class.clone()); - return Ok(casm_class); - } - } - - // II: FETCHING FROM STATE_READER - let contract_class = self.state_reader.get_contract_class(class_hash)?; - private_cache.insert(*class_hash, contract_class.clone()); - - Ok(contract_class) + fn get_sierra_program( + &mut self, + _class_hash: &ClassHash, + ) -> Result, StateError> { + todo!() } } @@ -979,7 +927,7 @@ mod tests { /// This test calculate the number of actual storage changes. #[test] - fn count_actual_storage_changes_test() { + fn count_actual_state_changes_test() { let state_reader = InMemoryStateReader::default(); let mut cached_state = CachedState::new( Arc::new(state_reader), @@ -1003,14 +951,15 @@ mod tests { let fee_token_address = Address(123.into()); let sender_address = Address(321.into()); - let expected_changes = { - let n_storage_updates = 3 + 1; // + 1 fee transfer balance update - let n_modified_contracts = 2; - - (n_modified_contracts, n_storage_updates) + let expected_changes = StateChangesCount { + n_storage_updates: 3 + 1, // + 1 fee transfer balance update, + n_class_hash_updates: 0, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 2, }; + let changes = cached_state - .count_actual_storage_changes(Some((&fee_token_address, &sender_address))) + .count_actual_state_changes(Some((&fee_token_address, &sender_address))) .unwrap(); assert_eq!(changes, expected_changes); diff --git a/src/state/mod.rs b/src/state/mod.rs index 0c15b6aad..ef6efc242 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -3,10 +3,10 @@ use self::{ }; use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::compiled_class::CompiledClass, transaction::error::TransactionError, utils::{ - get_keys, to_cache_state_storage_mapping, to_state_diff_storage_mapping, Address, ClassHash, + get_keys, to_cache_state_storage_mapping, to_state_diff_storage_mapping, Address, + ClassHash, CompiledClassHash, }, }; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; @@ -106,7 +106,7 @@ impl ExecutionResourcesManager { pub struct StateDiff { pub(crate) address_to_class_hash: HashMap, pub(crate) address_to_nonce: HashMap, - pub(crate) class_hash_to_compiled_class: HashMap, + pub(crate) class_hash_to_compiled_class: HashMap, pub(crate) storage_updates: HashMap>, } @@ -114,7 +114,7 @@ impl StateDiff { pub const fn new( address_to_class_hash: HashMap, address_to_nonce: HashMap, - class_hash_to_compiled_class: HashMap, + class_hash_to_compiled_class: HashMap, storage_updates: HashMap>, ) -> Self { StateDiff { @@ -133,7 +133,7 @@ impl StateDiff { let state_cache = cached_state.cache().to_owned(); let substracted_maps = state_cache.storage_writes; - let storage_updates = to_state_diff_storage_mapping(substracted_maps); + let storage_updates = to_state_diff_storage_mapping(&substracted_maps); let address_to_nonce = state_cache.nonce_writes; let class_hash_to_compiled_class = state_cache.compiled_class_hash_writes; @@ -330,7 +330,7 @@ mod test { Arc::new(PermanentContractClassCache::default()), ); - let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); + let diff = StateDiff::from_cached_state(cached_state_original.clone_for_testing()).unwrap(); let cached_state = diff .to_cached_state::<_, PermanentContractClassCache>( diff --git a/src/state/state_api.rs b/src/state/state_api.rs index ff468671a..4abe12354 100644 --- a/src/state/state_api.rs +++ b/src/state/state_api.rs @@ -5,6 +5,7 @@ use crate::{ state::StateDiff, utils::{Address, ClassHash, CompiledClassHash}, }; +use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; pub trait StateReader { @@ -25,6 +26,14 @@ pub trait StateReader { ) -> Result; } +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct StateChangesCount { + pub n_storage_updates: usize, + pub n_class_hash_updates: usize, + pub n_compiled_class_hash_updates: usize, + pub n_modified_contracts: usize, +} + pub trait State { fn set_contract_class( &mut self, @@ -53,13 +62,20 @@ pub trait State { class_hash: &Felt252, compiled_class_hash: &Felt252, ) -> Result<(), StateError>; + + fn set_sierra_program( + &mut self, + compiled_class_hash: &Felt252, + sierra_program: Vec, + ) -> Result<(), StateError>; + fn apply_state_update(&mut self, sate_updates: &StateDiff) -> Result<(), StateError>; - /// Counts the amount of modified contracts and the updates to the storage - fn count_actual_storage_changes( + /// Counts the amount of state changes + fn count_actual_state_changes( &mut self, fee_token_and_sender_address: Option<(&Address, &Address)>, - ) -> Result<(usize, usize), StateError>; + ) -> Result; /// Returns the class hash of the contract class at the given address. /// Returns zero by default if the value is not present @@ -75,4 +91,9 @@ pub trait State { fn get_compiled_class_hash(&mut self, class_hash: &ClassHash) -> Result; fn get_contract_class(&mut self, class_hash: &ClassHash) -> Result; + + fn get_sierra_program( + &mut self, + class_hash: &ClassHash, + ) -> Result, StateError>; } diff --git a/src/state/state_cache.rs b/src/state/state_cache.rs index 6238c258d..23a77400c 100644 --- a/src/state/state_cache.rs +++ b/src/state/state_cache.rs @@ -1,6 +1,5 @@ use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::compiled_class::CompiledClass, utils::{Address, ClassHash, CompiledClassHash}, }; use cairo_vm::felt::Felt252; @@ -18,7 +17,7 @@ pub struct StateCache { #[get_mut = "pub"] pub(crate) class_hash_initial_values: HashMap, #[get_mut = "pub"] - pub(crate) compiled_class_hash_initial_values: HashMap, + pub(crate) compiled_class_hash_initial_values: HashMap, #[getset(get = "pub", get_mut = "pub")] pub(crate) nonce_initial_values: HashMap, #[getset(get = "pub", get_mut = "pub")] @@ -28,7 +27,7 @@ pub struct StateCache { #[get_mut = "pub"] pub(crate) class_hash_writes: HashMap, #[get_mut = "pub"] - pub(crate) compiled_class_hash_writes: HashMap, + pub(crate) compiled_class_hash_writes: HashMap, #[get_mut = "pub"] pub(crate) nonce_writes: HashMap, #[getset(get = "pub", get_mut = "pub")] @@ -43,11 +42,11 @@ impl StateCache { /// Create a new StateCache with given initial and written values for testing pub const fn new( class_hash_initial_values: HashMap, - compiled_class_hash_initial_values: HashMap, + compiled_class_hash_initial_values: HashMap, nonce_initial_values: HashMap, storage_initial_values: HashMap, class_hash_writes: HashMap, - compiled_class_hash_writes: HashMap, + compiled_class_hash_writes: HashMap, nonce_writes: HashMap, storage_writes: HashMap, class_hash_to_compiled_class_hash: HashMap, @@ -84,11 +83,11 @@ impl StateCache { #[allow(clippy::too_many_arguments)] pub const fn new_for_testing( class_hash_initial_values: HashMap, - compiled_class_hash_initial_values: HashMap, + compiled_class_hash_initial_values: HashMap, nonce_initial_values: HashMap, storage_initial_values: HashMap, class_hash_writes: HashMap, - compiled_class_hash_writes: HashMap, + compiled_class_hash_writes: HashMap, nonce_writes: HashMap, storage_writes: HashMap<(Address, [u8; 32]), Felt252>, class_hash_to_compiled_class_hash: HashMap, @@ -116,7 +115,10 @@ impl StateCache { /// Get the compiled hash for a given class hash #[allow(dead_code)] - pub(crate) fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Option<&CompiledClass> { + pub(crate) fn get_compiled_class_hash( + &self, + class_hash: &ClassHash, + ) -> Option<&CompiledClassHash> { if self.compiled_class_hash_writes.contains_key(class_hash) { return self.compiled_class_hash_writes.get(class_hash); } @@ -143,7 +145,7 @@ impl StateCache { pub(crate) fn update_writes( &mut self, address_to_class_hash: &HashMap, - class_hash_to_compiled_class_hash: &HashMap, + class_hash_to_compiled_class_hash: &HashMap, address_to_nonce: &HashMap, storage_updates: &HashMap, ) { @@ -158,7 +160,7 @@ impl StateCache { pub fn set_initial_values( &mut self, address_to_class_hash: &HashMap, - class_hash_to_compiled_class: &HashMap, + class_hash_to_compiled_class: &HashMap, address_to_nonce: &HashMap, storage_updates: &HashMap, ) -> Result<(), StateError> { @@ -201,8 +203,7 @@ impl StateCache { } for (k, v) in self.compiled_class_hash_writes.iter() { - self.compiled_class_hash_initial_values - .insert(*k, v.clone()); + self.compiled_class_hash_initial_values.insert(*k, *v); } for (k, v) in self.storage_writes.iter() { @@ -219,9 +220,11 @@ impl StateCache { /// Unit tests for StateCache #[cfg(test)] mod tests { - use std::sync::Arc; - use crate::services::api::contract_classes::deprecated_contract_class::ContractClass; + use crate::{ + core::contract_address::compute_deprecated_class_hash, + services::api::contract_classes::deprecated_contract_class::ContractClass, + }; use super::*; @@ -232,7 +235,9 @@ mod tests { let contract_class = ContractClass::from_path("starknet_programs/raw_contract_classes/class_with_abi.json") .unwrap(); - let compiled_class = CompiledClass::Deprecated(Arc::new(contract_class)); + let compiled_class = compute_deprecated_class_hash(&contract_class) + .unwrap() + .to_be_bytes(); let class_hash_to_compiled_class_hash = HashMap::from([([8; 32], compiled_class)]); let address_to_nonce = HashMap::from([(Address(9.into()), 12.into())]); let storage_updates = HashMap::from([((Address(4.into()), [1; 32]), 18.into())]); diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index 5deb7b2ee..42925bf16 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -58,9 +58,10 @@ use crate::services::api::contract_classes::deprecated_contract_class::EntryPoin use crate::state::contract_class_cache::ContractClassCache; use num_traits::{One, ToPrimitive, Zero}; -const STEP: u128 = 100; -const SYSCALL_BASE: u128 = 100 * STEP; -const KECCAK_ROUND_COST: u128 = 180000; +pub(crate) const STEP: u128 = 100; +pub(crate) const SYSCALL_BASE: u128 = 100 * STEP; +pub(crate) const KECCAK_ROUND_COST: u128 = 180000; + lazy_static! { /// Felt->syscall map that was extracted from new_syscalls.json (Cairo 1.0 syscalls) static ref SELECTOR_TO_SYSCALL: HashMap = { @@ -92,7 +93,7 @@ lazy_static! { // Taken from starkware/starknet/constants.py in cairo-lang // See further documentation on cairo_programs/constants.cairo /// Maps syscall name to gas costs - static ref SYSCALL_GAS_COST: HashMap<&'static str, u128> = { + pub(crate) static ref SYSCALL_GAS_COST: HashMap<&'static str, u128> = { let mut map = HashMap::new(); map.insert("initial", 100_000_000 * STEP); @@ -134,6 +135,7 @@ pub struct BusinessLogicSyscallHandler<'a, S: StateReader, C: ContractClassCache pub(crate) support_reverted: bool, pub(crate) entry_point_selector: Felt252, pub(crate) selector_to_syscall: &'a HashMap, + pub(crate) execution_info_ptr: Option, } // TODO: execution entry point may no be a parameter field, but there is no way to generate a default for now @@ -172,6 +174,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, support_reverted, entry_point_selector, selector_to_syscall: &SELECTOR_TO_SYSCALL, + execution_info_ptr: None, } } @@ -229,6 +232,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, support_reverted: false, entry_point_selector, selector_to_syscall: &SELECTOR_TO_SYSCALL, + execution_info_ptr: None, } } @@ -312,6 +316,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } @@ -320,7 +325,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, contract_address: &Address, class_hash_bytes: ClassHash, constructor_calldata: Vec, - remainig_gas: u128, + remaining_gas: u128, ) -> Result { let compiled_class = if let Ok(compiled_class) = self .starknet_storage_state @@ -359,7 +364,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, EntryPointType::Constructor, Some(CallType::Call), None, - remainig_gas, + remaining_gas, ); let ExecutionResult { @@ -534,10 +539,10 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, /// them as accessed. pub(crate) fn validate_read_only_segments( &self, - runner: &mut VirtualMachine, + vm: &mut VirtualMachine, ) -> Result<(), TransactionError> { for (segment_ptr, segment_size) in self.read_only_segments.clone() { - let used_size = runner + let used_size = vm .get_segment_used_size(segment_ptr.segment_index as usize) .ok_or(TransactionError::InvalidSegmentSize)?; @@ -549,7 +554,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, if seg_size != used_size.into() { return Err(TransactionError::OutOfBound); } - runner.mark_address_range_as_accessed(segment_ptr, used_size)?; + vm.mark_address_range_as_accessed(segment_ptr, used_size)?; } Ok(()) } @@ -626,63 +631,69 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, }) } + // Returns the pointer to the segment with the execution info if it was already written. + // If it wasn't, it writes the execution info into memory and returns its start address. + fn get_or_allocate_execution_info( + &mut self, + vm: &mut VirtualMachine, + ) -> Result { + if let Some(ptr) = self.execution_info_ptr { + return Ok(ptr); + } + + // Allocate block_info + let block_info = &self.block_context.block_info; + let block_info_data = vec![ + MaybeRelocatable::from(Felt252::from(block_info.block_number)), + MaybeRelocatable::from(Felt252::from(block_info.block_timestamp)), + MaybeRelocatable::from(&block_info.sequencer_address.0), + ]; + let block_info_ptr = self.allocate_segment(vm, block_info_data)?; + + // Allocate signature + let signature: Vec = self + .tx_execution_context + .signature + .iter() + .map(MaybeRelocatable::from) + .collect(); + let signature_start_ptr = self.allocate_segment(vm, signature)?; + let signature_end_ptr = (signature_start_ptr + self.tx_execution_context.signature.len())?; + + // Allocate tx info + let tx_info = &self.tx_execution_context; + let tx_info_data = vec![ + MaybeRelocatable::from(&tx_info.version), + MaybeRelocatable::from(&tx_info.account_contract_address.0), + MaybeRelocatable::from(Felt252::from(tx_info.max_fee)), + signature_start_ptr.into(), + signature_end_ptr.into(), + MaybeRelocatable::from(&tx_info.transaction_hash), + MaybeRelocatable::from(&self.block_context.starknet_os_config.chain_id), + MaybeRelocatable::from(&tx_info.nonce), + ]; + let tx_info_ptr = self.allocate_segment(vm, tx_info_data)?; + + // Allocate execution_info + let execution_info = vec![ + block_info_ptr.into(), + tx_info_ptr.into(), + MaybeRelocatable::from(&self.caller_address.0), + MaybeRelocatable::from(&self.contract_address.0), + MaybeRelocatable::from(&self.entry_point_selector), + ]; + let execution_info_ptr = self.allocate_segment(vm, execution_info)?; + + self.execution_info_ptr = Some(execution_info_ptr); + Ok(execution_info_ptr) + } + fn get_execution_info( - &self, + &mut self, vm: &mut VirtualMachine, remaining_gas: u128, ) -> Result { - let tx_info = &self.tx_execution_context; - let block_info = &self.block_context.block_info; - - let mut res_segment = vm.add_memory_segment(); - - let signature_start = res_segment; - for s in tx_info.signature.iter() { - vm.insert_value(res_segment, s)?; - res_segment = (res_segment + 1)?; - } - let signature_end = res_segment; - - let tx_info_ptr = res_segment; - vm.insert_value::(res_segment, tx_info.version.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, tx_info.account_contract_address.0.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, tx_info.max_fee.into())?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, signature_start)?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, signature_end)?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, tx_info.transaction_hash.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::( - res_segment, - self.block_context.starknet_os_config.chain_id.clone(), - )?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, tx_info.nonce.clone())?; - res_segment = (res_segment + 1)?; - - let block_info_ptr = res_segment; - vm.insert_value::(res_segment, block_info.block_number.into())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, block_info.block_timestamp.into())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, block_info.sequencer_address.0.clone())?; - res_segment = (res_segment + 1)?; - - let exec_info_ptr = res_segment; - vm.insert_value(res_segment, block_info_ptr)?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, tx_info_ptr)?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, self.caller_address.0.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, self.contract_address.0.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, self.entry_point_selector.clone())?; - + let exec_info_ptr = self.get_or_allocate_execution_info(vm)?; Ok(SyscallResponse { gas: remaining_gas, body: Some(ResponseBody::GetExecutionInfo { exec_info_ptr }), @@ -876,7 +887,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, fn send_message_to_l1( &mut self, - vm: &mut VirtualMachine, + vm: &VirtualMachine, request: SendMessageToL1Request, remaining_gas: u128, ) -> Result { diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 9f0b66e32..56817de19 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -193,6 +193,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } @@ -596,7 +597,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S pub(crate) fn storage_write( &mut self, - vm: &mut VirtualMachine, + vm: &VirtualMachine, syscall_ptr: Relocatable, ) -> Result<(), SyscallHandlerError> { let request = @@ -887,7 +888,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S pub(crate) fn replace_class( &mut self, - vm: &mut VirtualMachine, + vm: &VirtualMachine, syscall_ptr: Relocatable, ) -> Result<(), SyscallHandlerError> { let request = match self.read_and_validate_syscall_request("replace_class", vm, syscall_ptr) diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index eabf9bdfa..997f684df 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -1214,7 +1214,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 065e31652..48a332316 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -4,6 +4,8 @@ pub mod deprecated_syscall_handler; pub mod deprecated_syscall_request; pub mod deprecated_syscall_response; pub mod hint_code; +#[cfg(feature = "cairo-native")] +pub mod native_syscall_handler; pub mod other_syscalls; pub mod syscall_handler; pub mod syscall_handler_errors; diff --git a/src/syscalls/native_syscall_handler.rs b/src/syscalls/native_syscall_handler.rs new file mode 100644 index 000000000..00386eaea --- /dev/null +++ b/src/syscalls/native_syscall_handler.rs @@ -0,0 +1,576 @@ +use crate::ContractClassCache; +use cairo_native::starknet::{ + BlockInfo, ExecutionInfo, StarkNetSyscallHandler, SyscallResult, TxInfo, U256, +}; +use cairo_vm::felt::Felt252; +use num_traits::Zero; + +use crate::definitions::constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR; +use crate::execution::CallResult; +use crate::hash_utils::calculate_contract_address; +use crate::services::api::contract_class_errors::ContractClassError; +use crate::services::api::contract_classes::compiled_class::CompiledClass; +use crate::state::state_api::State; +use crate::utils::felt_to_hash; +use crate::utils::ClassHash; +use crate::{ + core::errors::state_errors::StateError, + definitions::block_context::BlockContext, + execution::{ + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, + }, + state::{ + contract_storage_state::ContractStorageState, state_api::StateReader, + ExecutionResourcesManager, + }, + syscalls::business_logic_syscall_handler::{SYSCALL_BASE, SYSCALL_GAS_COST}, + utils::Address, + EntryPointType, +}; + +#[derive(Debug)] +pub struct NativeSyscallHandler<'a, S, C> +where + S: StateReader, + C: ContractClassCache, +{ + pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, + pub(crate) contract_address: Address, + pub(crate) caller_address: Address, + pub(crate) entry_point_selector: Felt252, + pub(crate) events: Vec, + pub(crate) l2_to_l1_messages: Vec, + pub(crate) tx_execution_context: TransactionExecutionContext, + pub(crate) block_context: BlockContext, + pub(crate) internal_calls: Vec, + pub(crate) resources_manager: ExecutionResourcesManager, +} + +impl<'a, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, S, C> { + /// Generic code that needs to be run on all syscalls. + fn handle_syscall_request(&mut self, gas: &mut u128, syscall_name: &str) -> SyscallResult<()> { + let required_gas = SYSCALL_GAS_COST + .get(syscall_name) + .map(|&x| x.saturating_sub(SYSCALL_BASE)) + .unwrap_or(0); + + if *gas < required_gas { + let out_of_gas_felt = Felt252::from_bytes_be("Out of gas".as_bytes()); + println!("out of gas!: {:?} < {:?}", *gas, required_gas); // TODO: remove once all other prints are removed + return Err(vec![out_of_gas_felt.clone()]); + } + + *gas = gas.saturating_sub(required_gas); + + self.resources_manager + .increment_syscall_counter(syscall_name, 1); + + Ok(()) + } +} + +impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler + for NativeSyscallHandler<'a, S, C> +{ + fn get_block_hash( + &mut self, + block_number: u64, + gas: &mut u128, + ) -> SyscallResult { + println!("Called `get_block_hash({block_number})` from MLIR."); + + self.handle_syscall_request(gas, "get_block_hash")?; + + Ok(Felt252::from_bytes_be(b"get_block_hash ok")) + } + + fn get_execution_info( + &mut self, + gas: &mut u128, + ) -> SyscallResult { + println!("Called `get_execution_info()` from MLIR."); + + self.handle_syscall_request(gas, "get_execution_info")?; + + Ok(ExecutionInfo { + block_info: BlockInfo { + block_number: self.block_context.block_info.block_number, + block_timestamp: self.block_context.block_info.block_timestamp, + sequencer_address: self.block_context.block_info.sequencer_address.0.clone(), + }, + tx_info: TxInfo { + version: self.tx_execution_context.version.clone(), + account_contract_address: self + .tx_execution_context + .account_contract_address + .0 + .clone(), + max_fee: self.tx_execution_context.max_fee, + signature: self.tx_execution_context.signature.clone(), + transaction_hash: self.tx_execution_context.transaction_hash.clone(), + chain_id: self.block_context.starknet_os_config.chain_id.clone(), + nonce: self.tx_execution_context.nonce.clone(), + }, + caller_address: self.caller_address.0.clone(), + contract_address: self.contract_address.0.clone(), + entry_point_selector: self.entry_point_selector.clone(), + }) + } + + fn deploy( + &mut self, + class_hash: cairo_vm::felt::Felt252, + contract_address_salt: cairo_vm::felt::Felt252, + calldata: &[cairo_vm::felt::Felt252], + deploy_from_zero: bool, + gas: &mut u128, + ) -> SyscallResult<(cairo_vm::felt::Felt252, Vec)> { + self.handle_syscall_request(gas, "deploy")?; + + let deployer_address = if deploy_from_zero { + Address::default() + } else { + self.contract_address.clone() + }; + + let contract_address = Address( + calculate_contract_address( + &contract_address_salt, + &class_hash, + calldata, + deployer_address, + ) + .map_err(|_| { + vec![Felt252::from_bytes_be( + b"FAILED_TO_CALCULATE_CONTRACT_ADDRESS", + )] + })?, + ); + // Initialize the contract. + let class_hash_bytes: ClassHash = felt_to_hash(&class_hash); + + self.starknet_storage_state + .state + .deploy_contract(contract_address.clone(), class_hash_bytes) + .map_err(|_| vec![Felt252::from_bytes_be(b"CONTRACT_ADDRESS_UNAVAILABLE")])?; + + let result = self + .execute_constructor_entry_point( + &contract_address, + class_hash_bytes, + calldata.to_vec(), + *gas, + ) + .map_err(|_| vec![Felt252::from_bytes_be(b"CONSTRUCTOR_ENTRYPOINT_FAILURE")])?; + + *gas = gas.saturating_sub(result.gas_consumed); + + Ok(( + contract_address.0, + result + .retdata + .iter() + .map(|mb| mb.get_int_ref().cloned().unwrap_or_default()) + .collect(), + )) + } + + fn replace_class( + &mut self, + class_hash: cairo_vm::felt::Felt252, + gas: &mut u128, + ) -> SyscallResult<()> { + println!("Called `replace_class({class_hash})` from MLIR."); + + self.handle_syscall_request(gas, "replace_class")?; + Ok(()) + } + + fn library_call( + &mut self, + class_hash: cairo_vm::felt::Felt252, + function_selector: cairo_vm::felt::Felt252, + calldata: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult> { + println!( + "Called `library_call({class_hash}, {function_selector}, {calldata:?})` from MLIR." + ); + + self.handle_syscall_request(gas, "library_call")?; + + Ok(calldata.iter().map(|x| x * &Felt252::new(3)).collect()) + } + + fn call_contract( + &mut self, + address: cairo_vm::felt::Felt252, + entrypoint_selector: cairo_vm::felt::Felt252, + calldata: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult> { + println!( + "Called `call_contract({address}, {entrypoint_selector}, {calldata:?})` from MLIR." + ); + + self.handle_syscall_request(gas, "call_contract")?; + + let address = Address(address); + let exec_entry_point = ExecutionEntryPoint::new( + address, + calldata.to_vec(), + entrypoint_selector, + self.caller_address.clone(), + EntryPointType::External, + Some(CallType::Call), + None, + *gas, + ); + + let ExecutionResult { call_info, .. } = exec_entry_point + .execute( + self.starknet_storage_state.state, + // TODO: This fields dont make much sense in the Cairo Native context, + // they are only dummy values for the `execute` method. + &self.block_context, + &mut self.resources_manager, + &mut self.tx_execution_context, + false, + self.block_context.invoke_tx_max_n_steps, + ) + .unwrap(); + + let call_info = call_info.unwrap(); + + *gas = gas.saturating_sub(call_info.gas_consumed); + + // update syscall handler information + self.starknet_storage_state + .read_values + .extend(call_info.storage_read_values.clone()); + self.starknet_storage_state + .accessed_keys + .extend(call_info.accessed_storage_keys.clone()); + + let retdata = call_info.retdata.clone(); + self.internal_calls.push(call_info); + + Ok(retdata) + } + + fn storage_read( + &mut self, + address_domain: u32, + address: cairo_vm::felt::Felt252, + gas: &mut u128, + ) -> SyscallResult { + println!("Called `storage_read({address_domain}, {address})` from MLIR."); + + self.handle_syscall_request(gas, "storage_read")?; + + let value = match self.starknet_storage_state.read(&address.to_be_bytes()) { + Ok(value) => Ok(value), + Err(_e @ StateError::Io(_)) => todo!(), + Err(_) => Ok(Felt252::zero()), + }; + + println!(" = {value:?}` from MLIR."); + + value + } + + fn storage_write( + &mut self, + address_domain: u32, + address: cairo_vm::felt::Felt252, + value: cairo_vm::felt::Felt252, + gas: &mut u128, + ) -> SyscallResult<()> { + println!("Called `storage_write({address_domain}, {address}, {value})` from MLIR."); + + self.handle_syscall_request(gas, "storage_write")?; + + self.starknet_storage_state + .write(&address.to_be_bytes(), value); + Ok(()) + } + + fn emit_event( + &mut self, + keys: &[cairo_vm::felt::Felt252], + data: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult<()> { + let order = self.tx_execution_context.n_emitted_events; + println!("Called `emit_event(KEYS: {keys:?}, DATA: {data:?})` from MLIR."); + + self.handle_syscall_request(gas, "emit_event")?; + + self.events + .push(OrderedEvent::new(order, keys.to_vec(), data.to_vec())); + self.tx_execution_context.n_emitted_events += 1; + Ok(()) + } + + fn send_message_to_l1( + &mut self, + to_address: cairo_vm::felt::Felt252, + payload: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult<()> { + println!("Called `send_message_to_l1({to_address}, {payload:?})` from MLIR."); + + self.handle_syscall_request(gas, "send_message_to_l1")?; + + let addr = Address(to_address); + self.l2_to_l1_messages.push(OrderedL2ToL1Message::new( + self.tx_execution_context.n_sent_messages, + addr, + payload.to_vec(), + )); + + // Update messages count. + self.tx_execution_context.n_sent_messages += 1; + + Ok(()) + } + + fn keccak( + &mut self, + input: &[u64], + gas: &mut u128, + ) -> SyscallResult { + println!("Called `keccak({input:?})` from MLIR."); + + self.handle_syscall_request(gas, "keccak")?; + + Ok(U256(Felt252::from(1234567890).to_le_bytes())) + } + + fn secp256k1_add( + &mut self, + _p0: cairo_native::starknet::Secp256k1Point, + _p1: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_get_point_from_x( + &self, + _x: cairo_native::starknet::U256, + _y_parity: bool, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_get_xy( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { + todo!() + } + + fn secp256k1_mul( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _m: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_new( + &self, + _x: cairo_native::starknet::U256, + _y: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_add( + &self, + _p0: cairo_native::starknet::Secp256k1Point, + _p1: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_get_point_from_x( + &self, + _x: cairo_native::starknet::U256, + _y_parity: bool, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_get_xy( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { + todo!() + } + + fn secp256r1_mul( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _m: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_new( + &mut self, + _x: cairo_native::starknet::U256, + _y: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn pop_log(&mut self) { + todo!() + } + + fn set_account_contract_address(&mut self, contract_address: cairo_vm::felt::Felt252) { + self.tx_execution_context.account_contract_address = Address(contract_address); + } + + fn set_block_number(&mut self, block_number: u64) { + self.block_context.block_info.block_number = block_number; + } + + fn set_block_timestamp(&mut self, block_timestamp: u64) { + self.block_context.block_info.block_timestamp = block_timestamp; + } + + fn set_caller_address(&mut self, address: cairo_vm::felt::Felt252) { + self.caller_address = Address(address); + } + + fn set_chain_id(&mut self, chain_id: cairo_vm::felt::Felt252) { + self.block_context.starknet_os_config.chain_id = chain_id; + } + + fn set_contract_address(&mut self, address: cairo_vm::felt::Felt252) { + self.contract_address = Address(address); + } + + fn set_max_fee(&mut self, max_fee: u128) { + self.tx_execution_context.max_fee = max_fee; + } + + fn set_nonce(&mut self, nonce: cairo_vm::felt::Felt252) { + self.tx_execution_context.nonce = nonce; + } + + fn set_sequencer_address(&mut self, _address: cairo_vm::felt::Felt252) { + todo!() + } + + fn set_signature(&mut self, signature: &[cairo_vm::felt::Felt252]) { + self.tx_execution_context.signature = signature.to_vec(); + } + + fn set_transaction_hash(&mut self, transaction_hash: cairo_vm::felt::Felt252) { + self.tx_execution_context.transaction_hash = transaction_hash; + } + + fn set_version(&mut self, version: cairo_vm::felt::Felt252) { + self.tx_execution_context.version = version; + } +} + +impl<'a, S, C> NativeSyscallHandler<'a, S, C> +where + S: StateReader, + C: ContractClassCache, +{ + fn execute_constructor_entry_point( + &mut self, + contract_address: &Address, + class_hash_bytes: ClassHash, + constructor_calldata: Vec, + remaining_gas: u128, + ) -> Result { + let compiled_class = if let Ok(compiled_class) = self + .starknet_storage_state + .state + .get_contract_class(&class_hash_bytes) + { + compiled_class + } else { + return Ok(CallResult { + gas_consumed: 0, + is_success: false, + retdata: vec![Felt252::from_bytes_be(b"CLASS_HASH_NOT_FOUND").into()], + }); + }; + + if self.constructor_entry_points_empty(compiled_class)? { + if !constructor_calldata.is_empty() { + return Err(StateError::ConstructorCalldataEmpty); + } + + let call_info = CallInfo::empty_constructor_call( + contract_address.clone(), + self.contract_address.clone(), + Some(class_hash_bytes), + ); + self.internal_calls.push(call_info.clone()); + + return Ok(call_info.result()); + } + + let call = ExecutionEntryPoint::new( + contract_address.clone(), + constructor_calldata, + CONSTRUCTOR_ENTRY_POINT_SELECTOR.clone(), + self.contract_address.clone(), + EntryPointType::Constructor, + Some(CallType::Call), + None, + remaining_gas, + ); + + let ExecutionResult { call_info, .. } = call + .execute( + self.starknet_storage_state.state, + &self.block_context, + &mut self.resources_manager, + &mut self.tx_execution_context, + false, + u64::MAX, + ) + .map_err(|_| StateError::ExecutionEntryPoint)?; + + let call_info = call_info.ok_or(StateError::CustomError("Execution error".to_string()))?; + + self.internal_calls.push(call_info.clone()); + + Ok(call_info.result()) + } + + fn constructor_entry_points_empty( + &self, + contract_class: CompiledClass, + ) -> Result { + match contract_class { + CompiledClass::Deprecated(class) => Ok(class + .entry_points_by_type + .get(&EntryPointType::Constructor) + .ok_or(ContractClassError::NoneEntryPointType)? + .is_empty()), + CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + } + } +} diff --git a/src/syscalls/syscall_handler.rs b/src/syscalls/syscall_handler.rs index b62fb9b64..679098a02 100644 --- a/src/syscalls/syscall_handler.rs +++ b/src/syscalls/syscall_handler.rs @@ -146,7 +146,7 @@ impl<'a, S: StateReader, C: ContractClassCache> HintProcessorPostRun // TODO: These four functions were copied from cairo-rs in // hint_processor/cairo-1-hint-processor/hint_processor_utils.rs as these functions are private. // They will became public soon and then we have to remove this ones and use the ones in cairo-rs instead -fn as_relocatable(vm: &mut VirtualMachine, value: &ResOperand) -> Result { +fn as_relocatable(vm: &VirtualMachine, value: &ResOperand) -> Result { let (base, offset) = extract_buffer(value)?; get_ptr(vm, base, &offset).map_err(HintError::from) } diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index 364628bcd..bf173065c 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -32,6 +32,8 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::Zero; + +use std::fmt::Debug; use std::sync::Arc; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -146,6 +148,44 @@ impl Declare { Ok(internal_declare) } + #[allow(clippy::too_many_arguments)] + pub fn new_with_tx_and_class_hash( + contract_class: ContractClass, + sender_address: Address, + max_fee: u128, + version: Felt252, + signature: Vec, + nonce: Felt252, + hash_value: Felt252, + class_hash: ClassHash, + ) -> Result { + let validate_entry_point_selector = VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(); + + let internal_declare = Declare { + class_hash, + sender_address, + validate_entry_point_selector, + version, + max_fee, + signature, + nonce, + hash_value, + contract_class, + skip_execute: false, + skip_validate: false, + skip_fee_transfer: false, + }; + + verify_version( + &internal_declare.version, + internal_declare.max_fee, + &internal_declare.nonce, + &internal_declare.signature, + )?; + + Ok(internal_declare) + } + pub fn get_calldata(&self) -> Vec { let bytes = Felt252::from_bytes_be(&self.class_hash); Vec::from([bytes]) @@ -167,7 +207,7 @@ impl Declare { } else { self.run_validate_entrypoint(state, &mut resources_manager, block_context)? }; - let changes = state.count_actual_storage_changes(Some(( + let changes = state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.sender_address, )))?; @@ -266,6 +306,14 @@ impl Declare { /// Calculates actual fee used by the transaction using the execution /// info returned by apply(), then updates the transaction execution info with the data of the fee. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::Declare, + self.version = ?self.version, + self.class_hash = ?self.class_hash, + self.hash_value = ?self.hash_value, + self.sender_address = ?self.sender_address, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, @@ -295,7 +343,7 @@ impl Declare { Ok(tx_exec_info) } - pub(crate) fn create_for_simulation( + pub fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -426,10 +474,10 @@ mod tests { entry_point_type: Some(EntryPointType::External), calldata, class_hash: Some(expected_class_hash), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 12, ..Default::default() - }, + }), ..Default::default() }); @@ -888,4 +936,104 @@ mod tests { Err(TransactionError::FeeTransferError(_)) ); } + + #[test] + fn declare_v1_with_validation_fee_higher_than_no_validation() { + // accounts contract class must be stored before running declaration of fibonacci + let contract_class = ContractClass::from_path("starknet_programs/Account.json").unwrap(); + + // Instantiate CachedState + let contract_class_cache = PermanentContractClassCache::default(); + + // ------------ contract data -------------------- + let hash = compute_deprecated_class_hash(&contract_class).unwrap(); + let class_hash = hash.to_be_bytes(); + + contract_class_cache.set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); + + // store sender_address + let sender_address = Address(1.into()); + // this is not conceptually correct as the sender address would be an + // Account contract (not the contract that we are currently declaring) + // but for testing reasons its ok + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(sender_address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(sender_address.clone(), Felt252::new(1)); + + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + // Insert pubkey storage var to pass validation + let storage_entry = &( + sender_address, + felt_str!( + "1672321442399497129215646424919402195095307045612040218489019266998007191460" + ) + .to_be_bytes(), + ); + state.set_storage_at( + storage_entry, + felt_str!( + "1735102664668487605176656616876767369909409133946409161569774794110049207117" + ), + ); + + //* --------------------------------------- + //* Test declare with previous data + //* --------------------------------------- + + let fib_contract_class = + ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); + + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + // Signature & tx hash values are hand-picked for account validations to pass + let mut declare = Declare::new( + fib_contract_class, + chain_id, + Address(Felt252::one()), + 60000, + 1.into(), + vec![ + felt_str!( + "3086480810278599376317923499561306189851900463386393948998357832163236918254" + ), + felt_str!( + "598673427589502599949712887611119751108407514580626464031881322743364689811" + ), + ], + Felt252::one(), + ) + .unwrap(); + declare.skip_fee_transfer = true; + declare.hash_value = felt_str!("2718"); + + let simulate_declare = declare + .clone() + .create_for_simulation(true, false, true, false); + + // --------------------- + // Comparison + // --------------------- + let mut state_copy = state.clone_for_testing(); + let mut bock_context = BlockContext::default(); + bock_context.starknet_os_config.gas_price = 12; + assert!( + declare + .execute(&mut state, &bock_context) + .unwrap() + .actual_fee + > simulate_declare + .execute(&mut state_copy, &bock_context, 0) + .unwrap() + .actual_fee, + ); + } } diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index a342b9d25..cbcca05cb 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -28,6 +28,7 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; use cairo_vm::felt::Felt252; use num_traits::Zero; +use std::fmt::Debug; use std::sync::Arc; /// Represents a declare transaction in the starknet network. @@ -42,7 +43,7 @@ pub struct DeclareV2 { pub signature: Vec, pub nonce: Felt252, pub compiled_class_hash: Felt252, - pub sierra_contract_class: SierraContractClass, + pub sierra_contract_class: Option, pub sierra_class_hash: Felt252, pub hash_value: Felt252, pub casm_class: Option, @@ -89,7 +90,7 @@ impl DeclareV2 { )?; Self::new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class, + Some(sierra_contract_class.clone()), sierra_class_hash, casm_contract_class, compiled_class_hash, @@ -118,7 +119,7 @@ impl DeclareV2 { /// may not hold. #[allow(clippy::too_many_arguments)] pub fn new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class: &SierraContractClass, + sierra_contract_class: Option, sierra_class_hash: Felt252, casm_contract_class: Option, compiled_class_hash: Felt252, @@ -184,7 +185,7 @@ impl DeclareV2 { let sierra_class_hash = compute_sierra_class_hash(sierra_contract_class)?; Self::new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class, + Some(sierra_contract_class.clone()), sierra_class_hash, casm_contract_class, compiled_class_hash, @@ -211,7 +212,7 @@ impl DeclareV2 { /// - nonce: The nonce of the contract. #[allow(clippy::too_many_arguments)] pub fn new_with_sierra_class_hash( - sierra_contract_class: &SierraContractClass, + sierra_contract_class: Option, sierra_class_hash: Felt252, casm_contract_class: Option, compiled_class_hash: Felt252, @@ -296,11 +297,21 @@ impl DeclareV2 { /// ## Parameter: /// - state: An state that implements the State and StateReader traits. /// - block_context: The block that contains the execution context + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::Declare, + self.version = ?self.version, + self.sierra_class_hash = ?self.sierra_class_hash, + self.compiled_class_hash = ?self.compiled_class_hash, + self.hash_value = ?self.hash_value, + self.sender_address = ?self.sender_address, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, block_context: &BlockContext, ) -> Result { + self.handle_nonce(state)?; verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; let initial_gas = INITIAL_GAS_COST; @@ -318,11 +329,13 @@ impl DeclareV2 { )?; (info, gas) }; + self.compile_and_store_casm_class(state)?; - let storage_changes = state.count_actual_storage_changes(Some(( + let storage_changes = state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.sender_address, )))?; + let actual_resources = calculate_tx_resources( resources_manager, &[execution_result.call_info.clone()], @@ -342,7 +355,6 @@ impl DeclareV2 { &mut tx_execution_context, self.skip_fee_transfer, )?; - self.compile_and_store_casm_class(state)?; let mut tx_exec_info = TransactionExecutionInfo::new_without_fee_info( execution_result.call_info, @@ -361,10 +373,13 @@ impl DeclareV2 { state: &mut S, ) -> Result<(), TransactionError> { let casm_class = match &self.casm_class { - None => { - CasmContractClass::from_contract_class(self.sierra_contract_class.clone(), true) - .map_err(|e| TransactionError::SierraCompileError(e.to_string()))? - } + None => CasmContractClass::from_contract_class( + self.sierra_contract_class + .clone() + .ok_or(TransactionError::DeclareV2NoSierraOrCasm)?, + true, + ) + .map_err(|e| TransactionError::SierraCompileError(e.to_string()))?, Some(casm_contract_class) => casm_contract_class.clone(), }; @@ -375,8 +390,11 @@ impl DeclareV2 { self.compiled_class_hash.to_string(), )); } - state.set_compiled_class_hash(&self.sierra_class_hash, &self.compiled_class_hash)?; + if let Some(ref class) = self.sierra_contract_class { + state.set_sierra_program(&self.sierra_class_hash, class.sierra_program.clone())?; + } + state.set_compiled_class_hash(&self.sierra_class_hash, &self.compiled_class_hash)?; state.set_contract_class( &self.compiled_class_hash.to_be_bytes(), &CompiledClass::Casm(Arc::new(casm_class)), @@ -433,7 +451,7 @@ impl DeclareV2 { // --------------- // Simulation // --------------- - pub(crate) fn create_for_simulation( + pub fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -527,7 +545,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap().clone(), true, ) .unwrap(); @@ -596,7 +614,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap(), true, ) .unwrap(); @@ -619,13 +637,13 @@ mod tests { let path; #[cfg(not(feature = "cairo_1_tests"))] { - version = &2.into() | &QUERY_VERSION_BASE.clone(); + version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); path = PathBuf::from("starknet_programs/cairo2/fibonacci.sierra"); } #[cfg(feature = "cairo_1_tests")] { - version = &1.into() | &QUERY_VERSION_BASE.clone(); + version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); path = PathBuf::from("starknet_programs/cairo1/fibonacci.sierra"); } @@ -642,7 +660,7 @@ mod tests { // create internal declare v2 let internal_declare = DeclareV2::new_with_sierra_class_hash_and_tx_hash( - &sierra_contract_class, + Some(sierra_contract_class), sierra_class_hash, Some(casm_class), casm_class_hash, @@ -667,7 +685,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap(), true, ) .unwrap(); @@ -736,7 +754,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap().clone(), true, ) .unwrap(); diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index 32bf9feb3..47168dfc4 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -34,6 +34,8 @@ use cairo_vm::felt::Felt252; use num_traits::Zero; use std::sync::Arc; +use std::fmt::Debug; + /// Represents a Deploy Transaction in the starknet network #[derive(Debug, Clone)] pub struct Deploy { @@ -138,6 +140,7 @@ impl Deploy { .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } /// Deploys the contract in the starknet network and calls its constructor if it has one. @@ -149,7 +152,13 @@ impl Deploy { state: &mut CachedState, block_context: &BlockContext, ) -> Result { - state.set_contract_class(&self.contract_hash, &self.contract_class)?; + match self.contract_class { + CompiledClass::Sierra(_) => todo!(), + _ => { + state.set_contract_class(&self.contract_hash, &self.contract_class)?; + } + } + state.deploy_contract(self.contract_address.clone(), self.contract_hash)?; if self.constructor_entry_points_empty(self.contract_class.clone())? { @@ -180,7 +189,7 @@ impl Deploy { let resources_manager = ExecutionResourcesManager::default(); - let changes = state.count_actual_storage_changes(None)?; + let changes = state.count_actual_state_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[Some(call_info.clone())], @@ -243,7 +252,7 @@ impl Deploy { block_context.validate_max_n_steps, )?; - let changes = state.count_actual_storage_changes(None)?; + let changes = state.count_actual_state_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[call_info.clone()], @@ -267,6 +276,14 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::Deploy, + self.version = ?self.version, + self.contract_hash = ?self.contract_hash, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.contract_address_salt = ?self.contract_address_salt, + ))] pub fn execute( &self, state: &mut CachedState, diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index b537c6f99..978cbcca0 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -40,6 +40,7 @@ use crate::{ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; +use std::fmt::Debug; #[derive(Clone, Debug, PartialEq, Eq)] pub struct StateSelector { @@ -156,6 +157,15 @@ impl DeployAccount { } } + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::DeployAccount, + self.version = ?self.version, + self.class_hash = ?self.class_hash, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.contract_address_salt = ?self.contract_address_salt, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, @@ -163,7 +173,7 @@ impl DeployAccount { ) -> Result { self.handle_nonce(state)?; - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; let mut tx_exec_info = self.apply(&mut transactional_state, block_context)?; let actual_fee = calculate_tx_fee( @@ -215,6 +225,7 @@ impl DeployAccount { .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } @@ -243,7 +254,7 @@ impl DeployAccount { resources_manager, &[Some(constructor_call_info.clone()), validate_info.clone()], TransactionType::DeployAccount, - state.count_actual_storage_changes(Some(( + state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.contract_address, )))?, @@ -393,7 +404,7 @@ impl DeployAccount { Ok(call_info) } - pub(crate) fn create_for_simulation( + pub fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -414,6 +425,42 @@ impl DeployAccount { Transaction::DeployAccount(tx) } + + pub fn from_sn_api_transaction( + value: starknet_api::transaction::DeployAccountTransaction, + chain_id: Felt252, + ) -> Result { + let max_fee = value.max_fee.0; + let version = Felt252::from_bytes_be(value.version.0.bytes()); + let nonce = Felt252::from_bytes_be(value.nonce.0.bytes()); + let class_hash: [u8; 32] = value.class_hash.0.bytes().try_into().unwrap(); + let contract_address_salt = Felt252::from_bytes_be(value.contract_address_salt.0.bytes()); + + let signature = value + .signature + .0 + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(); + let constructor_calldata = value + .constructor_calldata + .0 + .as_ref() + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(); + + DeployAccount::new( + class_hash, + max_fee, + version, + nonce, + constructor_calldata, + signature, + contract_address_salt, + chain_id, + ) + } } // ---------------------------------- diff --git a/src/transaction/error.rs b/src/transaction/error.rs index c254dd152..87a1f76a5 100644 --- a/src/transaction/error.rs +++ b/src/transaction/error.rs @@ -147,4 +147,6 @@ pub enum TransactionError { InvalidCompiledClassHash(String, String), #[error(transparent)] FromByteArrayError(#[from] FromByteArrayError), + #[error("DeclareV2 transaction has neither Sierra nor Casm contract class set")] + DeclareV2NoSierraOrCasm, } diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 9808591be..aa04a6e38 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -73,11 +73,9 @@ pub(crate) fn execute_fee_transfer( call_info.ok_or(TransactionError::CallInfoIsNone) } -// ---------------------------------------------------------------------------------------- /// Calculates the fee of a transaction given its execution resources. /// We add the l1_gas_usage (which may include, for example, the direct cost of L2-to-L1 /// messages) to the gas consumed by Cairo resource and multiply by the L1 gas price. - pub fn calculate_tx_fee( resources: &HashMap, gas_price: u128, @@ -94,11 +92,9 @@ pub fn calculate_tx_fee( Ok(total_l1_gas_usage.ceil() as u128 * gas_price) } -// ---------------------------------------------------------------------------------------- /// Calculates the L1 gas consumed when submitting the underlying Cairo program to SHARP. /// I.e., returns the heaviest Cairo resource weight (in terms of L1 gas), as the size of /// a proof is determined similarly - by the (normalized) largest segment. - pub(crate) fn calculate_l1_gas_by_cairo_usage( block_context: &BlockContext, cairo_resource_usage: &HashMap, @@ -117,6 +113,7 @@ pub(crate) fn calculate_l1_gas_by_cairo_usage( )) } +/// Calculates the maximum weighted value from a given resource usage mapping. fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap) -> f64 { let mut max = 0.0_f64; for (k, v) in weights { @@ -136,6 +133,11 @@ fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap( state: &mut CachedState, resources: &HashMap, @@ -195,6 +197,8 @@ mod tests { }; use std::{collections::HashMap, sync::Arc}; + /// Tests the behavior of the charge_fee function when the actual fee exceeds the maximum fee + /// for version 0. It expects to return an ActualFeeExceedsMaxFee error. #[test] fn charge_fee_v0_max_fee_exceeded_should_charge_nothing() { let mut state = CachedState::new( @@ -224,6 +228,8 @@ mod tests { assert_eq!(result.1, 0); } + /// Tests the behavior of the charge_fee function when the actual fee exceeds the maximum fee + /// for version 1. It expects the function to return the maximum fee. #[test] fn charge_fee_v1_max_fee_exceeded_should_charge_max_fee() { let mut state = CachedState::new( diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 877131c0f..1f8a0937c 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -28,6 +28,7 @@ use crate::{ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; +use std::fmt::Debug; /// Represents an InvokeFunction transaction in the starknet network. #[derive(Debug, Getters, Clone)] @@ -244,8 +245,12 @@ impl InvokeFunction { remaining_gas: u128, ) -> Result { let mut resources_manager = ExecutionResourcesManager::default(); - let validate_info = - self.run_validate_entrypoint(state, &mut resources_manager, block_context)?; + let validate_info = if self.skip_validation { + None + } else { + self.run_validate_entrypoint(state, &mut resources_manager, block_context)? + }; + // Execute transaction let ExecutionResult { call_info, @@ -261,7 +266,7 @@ impl InvokeFunction { remaining_gas, )? }; - let changes = state.count_actual_storage_changes(Some(( + let changes = state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.contract_address, )))?; @@ -289,6 +294,14 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. /// - remaining_gas: The amount of gas that the transaction disposes. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::InvokeFunction, + self.version = ?self.version, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.entry_point_selector = ?self.entry_point_selector, + self.entry_point_type = ?self.entry_point_type, + ))] pub fn execute( &self, state: &mut CachedState, @@ -299,7 +312,7 @@ impl InvokeFunction { self.handle_nonce(state)?; } - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; let mut tx_exec_info = self.apply(&mut transactional_state, block_context, remaining_gas)?; @@ -659,7 +672,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) @@ -804,7 +817,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); let expected_error = internal_invoke_function.apply(&mut transactional, &BlockContext::default(), 0); @@ -867,7 +880,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) @@ -940,7 +953,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let expected_error = internal_invoke_function.apply(&mut transactional, &BlockContext::default(), 0); @@ -1291,7 +1304,7 @@ mod tests { ) .unwrap(), None, - &1.into() | &QUERY_VERSION_BASE.clone(), + &Into::::into(1) | &QUERY_VERSION_BASE.clone(), ); assert!(expected_error.is_err()); } @@ -1342,7 +1355,7 @@ mod tests { let mut state = CachedState::new(Arc::new(state_reader), Arc::new(casm_contract_class_cache)); - let state_before_execution = state.clone(); + let state_before_execution = state.clone_for_testing(); let result = internal_invoke_function .execute(&mut state, &BlockContext::default(), 0) diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index fbae7e3e6..f01031436 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -7,6 +7,7 @@ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; +use super::Transaction; use crate::{ core::transaction_hash::{calculate_transaction_hash_common, TransactionHashPrefix}, definitions::{ @@ -25,10 +26,9 @@ use crate::{ utils::{calculate_tx_resources, Address}, }; -use super::Transaction; - #[allow(dead_code)] #[derive(Debug, Getters, Clone)] +/// Represents an L1Handler transaction in the StarkNet network. pub struct L1Handler { #[getset(get = "pub")] hash_value: Felt252, @@ -43,6 +43,7 @@ pub struct L1Handler { } impl L1Handler { + /// Constructor creates a new [L1Handler] instance. pub fn new( contract_address: Address, entry_point_selector: Felt252, @@ -71,7 +72,12 @@ impl L1Handler { hash_value, ) } - + /// Creates a new [L1Handler] instance with a specified transaction hash. + /// + /// # Safety + /// + /// `tx_hash` will be assumed to be the same as would result from calling + /// `calculate_transaction_hash_common`. Non-compliance will result in silent misbehavior. pub fn new_with_tx_hash( contract_address: Address, entry_point_selector: Felt252, @@ -93,6 +99,13 @@ impl L1Handler { } /// Applies self to 'state' by executing the L1-handler entry point. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::L1Handler, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.entry_point_selector = ?self.entry_point_selector, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, @@ -128,7 +141,7 @@ impl L1Handler { )? }; - let changes = state.count_actual_storage_changes(None)?; + let changes = state.count_actual_state_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[call_info.clone()], @@ -189,11 +202,9 @@ impl L1Handler { L1_HANDLER_VERSION.into(), )) } - pub(crate) fn create_for_simulation( - &self, - skip_validate: bool, - skip_execute: bool, - ) -> Transaction { + + /// Creates a L1Handler for simulation purposes. + pub fn create_for_simulation(&self, skip_validate: bool, skip_execute: bool) -> Transaction { let tx = L1Handler { skip_validate, skip_execute, @@ -202,6 +213,27 @@ impl L1Handler { Transaction::L1Handler(tx) } + + /// Creates a `L1Handler` from a starknet api `L1HandlerTransaction`. + pub fn from_sn_api_tx( + tx: starknet_api::transaction::L1HandlerTransaction, + tx_hash: Felt252, + paid_fee_on_l1: Option, + ) -> Result { + L1Handler::new_with_tx_hash( + Address(Felt252::from_bytes_be(tx.contract_address.0.key().bytes())), + Felt252::from_bytes_be(tx.entry_point_selector.0.bytes()), + tx.calldata + .0 + .as_ref() + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(), + Felt252::from_bytes_be(tx.nonce.0.bytes()), + paid_fee_on_l1, + tx_hash, + ) + } } #[cfg(test)] @@ -230,6 +262,7 @@ mod test { sync::Arc, }; + /// Test the correct execution of the L1Handler. #[test] fn test_execute_l1_handler() { let l1_handler = L1Handler::new( @@ -289,6 +322,8 @@ mod test { assert_eq!(tx_exec, expected_tx_exec) } + /// Helper function to construct the expected transaction execution info. + /// Expected output of the L1Handler's execution. fn expected_tx_exec_info() -> TransactionExecutionInfo { TransactionExecutionInfo { validate_info: None, @@ -311,14 +346,14 @@ mod test { 10.into(), ], retdata: vec![], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 141, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 6), ("pedersen_builtin".to_string(), 2), ]), - }, + }), events: vec![], l2_to_l1_messages: vec![], storage_read_values: vec![0.into(), 0.into()], diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index 5584aa940..3d75e4266 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -82,6 +82,7 @@ impl Transaction { Transaction::L1Handler(tx) => tx.execute(state, block_context, remaining_gas), } } + /// It creates a new transaction structure modificating the skip flags. It is meant to be used only to run a simulation ///## Parameters: ///- skip_validate: the transaction will not be verified. diff --git a/src/transaction/verify_version.rs b/src/transaction/verify_version.rs index 8787b09b9..2f9abecdb 100644 --- a/src/transaction/verify_version.rs +++ b/src/transaction/verify_version.rs @@ -31,6 +31,8 @@ pub fn verify_version( #[cfg(test)] mod test { + use cairo_vm::felt::Felt252; + // TODO: fixture tests would be better here use crate::{definitions::constants::QUERY_VERSION_BASE, transaction::error::TransactionError}; @@ -109,7 +111,7 @@ mod test { #[test] fn version_0_with_max_fee_0_nonce_0_and_empty_signature_and_query_version_set_should_return_ok() { - let version = &0.into() | &QUERY_VERSION_BASE.clone(); + let version = &Into::::into(0) | &QUERY_VERSION_BASE.clone(); let max_fee = 0; let nonce = 0.into(); let signature = vec![]; @@ -119,7 +121,7 @@ mod test { #[test] fn version_1_with_query_version_set_should_return_ok() { - let version = &1.into() | &QUERY_VERSION_BASE.clone(); + let version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); let max_fee = 2; let nonce = 3.into(); let signature = vec![5.into()]; @@ -129,7 +131,7 @@ mod test { #[test] fn version_2_with_query_version_set_should_return_ok() { - let version = &2.into() | &QUERY_VERSION_BASE.clone(); + let version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); let max_fee = 43; let nonce = 4.into(); let signature = vec![6.into()]; diff --git a/src/utils.rs b/src/utils.rs index b1736f852..dfa67e6d4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ use crate::core::errors::hash_errors::HashError; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; -use crate::state::state_api::State; +use crate::state::state_api::{State, StateChangesCount}; use crate::{ definitions::transaction_type::TransactionType, execution::{ @@ -16,6 +16,7 @@ use cairo_vm::{ felt::Felt252, serde::deserialize_program::BuiltinName, vm::runners::builtin_runner, }; use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine}; +use core::fmt; use num_integer::Integer; use num_traits::{Num, ToPrimitive}; use serde::{Deserialize, Serialize}; @@ -36,9 +37,21 @@ pub type CompiledClassHash = [u8; 32]; //* Address //* ------------------- -#[derive(Debug, Clone, PartialEq, Hash, Eq, Default, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Hash, Eq, Default, Serialize, Deserialize)] pub struct Address(pub Felt252); +impl fmt::Display for Address { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "0x{}", self.0.to_str_radix(16)) + } +} + +impl fmt::Debug for Address { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self) + } +} + //* ------------------- //* Helper Functions //* ------------------- @@ -135,17 +148,17 @@ pub fn string_to_hash(class_string: &String) -> ClassHash { /// Converts CachedState storage mapping to StateDiff storage mapping. pub fn to_state_diff_storage_mapping( - storage_writes: HashMap, + storage_writes: &HashMap, ) -> HashMap> { let mut storage_updates: HashMap> = HashMap::new(); - for ((address, key), value) in storage_writes.into_iter() { + for ((address, key), value) in storage_writes.iter() { storage_updates - .entry(address) + .entry(address.clone()) .and_modify(|updates_for_address: &mut HashMap| { - let key_fe = Felt252::from_bytes_be(&key); + let key_fe = Felt252::from_bytes_be(key); updates_for_address.insert(key_fe, value.clone()); }) - .or_insert_with(|| HashMap::from([(Felt252::from_bytes_be(&key), value)])); + .or_insert_with(|| HashMap::from([(Felt252::from_bytes_be(key), value.clone())])); } storage_updates } @@ -169,14 +182,11 @@ pub fn calculate_tx_resources( resources_manager: ExecutionResourcesManager, call_info: &[Option], tx_type: TransactionType, - storage_changes: (usize, usize), + state_changes: StateChangesCount, l1_handler_payload_size: Option, n_reverted_steps: usize, ) -> Result, TransactionError> { - let (n_modified_contracts, n_storage_changes) = storage_changes; - let non_optional_calls: Vec = call_info.iter().flatten().cloned().collect(); - let n_deployments = non_optional_calls.iter().map(get_call_n_deployments).sum(); let mut l2_to_l1_messages = Vec::new(); @@ -184,13 +194,8 @@ pub fn calculate_tx_resources( l2_to_l1_messages.extend(call_info.get_sorted_l2_to_l1_messages()?) } - let l1_gas_usage = calculate_tx_gas_usage( - l2_to_l1_messages, - n_modified_contracts, - n_storage_changes, - l1_handler_payload_size, - n_deployments, - ); + let l1_gas_usage = + calculate_tx_gas_usage(l2_to_l1_messages, &state_changes, l1_handler_payload_size); let cairo_usage = resources_manager.cairo_usage.clone(); let tx_syscall_counter = resources_manager.syscall_counter; @@ -301,7 +306,7 @@ pub fn get_storage_var_address( let args = args .iter() - .map(|felt| felt_to_field_element(felt)) + .map(felt_to_field_element) .collect::, _>>()?; let storage_var_name_hash = @@ -488,6 +493,7 @@ pub mod test_utils { macro_rules! ids_data { ( $( $name: expr ),* ) => { { + #[allow(clippy::useless_vec)] let ids_names = vec![$( $name ),*]; let references = $crate::utils::test_utils::references!(ids_names.len() as i32); let mut ids_data = HashMap::::new(); @@ -810,7 +816,7 @@ mod test { storage.insert((address1.clone(), key1), value1.clone()); storage.insert((address2.clone(), key2), value2.clone()); - let map = to_state_diff_storage_mapping(storage); + let map = to_state_diff_storage_mapping(&storage); let key1_fe = Felt252::from_bytes_be(key1.as_slice()); let key2_fe = Felt252::from_bytes_be(key2.as_slice()); @@ -881,7 +887,7 @@ mod test { storage.insert((address1.clone(), key1), value1.clone()); storage.insert((address2.clone(), key2), value2.clone()); - let state_dff = to_state_diff_storage_mapping(storage); + let state_dff = to_state_diff_storage_mapping(&storage); let cache_storage = to_cache_state_storage_mapping(&state_dff); let mut expected_res = HashMap::new(); @@ -920,4 +926,10 @@ mod test { ], ); } + + #[test] + fn test_address_display() { + let address = Address(Felt252::from(123456789)); + assert_eq!(format!("{}", address), "0x75bcd15".to_string()); + } } diff --git a/starknet_programs/cairo1/square_root_recursive.cairo b/starknet_programs/cairo1/square_root_recursive.cairo new file mode 100644 index 000000000..a38b7e1fe --- /dev/null +++ b/starknet_programs/cairo1/square_root_recursive.cairo @@ -0,0 +1,24 @@ +#[abi] +trait Math { + #[external] + fn square_root(n: felt252) -> felt252; +} + +#[contract] +mod SquareRoot { + use super::MathDispatcherTrait; + use super::MathLibraryDispatcher; + use starknet::ClassHash; + + #[external] + fn square_root_recursive(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + square_root_recursive_inner(n, math_class_hash, n_iterations) + } + + fn square_root_recursive_inner(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + if n_iterations == 0 { + return n; + } + square_root_recursive_inner(MathLibraryDispatcher {class_hash: math_class_hash}.square_root(n), math_class_hash, n_iterations - 1) + } +} diff --git a/starknet_programs/cairo1/wallet_wrapper.cairo b/starknet_programs/cairo1/wallet_wrapper.cairo index d3557a309..ca65cef90 100644 --- a/starknet_programs/cairo1/wallet_wrapper.cairo +++ b/starknet_programs/cairo1/wallet_wrapper.cairo @@ -22,4 +22,13 @@ mod WalletWrapper { fn increase_balance(amount: felt252, simple_wallet_contract_address: ContractAddress) { SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(amount) } + + #[external] + fn increase_balance_recursive(amount: felt252, simple_wallet_contract_address: ContractAddress) { + if amount == 0 { + return(); + } + SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(1); + increase_balance_recursive(amount - 1, simple_wallet_contract_address) + } } diff --git a/starknet_programs/cairo2/account_panic.cairo b/starknet_programs/cairo2/account_panic.cairo new file mode 100644 index 000000000..3cb051250 --- /dev/null +++ b/starknet_programs/cairo2/account_panic.cairo @@ -0,0 +1,148 @@ +use starknet::account::Call; + +mod SUPPORTED_TX_VERSION { + const DEPLOY_ACCOUNT: felt252 = 1; + const DECLARE: felt252 = 2; + const INVOKE: felt252 = 1; +} + +#[starknet::interface] +trait IAccount { + fn is_valid_signature(self: @T, hash: felt252, signature: Array) -> felt252; + fn supports_interface(self: @T, interface_id: felt252) -> bool; + fn public_key(self: @T) -> felt252; +} + +#[starknet::contract] +mod Account { + use super::{Call, IAccount, SUPPORTED_TX_VERSION}; + use starknet::{get_caller_address, call_contract_syscall, get_tx_info, VALIDATED}; + use zeroable::Zeroable; + use array::{ArrayTrait, SpanTrait}; + use ecdsa::check_ecdsa_signature; + use box::BoxTrait; + use result::ResultTrait; + + const SIMULATE_TX_VERSION_OFFSET: felt252 = 340282366920938463463374607431768211456; // 2**128 + const SRC6_TRAIT_ID: felt252 = 1270010605630597976495846281167968799381097569185364931397797212080166453709; // hash of SNIP-6 trait + + #[storage] + struct Storage { + public_key: felt252 + } + + #[constructor] + fn constructor(ref self: ContractState, public_key: felt252) { + self.public_key.write(public_key); + } + + #[external(v0)] + impl AccountImpl of IAccount { + fn is_valid_signature(self: @ContractState, hash: felt252, signature: Array) -> felt252 { + let is_valid = self.is_valid_signature_bool(hash, signature.span()); + if is_valid { VALIDATED } else { 0 } + } + + fn supports_interface(self: @ContractState, interface_id: felt252) -> bool { + interface_id == SRC6_TRAIT_ID + } + + fn public_key(self: @ContractState) -> felt252 { + self.public_key.read() + } + } + + #[external(v0)] + #[generate_trait] + impl ProtocolImpl of ProtocolTrait { + fn __execute__(ref self: ContractState, calls: Array) -> Array> { + let arr = ArrayTrait::new(); + panic_with_felt252('panic'); + arr + //self.only_protocol(); + // self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); + // self.execute_multiple_calls(calls) + } + + fn __validate__(self: @ContractState, calls: Array) -> felt252 { + panic_with_felt252('panic'); + 0 +// self.only_protocol(); +// self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); +// self.validate_transaction() + } + + fn __validate_declare__(self: @ContractState, class_hash: felt252) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::DECLARE); + self.validate_transaction() + } + + fn __validate_deploy__(self: @ContractState, class_hash: felt252, salt: felt252, public_key: felt252) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::DEPLOY_ACCOUNT); + self.validate_transaction() + } + } + + #[generate_trait] + impl PrivateImpl of PrivateTrait { + fn only_protocol(self: @ContractState) { + let sender = get_caller_address(); + assert(sender.is_zero(), 'Account: invalid caller'); + } + + fn is_valid_signature_bool(self: @ContractState, hash: felt252, signature: Span) -> bool { + let is_valid_length = signature.len() == 2_u32; + + if !is_valid_length { + return false; + } + + check_ecdsa_signature( + hash, self.public_key.read(), *signature.at(0_u32), *signature.at(1_u32) + ) + } + + fn validate_transaction(self: @ContractState) -> felt252 { + let tx_info = get_tx_info().unbox(); + let tx_hash = tx_info.transaction_hash; + let signature = tx_info.signature; + + let is_valid = self.is_valid_signature_bool(tx_hash, signature); + assert(is_valid, 'Account: Incorrect tx signature'); + VALIDATED + } + + fn execute_single_call(self: @ContractState, call: Call) -> Span { + let Call{to, selector, calldata} = call; + call_contract_syscall(to, selector, calldata.span()).unwrap() + } + + fn execute_multiple_calls(self: @ContractState, mut calls: Array) -> Array> { + let mut res = ArrayTrait::new(); + loop { + match calls.pop_front() { + Option::Some(call) => { + let _res = self.execute_single_call(call); + res.append(_res); + }, + Option::None(_) => { + break (); + }, + }; + }; + res + } + + fn only_supported_tx_version(self: @ContractState, supported_tx_version: felt252) { + let tx_info = get_tx_info().unbox(); + let version = tx_info.version; + assert( + version == supported_tx_version || + version == SIMULATE_TX_VERSION_OFFSET + supported_tx_version, + 'Account: Unsupported tx version' + ); + } + } +} diff --git a/starknet_programs/cairo2/callee.cairo b/starknet_programs/cairo2/callee.cairo new file mode 100644 index 000000000..3a71ab549 --- /dev/null +++ b/starknet_programs/cairo2/callee.cairo @@ -0,0 +1,22 @@ +#[starknet::contract] +mod Callee { + #[storage] + struct Storage { + balance: felt252, + } + + #[constructor] + fn constructor(ref self: ContractState, initial_balance: felt252) { + self.balance.write(initial_balance); + } + + #[external(v0)] + fn return_42(ref self: ContractState) -> felt252 { + 42 + } + + #[external(v0)] + fn return_44(ref self: ContractState) -> felt252 { + 44 + } +} \ No newline at end of file diff --git a/starknet_programs/cairo2/caller.cairo b/starknet_programs/cairo2/caller.cairo new file mode 100644 index 000000000..179478d46 --- /dev/null +++ b/starknet_programs/cairo2/caller.cairo @@ -0,0 +1,19 @@ +#[starknet::contract] +mod Caller { + use starknet::call_contract_syscall; + use core::array; + use core::result::ResultTrait; + + #[storage] + struct Storage { + balance: felt252, + } + + #[external(v0)] + fn call_callee_contract(ref self: ContractState, function_selector: felt252) -> felt252 { + let calldata: Array = ArrayTrait::new(); + let callee_addr = starknet::get_contract_address(); + let return_data = call_contract_syscall(callee_addr, function_selector, calldata.span()).unwrap(); + *return_data.get(0_usize).unwrap().unbox() + } +} diff --git a/starknet_programs/cairo2/deploy.cairo b/starknet_programs/cairo2/deploy.cairo index b773e94bb..8025d11aa 100644 --- a/starknet_programs/cairo2/deploy.cairo +++ b/starknet_programs/cairo2/deploy.cairo @@ -1,6 +1,8 @@ +use starknet::class_hash::ClassHash; + #[starknet::interface] trait IDeployTest { - fn deploy_test(self: @TContractState, class_hash: felt252, contract_address_salt: felt252) -> starknet::contract_address::ContractAddress; + fn deploy_test(self: @TContractState, class_hash: ClassHash, contract_address_salt: felt252) -> starknet::contract_address::ContractAddress; } #[starknet::contract] @@ -21,10 +23,10 @@ mod DeployTest { #[external(v0)] impl DeployTest of super::IDeployTest { - fn deploy_test(self: @ContractState, class_hash: felt252, contract_address_salt: felt252) -> ContractAddress { + fn deploy_test(self: @ContractState, class_hash: ClassHash, contract_address_salt: felt252) -> ContractAddress { let mut calldata = ArrayTrait::new(); calldata.append(100); - let (address0, _) = deploy_syscall(class_hash.try_into().unwrap(), contract_address_salt, calldata.span(), false).unwrap(); + let (address0, _) = deploy_syscall(class_hash, contract_address_salt, calldata.span(), false).unwrap(); address0 } } diff --git a/starknet_programs/cairo2/echo.cairo b/starknet_programs/cairo2/echo.cairo new file mode 100644 index 000000000..1cf32b282 --- /dev/null +++ b/starknet_programs/cairo2/echo.cairo @@ -0,0 +1,17 @@ +#[starknet::contract] +mod Echo { + #[storage] + struct Storage { + balance: felt252, + } + + #[constructor] + fn constructor(ref self: ContractState, initial_balance: felt252) { + self.balance.write(initial_balance); + } + + #[external(v0)] + fn echo(ref self: ContractState, value: felt252) -> felt252 { + value + } +} \ No newline at end of file diff --git a/starknet_programs/cairo2/echo_caller.cairo b/starknet_programs/cairo2/echo_caller.cairo new file mode 100644 index 000000000..80e29eb18 --- /dev/null +++ b/starknet_programs/cairo2/echo_caller.cairo @@ -0,0 +1,20 @@ +#[starknet::contract] +mod EchoCaller { + use starknet::call_contract_syscall; + use core::array; + use core::result::ResultTrait; + + #[storage] + struct Storage { + balance: felt252, + } + + #[external(v0)] + fn call_echo_contract(ref self: ContractState, function_selector: felt252, value: felt252) -> felt252 { + let mut calldata: Array = ArrayTrait::new(); + calldata.append(value); + let callee_addr = starknet::get_contract_address(); + let return_data = call_contract_syscall(callee_addr, function_selector, calldata.span()).unwrap(); + *return_data.get(0_usize).unwrap().unbox() + } +} diff --git a/starknet_programs/cairo2/erc20.cairo b/starknet_programs/cairo2/erc20.cairo index c17e9b2f3..464cf5d7d 100644 --- a/starknet_programs/cairo2/erc20.cairo +++ b/starknet_programs/cairo2/erc20.cairo @@ -67,7 +67,7 @@ mod erc_20 { self.name.write(name); self.symbol.write(symbol); self.decimals.write(decimals); - assert(!recipient.is_zero(), 'ERC20: mint to the 0 address'); + // assert(!recipient.is_zero(), 'ERC20: mint to the 0 address'); self.total_supply.write(initial_supply); self.balances.write(recipient, initial_supply); self diff --git a/starknet_programs/cairo2/event_emitter.cairo b/starknet_programs/cairo2/event_emitter.cairo new file mode 100644 index 000000000..fd5bb8129 --- /dev/null +++ b/starknet_programs/cairo2/event_emitter.cairo @@ -0,0 +1,30 @@ +#[starknet::contract] +mod EventTest { + use starknet::syscalls::emit_event_syscall; + + #[storage] + struct Storage { + balance: felt252, + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + EmitEvent: EmitEvent + } + + #[derive(Drop, starknet::Event)] + struct EmitEvent { + n: u128, + } + + #[external(v0)] + fn trigger_event(ref self: ContractState) -> felt252 { + let mut keys = ArrayTrait::new(); + keys.append('n'); + let mut values = ArrayTrait::new(); + values.append(1); + emit_event_syscall(keys.span(), values.span()).unwrap(); + 1234 + } +} diff --git a/starknet_programs/cairo2/hello_world_account.cairo b/starknet_programs/cairo2/hello_world_account.cairo index c87651795..c98ded486 100644 --- a/starknet_programs/cairo2/hello_world_account.cairo +++ b/starknet_programs/cairo2/hello_world_account.cairo @@ -108,7 +108,7 @@ mod Account { // Call the target contract starknet::call_contract_syscall( address: to, entry_point_selector: selector, calldata: calldata.span() - ).unwrap_syscall() + ).unwrap() } } } diff --git a/starknet_programs/cairo2/square_root_recursive.cairo b/starknet_programs/cairo2/square_root_recursive.cairo new file mode 100644 index 000000000..a960e572e --- /dev/null +++ b/starknet_programs/cairo2/square_root_recursive.cairo @@ -0,0 +1,37 @@ +use starknet::ClassHash; + +#[starknet::interface] +trait Math { + fn square_root(self: @TContractState, n: felt252) -> felt252; +} + +#[starknet::interface] +trait ISquareRoot { + fn square_root(self: @TContractState, n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252; +} + + +#[starknet::contract] +mod SquareRoot { + use super::MathDispatcherTrait; + use super::MathLibraryDispatcher; + use starknet::ClassHash; + + #[storage] + struct Storage{ + } + + #[external(v0)] + impl SquareRoot of super::ISquareRoot { + fn square_root(self: @ContractState, n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + square_root_recursive_inner(n, math_class_hash, n_iterations) + } + } + + fn square_root_recursive_inner(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + if n_iterations == 0 { + return n; + } + square_root_recursive_inner(MathLibraryDispatcher {class_hash: math_class_hash}.square_root(n), math_class_hash, n_iterations - 1) + } +} diff --git a/starknet_programs/cairo2/wallet_wrapper.cairo b/starknet_programs/cairo2/wallet_wrapper.cairo index 5208f8f73..d4a4a241b 100644 --- a/starknet_programs/cairo2/wallet_wrapper.cairo +++ b/starknet_programs/cairo2/wallet_wrapper.cairo @@ -7,7 +7,8 @@ trait SimpleWallet { #[starknet::interface] trait IWalletWrapper { fn get_balance(self: @TContractState, simple_wallet_contract_address: starknet::ContractAddress) -> felt252; - fn increase_balance(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); + fn increase_balance(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); + fn increase_balance_recursive(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); } #[starknet::contract] @@ -28,5 +29,16 @@ mod WalletWrapper { fn increase_balance(ref self: ContractState, amount: felt252, simple_wallet_contract_address: ContractAddress) { SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(amount) } + fn increase_balance_recursive(ref self: ContractState, amount: felt252, simple_wallet_contract_address: ContractAddress) { + increase_balance_recursive_inner(amount, simple_wallet_contract_address) + } + } + + fn increase_balance_recursive_inner(amount: felt252, simple_wallet_contract_address: ContractAddress) { + if amount == 0 { + return(); + } + SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(1); + increase_balance_recursive_inner(amount - 1, simple_wallet_contract_address) } } diff --git a/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra b/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra new file mode 100644 index 000000000..0925ceabe --- /dev/null +++ b/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra @@ -0,0 +1,687 @@ +{ + "sierra_program": [ + "0x1", + "0x2", + "0x0", + "0x2", + "0x0", + "0x0", + "0x13e", + "0xc2", + "0x2a", + "0x52616e6765436865636b", + "0x0", + "0x4761734275696c74696e", + "0x66656c74323532", + "0x4172726179", + "0x1", + "0x2", + "0x536e617073686f74", + "0x3", + "0x537472756374", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x4", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x456e756d", + "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", + "0x6", + "0x2d7b9ba5597ffc180f5bbd030da76b84ecf1e4f1311043a0a15295f29ccc1b0", + "0x7", + "0x753332", + "0x4275696c74696e436f737473", + "0xa5a3299e5660d06bfa52eacd3a1fcd165ecd6f0cbac6f443fe26f6f68c70f3", + "0x38c95698b12086e50047d206c91c7248ef6f3427861aea1234b080c80fddf35", + "0xb", + "0x53797374656d", + "0xc", + "0x14de46c93830b854d231d540339ee8ae16bb18830a375fe81572a472d5945f1", + "0xf", + "0x3b5488061ac7a66f24fcbc888e7d6d5454df009b3abc2572f25f2400cfac629", + "0xe", + "0x10", + "0x5", + "0x19b3b4955bdcfa379bfc5a4949111c4efdd79128f8676f4d0895419b22e2ad7", + "0x12", + "0x426f78", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x14", + "0x4e6f6e5a65726f", + "0x464c55b21b6d3dadb22fd8587d389a14c0e53182f19e003bdf15db3ecb1676", + "0x75313238", + "0x16c8ea90dd6c64f624ab9863dc00b8f2c35a45fb64a97fa4bac6359fba975ec", + "0x18", + "0x3610c7cf372ee49406b6d03ec0b82f790884fb8652a25c91b2a749ad8982bc5", + "0x19", + "0x17", + "0xcfb175da425fe9834ebf5c4c2342c0507188ad820763d15abada732ab9341a", + "0x1b", + "0x20df6a887dc282129d37d7fa362eda55eb38e5c74604aff8fd97f11e3e79a2f", + "0x1d", + "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", + "0xd3a26a7712a33547a4a74e7594a446ca400cb36a0c2c307b92eff9ce82ff8", + "0x20", + "0x53746f726167654261736541646472657373", + "0x2cf4ead4392e987c9b56754a10f0a8e0f13776791e096fa6503893f05582c51", + "0x23", + "0x1586938debaf5e59bfb4e9f27763dc7b3da65f9737172ffde9ff9b65b55d857", + "0x24", + "0x1ca27f4a416836d321a19551a437aeb9946fde25373762126dda39b53c0bd11", + "0x53746f7261676541646472657373", + "0x1909a2057b9c1373b889e003e050a09f431d8108e0659d03444ced99a6eea68", + "0xb1", + "0x7265766f6b655f61705f747261636b696e67", + "0x656e61626c655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x73746f72655f74656d70", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x8", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x9", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x7533325f6571", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x6a756d70", + "0x626f6f6c5f6e6f745f696d706c", + "0x6765745f6275696c74696e5f636f737473", + "0xa", + "0x77697468647261775f6761735f616c6c", + "0x64697361626c655f61705f747261636b696e67", + "0xd", + "0x11", + "0x61727261795f6e6577", + "0x13", + "0x66656c743235325f636f6e7374", + "0x4f7574206f6620676173", + "0x61727261795f617070656e64", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x15", + "0x756e626f78", + "0x66656c743235325f737562", + "0x66656c743235325f69735f7a65726f", + "0x16", + "0x1a", + "0x1c", + "0x753132385f636f6e7374", + "0x1e", + "0x656d69745f6576656e745f73797363616c6c", + "0x1f", + "0x21", + "0x73746f726167655f626173655f616464726573735f636f6e7374", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x22", + "0x25", + "0x753132385f6f766572666c6f77696e675f616464", + "0x26", + "0x753132385f616464204f766572666c6f77", + "0x753132385f746f5f66656c74323532", + "0x73746f726167655f616464726573735f66726f6d5f62617365", + "0x27", + "0x73746f726167655f77726974655f73797363616c6c", + "0x477e157efde59c5531277ede78acb3e03ef69508c6c35fde3495aa0671d227", + "0x1d3bd105efd11cb4e1d188c3f2b302935b4db511160389bd8b0a936ce967708", + "0x73746f726167655f726561645f73797363616c6c", + "0x28", + "0x53746f7261676541636365737355313238202d206e6f6e2075313238", + "0x75313238735f66726f6d5f66656c74323532", + "0x29", + "0x304", + "0xffffffffffffffff", + "0x76", + "0x66", + "0x53", + "0x44", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x3d", + "0x2f", + "0x30", + "0x31", + "0x32", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x39", + "0x3a", + "0x3b", + "0x3c", + "0x3e", + "0x3f", + "0x40", + "0x41", + "0x42", + "0x43", + "0x45", + "0x46", + "0x47", + "0x48", + "0x4b", + "0x49", + "0x4a", + "0x4c", + "0x4d", + "0x4e", + "0x4f", + "0x50", + "0x51", + "0x52", + "0x54", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5b", + "0x5c", + "0x5d", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x62", + "0x63", + "0x64", + "0x65", + "0x67", + "0x68", + "0x69", + "0xe3", + "0x9a", + "0x9e", + "0xd1", + "0xc4", + "0xbd", + "0xf9", + "0xfe", + "0x124", + "0x11a", + "0x11f", + "0x145", + "0x13e", + "0x17d", + "0x1a3", + "0x19c", + "0x194", + "0x18c", + "0x185", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x70", + "0x71", + "0x72", + "0x73", + "0x74", + "0x75", + "0x77", + "0x78", + "0x79", + "0x7a", + "0x7b", + "0x1c2", + "0x1e3", + "0x1e8", + "0x1f3", + "0x219", + "0x212", + "0x226", + "0x7c", + "0x7d", + "0x22a", + "0x7e", + "0x7f", + "0x80", + "0x81", + "0x236", + "0x82", + "0x83", + "0x84", + "0x85", + "0x24b", + "0x250", + "0x25b", + "0x86", + "0x87", + "0x88", + "0x89", + "0x8a", + "0x271", + "0x8b", + "0x8c", + "0x8d", + "0x27c", + "0x8e", + "0x8f", + "0x90", + "0x91", + "0x92", + "0x287", + "0x93", + "0x94", + "0x95", + "0x96", + "0x97", + "0x2ad", + "0x98", + "0x99", + "0x29f", + "0x9b", + "0x9c", + "0x9d", + "0x9f", + "0xa0", + "0xa1", + "0x2bc", + "0xa2", + "0x2c9", + "0xa3", + "0xa4", + "0xa5", + "0xa6", + "0xa7", + "0x2e8", + "0xa8", + "0xa9", + "0x2ef", + "0xaa", + "0xab", + "0xac", + "0xad", + "0xae", + "0xaf", + "0xb0", + "0xf2", + "0x12b", + "0x1ab", + "0x1af", + "0x1c8", + "0x1fa", + "0x220", + "0x23b", + "0x262", + "0x264", + "0x281", + "0x28d", + "0x2b6", + "0x2c2", + "0x2d2", + "0x2dc", + "0x2e2", + "0x2f2", + "0x2fe", + "0x1c1c", + "0x241c0d01018140c0302c0407050240c060401c0c06028080802018080200", + "0x182c02038282a020302804140104c2006090182202048382006080181e02", + "0x700409070240c1b030340409050680406050400c19030340409050083017", + "0x184602048380e06030883c06108184002048383e06068080e0a0f0183a06", + "0xb00c2b030a80409070a40c280101c14021389804060501c0c06128400c24", + "0x185e020483820060b8181a02048283c06170185a02048385206068080e0a", + "0x8681e030cc0c32010241c10030340407050240c10030c40409070780c30", + "0x187202048383c061c0186e02048386c06068080e0a0481852061a808120e", + "0xfc043e010f47829030a40c0d010241410030a40c3b010241c021d0a40c29", + "0x1c0c062307c0c06229100c06218080c062081c12062107c0c06208088002", + "0x138200603134044c240180c41240180c4b0101c0c4a240180c49240180c47", + "0x400c06248480c0621808a006038480c07270089e12030188202038480c07", + "0x104aa06031040c06031043206031342e060313404540114ca406031040451", + "0x240c06248240c062381c0c062b8740c06249580c06218241206210640c06", + "0x180c490301cb00603938b0060310404072c0180e4e108180c4d0f8180c4d", + "0x18b20c04818841e030189a1b030189a0703018b60703018825a03818b212", + "0x180c410101cbe06039380e06031783e0903108ba07031643e0603124b807", + "0x1c0c062381c0c062581c0c063017c0c06218180e5f0301c9c5f03018820c", + "0x1388806031040407220180e4e318180c490118804610101c0c59038180c49", + "0x740c06228401206211900c06208180e640301c9c2c030189a06039100c07", + "0x10c2409031082e06031042e060311c320603114ac06031040c072b0180e4e", + "0x18842903018820603818cc02039900c07270ac0c06268b80c06229940c06", + "0x180c490101cac06039383a0603134600603114ce060310c9009031088809", + "0x188409030188264030189264030188e5204818840203818cc10030188217", + "0x240c42348180c4b0301cd20603938d206031040407348180e4e011a02e09", + "0x18865504818846d03018826c03818d619030189233030188a6a030188619", + "0x180c410101cca06039385c06031343a09031086c0603104700603114dc06", + "0x18b206039c00c07271c00c06208080e700301c9c02378180e650301c9c65", + "0x180e4e180180c4d011d4e806031040473011c8360903108e0060312ce207", + "0x18842b03018827603818b2640301886060399c0c072719c0c06208080e67", + "0x138660603134d2060310c12060312cac0903108580603104ee07031643c09", + "0x1c9c790301886210481884023c0180e6a0301c9c6a030188202039a80c07", + "0x1cdc0603938f40703164dc06031040407370180e4e1c0180c4d0101c6c06", + "0x1601206210ac0c06228a40c06249c00c06218d80c06218180e360301c9c06", + "0x180e4e3e0180c493e0180c4d3c8180c410101cf20603938047b160180c49", + "0x8047e0300804023e8901206210a40c06259e40c06258080c06258180e79", + "0x3004023f01804090104820073f87c18073f01c0c020381c04023f0180406", + "0x1200c12010300c7e030300c100112088073f018a4060f808a4063f0181206", + "0x1f80c55031200455031f80c440311004023f0180409010640c800b818fc07", + "0x1480456031f80c020c808047e0306c0c170107836073f0183a06290083a06", + "0x18b0062a80848063f0183c062a808047e030840c170116042073f018ac06", + "0x8fc0601024040215808fc072f8900e1b010900c7e030900c1d0117c0c7e", + "0x180458010a40c7e030b00c21010b00c7e0318c0c560118c0c7e030083c02", + "0x1900c21011900c7e030ac0c24010ac0c7e030083c02011f80c02048080430", + "0x18fc0717018c60217018fc0617018420217018fc0614818be0214818fc06", + "0x18560233818fc06010a404023f018ca0616008047e030081202180190265", + "0x8047e030081202369a80e82199a40e7e0399c3e0c049900467031f80c67", + "0x18fc063481820021c018fc061b01860021b018fc060119404023f018042e", + "0x840484031f80c38030cc0483031f80c07031a40400031f80c330319c047c", + "0x1f80e79031b404793a1c0dc0c3f0190a8441800f81f350090a063f0182e06", + "0x1b80489031f80c021c008047e032180c3601008fc060102404880321d0c06", + "0x1918063c80918063f01916063a008047e032280c700122d14073f0191206", + "0x2400c7e031c00c670123c0c7e031b80c10012380c7e032340c7c012340c7e", + "0x1f80c020480924914823c180649018fc0647018000248818fc063a018d202", + "0x1a40495031f80c700319c0494031f80c6e030400493031f80c880320c0402", + "0x8047e0300812024b21d2a94060192c063f0192606000090e063f018e806", + "0x930063f01804850125c0c7e030087002011f80c170321004023f018042e", + "0x2680e8a012680c7e0300912024c818fc064c25c0e88012600c7e032600c86", + "0x1f80c6d0319c049c031f80c6a030400482031f80c9b0320c049b031f80c99", + "0x812024fa793a9c060193e063f0190406000093c063f0180e06348093a06", + "0x1c0c6901008fc060b8190802011f80c30030b004023f018042e01008fc06", + "0x28c0c7e030087002011f80ca2030b004a25081cfc0650019160250018fc06", + "0x9120252818fc065228c0e88012900c7e032900c86012900c7e030091802", + "0x1f80c0c0304004a8031f80ca70320c04a7031f80ca55301d140253018fc06", + "0x1956063f01950060000954063f01942063480902063f0183e06338095206", + "0x191a02011f80c19030b004023f018042e01008fc060102404ab55205520c", + "0x95a063f0195a06430095a063f018048e012b00c7e030087002011f80c44", + "0x19060258018fc06572bc0e8a012bc0c7e03009120257018fc0656ab00e88", + "0x1f80c07031a404b3031f80c1f0319c04b2031f80c0c0304004b1031f80cb0", + "0x1f80c0217008047e0300812025aad166b2060196a063f0196206000096806", + "0x196e06430096e063f0180485012d80c7e030087002011f80c09032340402", + "0x18fc065c2e40e8a012e40c7e0300912025c018fc065bad80e88012dc0c7e", + "0x1a404bc031f80c120319c0480031f80c100304004bb031f80cba0320c04ba", + "0x8047e0300804025f2f57880060197c063f0197606000097a063f0180e06", + "0x11004023f01804090104820075f87c18073f01c0c020381c04023f0180406", + "0x1480c170105ca4073f01890062900890063f01888062400888063f0181206", + "0x8047e031540c1701074aa073f01832062900832063f018041901008fc06", + "0x300c100106c0c7e0306c0c1d010780c7e030740c550106c0c7e0305c0c55", + "0x1580c7e030083c02011f80c020480804c0011f80e1e0d81c360206018fc06", + "0x1f80c020480804c103008b0022c018fc0610818420210818fc062b018ac02", + "0x18be022c018fc062f81842022f818fc0612018480212018fc06010780402", + "0x8120214819842c031f80e630318c0463031f80c63030840463031f80c58", + "0xac0c2b010ac0c7e030085202011f80c2c030b004023f018042e01008fc06", + "0x19404023f0180409010c0ca07618b8c8073f01c561f06024c80215818fc06", + "0x1f80c07031a40436031f80c2e0319c0469031f80c67030c00467031f80c02", + "0x18c80608008da6a19824fc06370e06c0947808dc063f018d206198087006", + "0x8fc06380186c02011f80c0204808e806621c00c7e039b40c6d011900c7e", + "0xc7401008fc063e018e002001f00e7e031e40c6e011e40c7e030087002", + "0x18fc0632018200242818fc0642018f80242018fc0641818f20241818fc06", + "0x300c8a031f80c85030000489031f80c6a031a40488031f80c330319c0486", + "0x918063f018c8060800916063f018e80641808047e030081202452251086", + "0x235180c0323c0c7e0322c0c00012380c7e031a80c69012340c7e030cc0c67", + "0x1922064300922063f0180485012400c7e030087002011f80c02048091e8e", + "0x18fc064924c0e8a0124c0c7e03009120249018fc0648a400e88012440c7e", + "0x1a40496031f80c300319c0487031f80c65030400495031f80c940320c0494", + "0x8047e0300812024c25d2c870601930063f0192a06000092e063f0180e06", + "0x1cfc064d81916024d818fc0603818d202011f80c29030b004023f018042e", + "0x2700c86012700c7e03009180241018fc06010e004023f0193406160093499", + "0x1f80c9d4f01d14024f018fc0601224049d031f80c9c4101d10024e018fc06", + "0x940063f0183e063380944063f01818060800942063f0193e06418093e06", + "0x8fc060102404a451a81440c032900c7e032840c000128c0c7e032640c69", + "0x2980c7e030090a0252818fc06010e004023f018120646808047e030085c02", + "0x1d140254018fc060122404a7031f80ca65281d100253018fc06530190c02", + "0x1824063380954063f01820060800902063f01952064180952063f0194ea8", + "0x11004ad562ad540c032b40c7e032040c00012b00c7e0301c0c69012ac0c7e", + "0x192202011f80c02048081806628240e073f01c0c06480080c063f0180406", + "0x98c06011600412031f80c1f0324c0410031f80c0703248041f031f80c09", + "0x1f80c0c032480448031f80c44032500444031f80c020f008047e030081202", + "0x8a4063f018a40606008a4063f01820063a00824063f0189006498082006", + "0x192c022a818fc060b8190e02011f80c020480832066385c0c7e038480c95", + "0x18fc060126404023f01836064c0083c1b039f80c1d0325c041d031f80c55", + "0x25c0424031f80c1e0325804023f01842064c008b021039f80c560325c0456", + "0x1858064b80858063f018b0064b008047e0317c0c980118cbe073f0184806", + "0xb80c7e030ac0c96011900c7e0318c0c9601008fc06148193002158a40e7e", + "0x26c0465031f80c65032180465031f80c2e3201d340232018fc06320190c02", + "0x1f80c67030900467031f80c020f008047e0300812021801990023f01cca06", + "0x18600641008047e030081202013240c022c00866063f018d20610808d206", + "0x17c0433031f80c6d03084046d031f80c6a03158046a031f80c020f008047e", + "0x1870064e808dc063f018a4060600870063f0186c064e0086c063f0186606", + "0x1d00c7e030083c02011f80c19030b004023f0180409011c0dc07031c00c7e", + "0x1f00e0600018fc063c8193a023e018fc062901818023c818fc063a0193c02", + "0x27c04023f0183e0616008047e03008120208019941f031f80e0c0318c0400", + "0x1f80c07031a40419031f80c060319c0444031f80c12032840412031f80c02", + "0x1f80c1b0e954320c5000836063f0188806510083a063f018120619808aa06", + "0x1f80c1e0328c04023f0180409011580ccb0f018fc070b818da020b9489009", + "0x8be063f01890063380848063f018040608008047e031600c2c011604207", + "0x8fc06010240402660180458010b00c7e030840c330118c0c7e031480c69", + "0x18d20232018fc0624018ce0215818fc0601018200214818fc062b0194802", + "0xb004023f0180409011945c64158300c65031f80c2903294042e031f80c52", + "0x18040608008d267039f80c300329c0430031f80c090329804023f0182006", + "0x1d00c7e031a40ca8011c00c7e0301c0c69011b80c7e030180c67010e00c7e", + "0x24047c03334f2063f01c6c06408086c6d350cc187e031d0e06e1c0315202", + "0x18fc0641819580241818fc0600019560200018fc063c8195402011f80c02", + "0xcc048b031f80c6d031a4048a031f80c6a0319c0485031f80c67030c00484", + "0x2251086049f80c8d4622d140c500091a063f01908065100918063f0190a06", + "0x92290039f80c8e0328c04023f01804090123c0cce47018fc0744818da02", + "0xcc0c100125126073f01924065380924063f019200653008047e032440c2c", + "0x18fc064a01950024d018fc0644018d2024c818fc0643018ce024c018fc06", + "0x9380667a080c7e03a5c0c810125d2c874a830fc064da693298062a4049b", + "0x18fc064a81820024f018fc06012b4049d031f80c82032a804023f0180409", + "0x27c0e7e0328d40a204abc04a3031f80c9e032b804a0031f80c9d032b804a2", + "0x94c063f019480655008047e03008120252819a0a4031f80ea10320404a1", + "0x2980cae012ac0c7e0324c0ca8012a80c7e032580c69012040c7e0321c0c67", + "0x19a2ad031f80ea9032c404a95429c127e032b156aa40831600256018fc06", + "0x2bc0c3001008fc06580185802582bc0e7e032b40cb201008fc060102404ae", + "0x18fc0654018d2022f818fc0653818ce0212018fc064f818200258818fc06", + "0x2d004b3031f80cb21601d660259018fc0601078042c031f80cb1030cc0463", + "0x18c606348096c063f018be06338096a063f01848060800968063f0196606", + "0x2b80ca401008fc060102404b85bad96a0c032e00c7e032d00ca5012dc0c7e", + "0x18fc0654018d2025d818fc0653818ce025d018fc064f81820025c818fc06", + "0x1f80c93032d404023f0180409012f100bb5d0300cbc031f80cb9032940480", + "0x1a404d2031f80c870319c04be031f80c9f0304004bd031f80ca5032900402", + "0x8047e0300812026a34da4be06019a8063f0197a0652809a6063f0192c06", + "0x190e0633809ac063f0192a0608009aa063f019380652008047e0324c0cb5", + "0x2404d96c35dac0c033640c7e033540ca5013600c7e032580c690135c0c7e", + "0x18fc0643018ce026d818fc061981820026d018fc06478194802011f80c02", + "0x180409011fdbadc6d8300c7f031f80cda0329404dd031f80c88031a404dc", + "0x19c04df031f80c330304004de031f80c7c0329004023f018ce065a808047e", + "0x385c0df06019c4063f019bc0652809c2063f018da0634809c0063f018d406", + "0x1c0e0604818fc06030196c0203818fc0601018d20203018fc060107804e2", + "0x18d20222018fc0601018ce0206018fc06012dc0409031f80c07032980409", + "0x1489044062c00417031f80c0c032b80452031f80c09032a00448031f80c06", + "0x196402011f80c0204808aa06718640c7e038480cb101048201f049f80c17", + "0x18fc0601078041e031f80c1d030c004023f018360616008361d039f80c19", + "0x848063f0183e0633808b0063f01842065a00842063f018ac1e03acc0456", + "0x8047e0300812023197c48090318c0c7e031600ca50117c0c7e030400c69", + "0xb00ca5010ac0c7e030400c69010a40c7e0307c0c67010b00c7e031540ca4", + "0xe0040c031f80c1f032e0041f031f80c09032880464158a4120632018fc06", + "0x1f80c44032e804482201cfc0606019720209018fc06010e00410031f80c02", + "0x200041b031f80c12032ec041d031f80c10032ec0455031f80c48032880402", + "0x8ac1e039f80c52031b804023f018320616008321729024fc060d874aa09", + "0x1600c7001090b0073f0182e063700842063f018ac063a008047e030780c70", + "0x17c0c7e0317c0c0c010840c7e030840c0c0117c0c7e030900c7401008fc06", + "0x18041e01008fc06010240464158a412e41618c0e7e0397c4206010317802", + "0x19c0c7e030b00c69010c00c7e0318c0c67011940c7e030b80cbd010b80c7e", + "0x18fc0632019a402011f80c020480804e503008b00234818fc06328197c02", + "0x34c0469031f80c33032f80467031f80c2b031a40430031f80c290319c0433", + "0x240438033986c063f01cd4066a808d4063f018da066a008da063f018d206", + "0x1f80c70032d00470031f80c6e0381d660237018fc061b019ac02011f80c02", + "0x1800063f018e80652808f8063f018ce0634808f2063f018600633808e806", + "0x19c0483031f80c380329004023f0180e066b808047e030081202001f0f209", + "0x2190a84048190c063f0190606528090a063f018ce063480908063f0186006", + "0x1f80c0203040041f031f80c020c80818063f01804d801008fc06048196a02", + "0x8aa063f0183e060e80832063f0180e06348082e063f0180c0633808a406", + "0x1c90066d808904409040187e03074aa190b9483eda010740c7e030300cd9", + "0x18fc062b019ba022b018fc060d819b802011f80c02048083c067386c0c7e", + "0x8047e0300812022f819d024031f80e21032040421031f80c58031fc0458", + "0x400c10010a40c7e030b00cdf010b00c7e0318c0cde0118c0c7e030900caa", + "0x18fc0614819c00217018fc0622018d20232018fc0609018ce0215818fc06", + "0x1f80c10030400430031f80c5f0338404023f0180409011945c64158300c65", + "0x18d4063f01860067000866063f018880634808d2063f018240633808ce06", + "0xd80c7e030400c10011b40c7e030780ce101008fc0601024046a199a4ce0c", + "0xd8180638018fc0636819c00237018fc0622018d2021c018fc0609018ce02", + "0x19d402011f80c0204808201f03ba41809039f80e070300812e2011c0dc38", + "0x9d806011600448031f80c12033ac0444031f80c09030400412031f80c0c", + "0x18a4067580888063f0183e0608008a4063f018200676808047e030081202", + "0x83a063f0182e0643008aa063f0189006778082e063f01804ee011200c7e", + "0x2a804023f0180409010780cf10d818fc070c81902020c818fc060e9540ef0", + "0x18880608008b0063f01842066f80842063f018ac066f008ac063f0183606", + "0x1f80c1e0338404023f01804090117c48070317c0c7e031600ce0010900c7e", + "0x180e0653808522c0381852063f018c6067000858063f018880608008c606", + "0x824063f01812067900820063f01804d801008fc060f8196a020f8300e7e", + "0x1888067a00890063f01890060e80890063f0180419011100c7e030400cf3", + "0x8fc0601024041d2a86412f60b9480e7e038488848030083ef5011100c7e", + "0x5c0c69011580c7e031480c67010780c7e0306c0cbd0106c0c7e030083c02", + "0x19a402011f80c020480804f703008b0022c018fc060f0197c0210818fc06", + "0x1f80c24032f80421031f80c55031a40456031f80c190319c0424031f80c1d", + "0x3e058063f01cbe066a808be063f018c6066a008c6063f018b00669808b006", + "0x3e80464031f80c2b0601df20215818fc0616019ac02011f80c02048085206", + "0x185c067d80860063f018420634808ca063f018ac06338085c063f018c806", + "0x1f80c29033f004023f01818065a808047e030081202338c0ca090319c0c7e", + "0x18da063f018d2067d808d4063f01842063480866063f018ac0633808d206", + "0x818067f0240c7e038080cfd010180c0603018fc06010194402369a86609", + "0x1f80c1f0301d10020f818fc060f8190c020f818fc06013fc04023f0180409", + "0x832063f0180e065d8082e063f01820065d808a4063f0181206800082006", + "0x8aa063f01824065d808047e031200c2c011208812049f80c190b9481301", + "0x836063f018050301008fc06010240402810180458010740c7e031100cbb", + "0x19760212018fc060601a08020f018fc060d8180e880106c0c7e0306c0c86", + "0xb0045810958127e0318cbe2404c140463031f80c07032ec045f031f80c1e", + "0x18fc0601078041d031f80c21032ec0455031f80c56032ec04023f018b006", + "0x240c64031f80c2c032d8042b031f80c1d034180429031f80c5503418042c", + "0x18fc060301a1202011f80c02048080e06840180c7e038080d07011905629", + "0x8047e0300812020f8180c1f031f80c0c0342c040c031f80c09034280409", + "0x1100d0b011100c7e030480d0c010480c7e0301c20074500820063f0180489", + "0x4820093f01c3e0903818190d0107c0c7e030300cf3011200c0624018fc06", + "0x18fc06220190c020e818fc06010182002011f80c02048082e52240261c44", + "0x480c7e030480c69010400c7e030400c670115432073f018361d03c3c041b", + "0x4480421031f80c1e0330004023f0180409011580d110f018fc072a81a2002", + "0x18200633808be063f01832060800848063f018b00689808b0063f0184206", + "0x2404291618cbe0c030a40c7e030900d14010b00c7e030480c690118c0c7e", + "0x2180464031f80c026080856063f018043801008fc062b0185802011f80c02", + "0xb8ca0745008ca063f0180489010b80c7e03190560744008c8063f018c806", + "0x18fc0608018ce0234818fc060c818200233818fc061801a2a0218018fc06", + "0x180409011b4d433348300c6d031f80c6703450046a031f80c12031a40433", + "0x8dc063f01870068980870063f0186c06890086c063f0182e068b008047e", + "0x1b80d14011e40c7e031480c69011d00c7e031200c67011c00c7e030080c10", + "0x8fc06010240407034600c063f01c04068b808f8793a1c018063e018fc06", + "0x7c0c060f818fc0606019c00206018fc0604819be0204818fc0603019bc02", + "0x1824067080824063f0180e1003a280410031f80c0244808047e030081202", + "0x240409034680e063f01c04068c8089006031200c7e031100ce0011100c7e", + "0x7c0c7e030300cdf010300c7e0301c0cde01008fc06030193002011f80c02", + "0x87002011f80c090346c04023f0180409010400c0608018fc060f819c002", + "0x1f80c442401d140224018fc06012240444031f80c060901d100209018fc06", + "0x1f80c020347004190301832063f0182e06700082e063f018a40670808a406", + "0x300e7e0304820078e80824063f0180e065d80820063f0181206570081206", + "0x300cbb011200c7e030180cbb011100c7e030083c02011f80c1f030b0041f", + "0x83c02011f80c020347804172912012060b818fc06220196c0229018fc06", + "0x18fc06048196c020f818fc0603819760206018fc0603019760204818fc06", + "0x8fc060102404100f83013200481c0e7e0381804078f808201f060240c10", + "0x8b00224018fc060901a440222018fc0603818200209018fc060481a4202", + "0x7804023f018a40692808a4063f018201f03c9004023f01804090100a4606", + "0x1f80c19034880444031f80c0c030400419031f80c17034980417031f80c02", + "0x180406948083a55038183a063f018900694008aa063f0188806938089006", + "0x8fc060601930020f8300e7e030240c97010240c7e0301c0cf20101c0c7e", + "0x82410039f80c482201e540224018fc0603019760222018fc060f8190c02", + "0x1f80c52032d80417031f80c10032ec0452031f80c020f008047e030480c2c", + "0x18041e010240c7e0301c0c07440080e063f01804064b0083217038183206", + "0x18040c2f8403e07030400c7e030300cb60107c0c7e030240cbb010300c7e", + "0x3d4120703008b05503008181f2a818040c010240e0601160aa06010303e55", + "0x1caa0696030120703008ac550300818120c9540c020fcac04440f81c3e06", + "0x1804562a81812640c9540c0c9701c0c022b1540c090c9540c09968082055", + "0x1804650101c52290102660090381804652a818040c0b9540c02064bc1207", + "0x24120932026660232018c806990240e060119caa06048a42e55030326207", + "0x1c0c02371540c02061b49055030083f35011a80c69034d00e06010401209", + "0x180410048241209048ac133803008ca06039c00f37011940c36034d81809", + "0x1c122903cec0c023c8080e070101e7407030082009048241209160267207", + "0x27a060104012070481c0f3c030082009" + ], + "sierra_program_debug_info": { + "type_names": [], + "libfunc_names": [], + "user_func_names": [] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x966af5d72d3975f70858b044c77785d3710638bbcebbd33cc7001a91025588", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "function_idx": 1 + } + ] + }, + "abi": [ + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "function", + "name": "emit_event", + "inputs": [ + { + "name": "incremental", + "type": "core::bool" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "event", + "name": "events::events::ContractWithEvent::IncrementalEvent", + "kind": "struct", + "members": [ + { + "name": "value", + "type": "core::integer::u128", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "events::events::ContractWithEvent::StaticEvent", + "kind": "struct", + "members": [] + }, + { + "type": "event", + "name": "events::events::ContractWithEvent::Event", + "kind": "enum", + "variants": [ + { + "name": "IncrementalEvent", + "type": "events::events::ContractWithEvent::IncrementalEvent", + "kind": "nested" + }, + { + "name": "StaticEvent", + "type": "events::events::ContractWithEvent::StaticEvent", + "kind": "nested" + } + ] + } + ] +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm b/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm new file mode 100644 index 000000000..e8527a982 --- /dev/null +++ b/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm @@ -0,0 +1,1429 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xfffffffffffffffffffffffffffefe08", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x79", + "0x4825800180007ffa", + "0x101f8", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xf9", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x60", + "0x48307ffb80007ffc", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x3d", + "0x1104800180018000", + "0x354", + "0x482480017fff8000", + "0x353", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fe1", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff37fff", + "0x10780017fff7fff", + "0x20", + "0x4824800180007fe1", + "0x0", + "0x400080007ff47fff", + "0x482480017ff48000", + "0x1", + "0x48127ffe7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff07fff8000", + "0x1104800180018000", + "0xfe", + "0x20680017fff7ffd", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff18000", + "0x1", + "0x48127fdc7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x15a", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff47fff8000", + "0x48127fdf7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fe87fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffe3b8", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x64", + "0x4825800180007ffa", + "0x1c48", + "0x400280007ff97fff", + "0x48297ffc80007ffd", + "0x482680017ff98000", + "0x1", + "0x4824800180007ffe", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x3c", + "0x1104800180018000", + "0x2cd", + "0x482480017fff8000", + "0x2cc", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007ff4", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff47fff", + "0x10780017fff7fff", + "0x1f", + "0x4824800180007ff4", + "0x0", + "0x400080007ff57fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xfe", + "0x482480017fd48000", + "0x1", + "0x20680017fff7ffc", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff28000", + "0x1", + "0x48127fef7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xd4", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff57fff8000", + "0x48127ff27fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x15", + "0x480080007ffd8000", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x6", + "0x480680017fff8000", + "0x1", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x48307ffb80007ffc", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x4", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffd", + "0x1d", + "0x40780017fff7fff", + "0x96", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x1104800180018000", + "0x92", + "0x20680017fff7ffd", + "0x7", + "0x480a7ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x10780017fff7fff", + "0x35", + "0x40780017fff7fff", + "0x3", + "0x480a7ffa7fff8000", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0xc1", + "0x20680017fff7ffd", + "0x56", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x1104800180018000", + "0x73", + "0x20680017fff7ffd", + "0x43", + "0x48127fb17fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x1104800180018000", + "0xb1", + "0x20680017fff7ffd", + "0x32", + "0x48127ffa7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x1104800180018000", + "0xd6", + "0x20680017fff7ffd", + "0x20", + "0x48127fe57fff8000", + "0x48127fe57fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xf9", + "0x20680017fff7ffd", + "0xf", + "0x48127fe47fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x3", + "0x48127fe17fff8000", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1b", + "0x48127fe17fff8000", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fdf7fff8000", + "0x48127fdf7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x31", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x65", + "0x48127f4c7fff8000", + "0x48127f957fff8000", + "0x48127f957fff8000", + "0x480680017fff8000", + "0x1", + "0x48127f957fff8000", + "0x48127f957fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0xae", + "0x48127f4c7fff8000", + "0x48127f4c7fff8000", + "0x48127f4c7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127f4c7fff8000", + "0x48127f4c7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x1104800180018000", + "0xb0", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xce", + "0x40780017fff7fff", + "0x1", + "0x40780017fff7fff", + "0x1", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x1104800180018000", + "0xc5", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x480680017fff8000", + "0x456d69744576656e74", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400280027ffb7ffb", + "0x400280037ffb7ffc", + "0x400280047ffb7ffd", + "0x400280057ffb7ffe", + "0x480280077ffb8000", + "0x20680017fff7fff", + "0xd", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0xa", + "0x480680017fff8000", + "0x1", + "0x480280087ffb8000", + "0x480280097ffb8000", + "0x1104800180018000", + "0xc6", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x1104800180018000", + "0xb9", + "0x20680017fff7ffc", + "0x1a", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xee", + "0x20680017fff7ffd", + "0xb", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x8", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff27fff8000", + "0x48127ff27fff8000", + "0x208b7fff7fff7ffe", + "0x482a7ffd7ffc8001", + "0xa0680017fff7fff", + "0x7", + "0x4824800180007fff", + "0x100000000000000000000000000000000", + "0x400280007ffb7fff", + "0x10780017fff7fff", + "0xc", + "0x400280007ffb7fff", + "0x40780017fff7fff", + "0x1", + "0x482680017ffb8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x10780017fff7fff", + "0x7", + "0x482680017ffb8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x753132385f616464204f766572666c6f77", + "0x1104800180018000", + "0xc3", + "0x20680017fff7ffd", + "0x9", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x480680017fff8000", + "0x53746f726167655772697465", + "0x400280007ffc7fff", + "0x400380017ffc7ffb", + "0x400280027ffc7ffd", + "0x400280037ffc7ffe", + "0x400380047ffc7ffd", + "0x480280067ffc8000", + "0x20680017fff7fff", + "0xd", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x7", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x9", + "0x480680017fff8000", + "0x1", + "0x480280077ffc8000", + "0x480280087ffc8000", + "0x1104800180018000", + "0x3b", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ff8", + "0x13", + "0x480680017fff8000", + "0x477e157efde59c5531277ede78acb3e03ef69508c6c35fde3495aa0671d227", + "0x400280007ffb7fff", + "0x480a7ff97fff8000", + "0x480a7ffa7fff8000", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x83", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x10780017fff7fff", + "0x12", + "0x40780017fff7fff", + "0xf", + "0x480680017fff8000", + "0x1d3bd105efd11cb4e1d188c3f2b302935b4db511160389bd8b0a936ce967708", + "0x400280007ffb7fff", + "0x480a7ffa7fff8000", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x7b", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x53746f7261676552656164", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400380027ffb7ffc", + "0x400380037ffb7ffd", + "0x480280057ffb8000", + "0x20680017fff7fff", + "0x28", + "0x480a7ff97fff8000", + "0x480280067ffb8000", + "0x1104800180018000", + "0x60", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x7", + "0x20680017fff7ffc", + "0xf", + "0x40780017fff7fff", + "0x2", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x53746f7261676541636365737355313238202d206e6f6e2075313238", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ff97fff8000", + "0x482480017ff88000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x11", + "0x480a7ff97fff8000", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x480280067ffb8000", + "0x480280077ffb8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0xa", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x400180007fff7ffd", + "0x480680017fff8000", + "0x1", + "0x48127ffe7fff8000", + "0x482480017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ff97fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x33", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x16", + "0x480280007ffc8003", + "0x480280017ffc8003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483180017ffd7ffd", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400280027ffc7ffd", + "0x20680017fff7ffe", + "0xe", + "0x402780017fff7fff", + "0x1", + "0x400380007ffc7ffd", + "0x40780017fff7fff", + "0x5", + "0x482680017ffc8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x10780017fff7fff", + "0x8", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x5", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x101f8" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 41, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -30 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 62, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 80, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 98, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 112, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 126, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 141, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x1c48" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 176, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -11 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 196, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 214, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 232, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 246, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 472, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 474, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 496, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 583, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 0 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": -1 + } + } + } + ] + ], + [ + 635, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -4 + } + } + } + } + ] + ], + [ + 735, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 760, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 812, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 836, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 838, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 66040 <= memory[fp + -6]" + ] + ], + [ + 41, + [ + "memory[ap + 0] = 0 <= memory[ap + -30]" + ] + ], + [ + 62, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 80, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 98, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 112, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 126, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 141, + [ + "memory[ap + 0] = 7240 <= memory[fp + -6]" + ] + ], + [ + 176, + [ + "memory[ap + 0] = 0 <= memory[ap + -11]" + ] + ], + [ + 196, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 214, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 232, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 246, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 472, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 474, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 496, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 583, + [ + "memory[ap + -1] = memory[ap + 0] < 340282366920938463463374607431768211456" + ] + ], + [ + 635, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" + ] + ], + [ + 735, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 760, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 812, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 836, + [ + "memory[ap + 0] = memory[fp + -3] < 340282366920938463463374607431768211456" + ] + ], + [ + 838, + [ + "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -3], 340282366920938463463374607431768211456)" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x966af5d72d3975f70858b044c77785d3710638bbcebbd33cc7001a91025588", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "offset": 141, + "builtins": [ + "range_check" + ] + } + ] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm b/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm new file mode 100644 index 000000000..a3629918d --- /dev/null +++ b/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm @@ -0,0 +1,524 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffff43f4", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x68", + "0x4825800180007ffa", + "0xbc0c", + "0x400280007ff97fff", + "0x48297ffc80007ffd", + "0x482680017ff98000", + "0x1", + "0x4824800180007ffe", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x40", + "0x1104800180018000", + "0x118", + "0x482480017fff8000", + "0x117", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007ff4", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff47fff", + "0x10780017fff7fff", + "0x23", + "0x4824800180007ff4", + "0x0", + "0x400080007ff57fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x4b", + "0x482480017f268000", + "0x1", + "0x20680017fff7ffc", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x48127fff7fff8000", + "0x48127ffe7fff8000", + "0x1104800180018000", + "0x81", + "0x48127ff87fff8000", + "0x48127ff27fff8000", + "0x48127ff27fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff28000", + "0x1", + "0x48127fef7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x62", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff57fff8000", + "0x48127ff27fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x1104800180018000", + "0x3f", + "0x20680017fff7ffd", + "0x2f", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x2", + "0x1104800180018000", + "0x35", + "0x20680017fff7ffd", + "0x1c", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x3", + "0x1104800180018000", + "0x2b", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x42", + "0x48127fb97fff8000", + "0x48127fb97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fb97fff8000", + "0x48127fb97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x84", + "0x48127f777fff8000", + "0x48127f777fff8000", + "0x480680017fff8000", + "0x1", + "0x48127f777fff8000", + "0x48127f777fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x43", + "0x40780017fff7fff", + "0x1", + "0x40780017fff7fff", + "0x1", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x1104800180018000", + "0x3a", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x480680017fff8000", + "0x456d69744576656e74", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400280027ffb7ffb", + "0x400280037ffb7ffc", + "0x400280047ffb7ffd", + "0x400280057ffb7ffe", + "0x480280077ffb8000", + "0x20680017fff7fff", + "0xd", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0xa", + "0x480680017fff8000", + "0x1", + "0x480280087ffb8000", + "0x480280097ffb8000", + "0x1104800180018000", + "0x27", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x363b90c0b8be133a6373701cce2f678d73ec604cb810f4d8b511c6a3ea4fcfd", + "0x400280007ffb7fff", + "0x480a7ff97fff8000", + "0x480a7ffa7fff8000", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x15", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ff97fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x7", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0xbc0c" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 35, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -11 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 55, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 77, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 95, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 109, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 197, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 199, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 221, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 48140 <= memory[fp + -6]" + ] + ], + [ + 35, + [ + "memory[ap + 0] = 0 <= memory[ap + -11]" + ] + ], + [ + 55, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 77, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 95, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 109, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 197, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 199, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 221, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x2e8359222ced3eab92eabe6442847adf1c8234edbdea21c3fa8b2d5573346c4", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm b/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm new file mode 100644 index 000000000..bf0ff34ca --- /dev/null +++ b/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm @@ -0,0 +1,1097 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffff8a94", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x7e", + "0x4825800180007ffa", + "0x756c", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x111", + "0x20680017fff7ffe", + "0x65", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x42", + "0x1104800180018000", + "0x25f", + "0x482480017fff8000", + "0x25e", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fd7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fef7fff", + "0x10780017fff7fff", + "0x25", + "0x4824800180007fd7", + "0x0", + "0x400080007ff07fff", + "0x482480017ff08000", + "0x1", + "0x48127ffe7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff17fff8000", + "0x1104800180018000", + "0x11b", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0x13b", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fed8000", + "0x1", + "0x48127fd27fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x121", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff07fff8000", + "0x48127fd57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127fde7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffd346", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x79", + "0x4825800180007ffa", + "0x2cba", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x7f", + "0x20680017fff7ffe", + "0x60", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x3d", + "0x1104800180018000", + "0x1cd", + "0x482480017fff8000", + "0x1cc", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fd7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fef7fff", + "0x10780017fff7fff", + "0x20", + "0x4824800180007fd7", + "0x0", + "0x400080007ff07fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff27fff8000", + "0x1104800180018000", + "0xbe", + "0x482480017fce8000", + "0x1", + "0x20680017fff7ffc", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fed8000", + "0x1", + "0x48127fd27fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x94", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff07fff8000", + "0x48127fd57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127fde7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x17", + "0x480a7ffb7fff8000", + "0x480080007ffc8000", + "0x1104800180018000", + "0x67", + "0x20680017fff7ffe", + "0x9", + "0x48127ffd7fff8000", + "0x48127ff07fff8000", + "0x48127ff07fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffd7fff8000", + "0x48127ff07fff8000", + "0x48127ff07fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0xd", + "0x480a7ffb7fff8000", + "0x48127ff07fff8000", + "0x48127ff07fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0x6e", + "0x20680017fff7ffd", + "0x1a", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x94", + "0x20680017fff7ffd", + "0xb", + "0x48127fe27fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127fe27fff8000", + "0x208b7fff7fff7ffe", + "0x48127fe27fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x18", + "0x48127fe27fff8000", + "0x48127fe27fff8000", + "0x48127fe27fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fe27fff8000", + "0x48127fe27fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xa6", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x68", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x16", + "0x480280007ffc8003", + "0x480280017ffc8003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483180017ffd7ffd", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400280027ffc7ffd", + "0x20680017fff7ffe", + "0xe", + "0x402780017fff7fff", + "0x1", + "0x400380007ffc7ffd", + "0x40780017fff7fff", + "0x5", + "0x482680017ffc8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x10780017fff7fff", + "0x8", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x1104800180018000", + "0x5f", + "0x20680017fff7ffc", + "0x1a", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0x94", + "0x20680017fff7ffd", + "0xb", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x8", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff27fff8000", + "0x48127ff27fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x480680017fff8000", + "0x53746f726167655772697465", + "0x400280007ffc7fff", + "0x400380017ffc7ffb", + "0x400280027ffc7ffd", + "0x400280037ffc7ffe", + "0x400380047ffc7ffd", + "0x480280067ffc8000", + "0x20680017fff7fff", + "0xd", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x7", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x9", + "0x480680017fff8000", + "0x1", + "0x480280077ffc8000", + "0x480280087ffc8000", + "0x1104800180018000", + "0x62", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x53746f7261676552656164", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400380027ffb7ffc", + "0x400380037ffb7ffd", + "0x480280057ffb8000", + "0x20680017fff7fff", + "0x28", + "0x480a7ff97fff8000", + "0x480280067ffb8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff69", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x7", + "0x20680017fff7ffc", + "0xf", + "0x40780017fff7fff", + "0x2", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x53746f7261676541636365737355313238202d206e6f6e2075313238", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ff97fff8000", + "0x482480017ff88000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x11", + "0x480a7ff97fff8000", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x480280067ffb8000", + "0x480280077ffb8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x756c" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 41, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -40 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 62, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 85, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 103, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 117, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 131, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 146, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x2cba" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 187, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -40 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 208, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 226, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 244, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 258, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 272, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 415, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 417, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 510, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -4 + } + } + } + } + ] + ], + [ + 562, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 587, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 30060 <= memory[fp + -6]" + ] + ], + [ + 41, + [ + "memory[ap + 0] = 0 <= memory[ap + -40]" + ] + ], + [ + 62, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 85, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 103, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 117, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 131, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 146, + [ + "memory[ap + 0] = 11450 <= memory[fp + -6]" + ] + ], + [ + 187, + [ + "memory[ap + 0] = 0 <= memory[ap + -40]" + ] + ], + [ + 208, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 226, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 244, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 258, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 272, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 415, + [ + "memory[ap + 0] = memory[fp + -3] < 340282366920938463463374607431768211456" + ] + ], + [ + 417, + [ + "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -3], 340282366920938463463374607431768211456)" + ] + ], + [ + 510, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" + ] + ], + [ + 562, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 587, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x1b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "offset": 146, + "builtins": [ + "range_check" + ] + } + ] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm b/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm new file mode 100644 index 000000000..c4da4fc1c --- /dev/null +++ b/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm @@ -0,0 +1,755 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffc144", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x93", + "0x4825800180007ffa", + "0x3ebc", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x9b", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x7a", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x1104800180018000", + "0x93", + "0x20680017fff7ffe", + "0x66", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x43", + "0x1104800180018000", + "0x158", + "0x482480017fff8000", + "0x157", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fd6", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fe47fff", + "0x10780017fff7fff", + "0x26", + "0x4824800180007fd6", + "0x0", + "0x400080007fe57fff", + "0x482480017fe58000", + "0x1", + "0x48127ffe7fff8000", + "0x480a7ffb7fff8000", + "0x48127fe17fff8000", + "0x48127ff07fff8000", + "0x1104800180018000", + "0x8a", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xd7", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fe28000", + "0x1", + "0x48127fd17fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xbd", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fe57fff8000", + "0x48127fd47fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fee7fff8000", + "0x48127fdd7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x64", + "0x400080007ffe7fff", + "0x480a7ff97fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0x59", + "0x48127ff17fff8000", + "0x482480017ff08000", + "0x1", + "0x20680017fff7ffc", + "0x3a", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x4465706c6f79", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400280027ffb7ff9", + "0x400380037ffb7ffd", + "0x400280047ffb7ffc", + "0x400280057ffb7ffd", + "0x400280067ffb7ffe", + "0x480280087ffb8000", + "0x20680017fff7fff", + "0xc", + "0x480280077ffb8000", + "0x482680017ffb8000", + "0xc", + "0x480680017fff8000", + "0x0", + "0x480280097ffb8000", + "0x4802800a7ffb8000", + "0x4802800b7ffb8000", + "0x10780017fff7fff", + "0xb", + "0x480280077ffb8000", + "0x482680017ffb8000", + "0xb", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480280097ffb8000", + "0x4802800a7ffb8000", + "0x1104800180018000", + "0x55", + "0x20680017fff7ffc", + "0xb", + "0x48127fde7fff8000", + "0x48127fe77fff8000", + "0x48127fe77fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff87fff8000", + "0x208b7fff7fff7ffe", + "0x48127fde7fff8000", + "0x48127fe77fff8000", + "0x48127fe77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1b", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7074696f6e3a3a756e77726170206661696c65642e", + "0x400080007ffe7fff", + "0x48127fde7fff8000", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x44", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0xa0680017fff8004", + "0xe", + "0x4825800180047ffd", + "0x800000000000000000000000000000000000000000000000000000000000000", + "0x484480017ffe8000", + "0x110000000000000000", + "0x48307ffe7fff8002", + "0x480280007ffc7ffc", + "0x480280017ffc7ffc", + "0x402480017ffb7ffd", + "0xffffffffffffffeeffffffffffffffff", + "0x400280027ffc7ffd", + "0x10780017fff7fff", + "0x13", + "0x484480017fff8001", + "0x8000000000000000000000000000000", + "0x48317fff80007ffd", + "0x480280007ffc7ffd", + "0x480280017ffc7ffd", + "0x402480017ffc7ffe", + "0xf8000000000000000000000000000000", + "0x400280027ffc7ffe", + "0x40780017fff7fff", + "0x1", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x10780017fff7fff", + "0x8", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x526573756c743a3a756e77726170206661696c65642e", + "0x1104800180018000", + "0x16", + "0x20680017fff7ffc", + "0x8", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x20780017fff7ff9", + "0xa", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x400180007fff7ffd", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffd7fff8000", + "0x482480017ffc8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x3ebc" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 47, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -41 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 69, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 92, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 110, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 124, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 138, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 152, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 203, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 230, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 275, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 299, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x800000000000000000000000000000000000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 303, + [ + { + "LinearSplit": { + "value": { + "Deref": { + "register": "AP", + "offset": 3 + } + }, + "scalar": { + "Immediate": "0x110000000000000000" + }, + "max_x": { + "Immediate": "0xffffffffffffffffffffffffffffffff" + }, + "x": { + "register": "AP", + "offset": -2 + }, + "y": { + "register": "AP", + "offset": -1 + } + } + } + ] + ], + [ + 313, + [ + { + "LinearSplit": { + "value": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "scalar": { + "Immediate": "0x8000000000000000000000000000000" + }, + "max_x": { + "Immediate": "0xffffffffffffffffffffffffffffffff" + }, + "x": { + "register": "AP", + "offset": -1 + }, + "y": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 375, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 16060 <= memory[fp + -6]" + ] + ], + [ + 47, + [ + "memory[ap + 0] = 0 <= memory[ap + -41]" + ] + ], + [ + 69, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 92, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 110, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 124, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 138, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 152, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 203, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 230, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 275, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 299, + [ + "memory[ap + 4] = memory[fp + -3] < 3618502788666131106986593281521497120414687020801267626233049500247285301248" + ] + ], + [ + 303, + [ + "\n(value, scalar) = (memory[ap + 3], 313594649253062377472)\nx = min(value // scalar, 340282366920938463463374607431768211455)\ny = value - x * scalar\nmemory[ap + -2] = x\nmemory[ap + -1] = y\n" + ] + ], + [ + 313, + [ + "\n(value, scalar) = (memory[fp + -3], 10633823966279326983230456482242756608)\nx = min(value // scalar, 340282366920938463463374607431768211455)\ny = value - x * scalar\nmemory[ap + -1] = x\nmemory[ap + 0] = y\n" + ] + ], + [ + 375, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x2f459db2a642c91d279cdbe9185f3934bb1cde01b16f89896c71066cf42bb18", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm b/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm new file mode 100644 index 000000000..03cf472ff --- /dev/null +++ b/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm @@ -0,0 +1,557 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xfffffffffffffffffffffffffffff8ee", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0xa7", + "0x4825800180007ffa", + "0x712", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xaf", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x8e", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x1104800180018000", + "0xa7", + "0x20680017fff7ffe", + "0x7a", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x1104800180018000", + "0xa1", + "0x20680017fff7ffe", + "0x66", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x43", + "0x1104800180018000", + "0xfa", + "0x482480017fff8000", + "0xf9", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fc7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fd57fff", + "0x10780017fff7fff", + "0x26", + "0x4824800180007fc7", + "0x0", + "0x400080007fd67fff", + "0x482480017fd68000", + "0x1", + "0x48127ffe7fff8000", + "0x48127fd37fff8000", + "0x48127fe27fff8000", + "0x48127ff07fff8000", + "0x1104800180018000", + "0x98", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xd3", + "0x48127ff37fff8000", + "0x48127ff37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fd38000", + "0x1", + "0x48127fc27fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xb6", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fd67fff8000", + "0x48127fc57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fdf7fff8000", + "0x48127fce7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fee7fff8000", + "0x48127fdd7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x4b", + "0x482480017fff8000", + "0x4a", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4825800180007ffa", + "0xa0a", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x2a", + "0x4825800180007ffa", + "0xa0a", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x20780017fff7ffd", + "0x7", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480a7ffb7fff8000", + "0x10780017fff7fff", + "0xf", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480a7ffc7fff8000", + "0x482a7ffc7ffb8000", + "0x4825800180007ffd", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe1", + "0x20680017fff7ffd", + "0xd", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x482480017ffa8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x712" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 53, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -56 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 75, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 98, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 116, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 130, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 144, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 158, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 172, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 228, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0xa0a" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 277, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 1810 <= memory[fp + -6]" + ] + ], + [ + 53, + [ + "memory[ap + 0] = 0 <= memory[ap + -56]" + ] + ], + [ + 75, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 98, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 116, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 130, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 144, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 158, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 172, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 228, + [ + "memory[ap + 0] = 2570 <= memory[fp + -6]" + ] + ], + [ + 277, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x112e35f48499939272000bd72eb840e502ca4c3aefa8800992e8defb746e0c9", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm b/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm new file mode 100644 index 000000000..c2420dff1 --- /dev/null +++ b/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm @@ -0,0 +1,476 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0x100000000000000000000000000000000", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x7d", + "0x4825800180007ffa", + "0x0", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x85", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x64", + "0x48307ffb80007ffc", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x41", + "0x1104800180018000", + "0xdb", + "0x482480017fff8000", + "0xda", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fe5", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff37fff", + "0x10780017fff7fff", + "0x24", + "0x4824800180007fe5", + "0x0", + "0x400080007ff47fff", + "0x482480017ff48000", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff17fff8000", + "0x1104800180018000", + "0x7c", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xb6", + "0x48127ff37fff8000", + "0x48127ff37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff18000", + "0x1", + "0x48127fe07fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x99", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff47fff8000", + "0x48127fe37fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x4a", + "0x482480017fff8000", + "0x49", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4825800180007ffc", + "0x942", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400280007ffb7fff", + "0x10780017fff7fff", + "0x29", + "0x4825800180007ffc", + "0x942", + "0x400280007ffb7fff", + "0x482680017ffb8000", + "0x1", + "0x20780017fff7ffd", + "0x8", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x10780017fff7fff", + "0xd", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x4825800180007ffd", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe2", + "0x20680017fff7ffd", + "0xd", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48527ffd7ffd8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x482480017ffa8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 41, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -26 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 61, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 84, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 102, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 116, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 130, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 186, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x942" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -4 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 234, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 0 <= memory[fp + -6]" + ] + ], + [ + 41, + [ + "memory[ap + 0] = 0 <= memory[ap + -26]" + ] + ], + [ + 61, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 84, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 102, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 116, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 130, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 186, + [ + "memory[ap + 0] = 2370 <= memory[fp + -4]" + ] + ], + [ + 234, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x36fbc999025b89d36d31dc2f9c0a03b4377755e1f27e0e42a385aaba90f61a6", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/fibonacci.sierra b/starknet_programs/raw_contract_classes/fibonacci.sierra new file mode 100644 index 000000000..8cd932a4e --- /dev/null +++ b/starknet_programs/raw_contract_classes/fibonacci.sierra @@ -0,0 +1,373 @@ +{ + "sierra_program": [ + "0x1", + "0x2", + "0x0", + "0x2", + "0x0", + "0x0", + "0xd5", + "0x2b", + "0x16", + "0x52616e6765436865636b", + "0x0", + "0x4761734275696c74696e", + "0x66656c74323532", + "0x4172726179", + "0x1", + "0x2", + "0x536e617073686f74", + "0x3", + "0x537472756374", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x4", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x456e756d", + "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", + "0x6", + "0x753332", + "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", + "0x4275696c74696e436f737473", + "0x17bc4bcbb517b92736828af382c42b71df97fe5d0a8db42d13069b34a1ddbe9", + "0x14de46c93830b854d231d540339ee8ae16bb18830a375fe81572a472d5945f1", + "0xd", + "0x2f528e3c691e195fca674982b69c0dc4284f206c3ea4d680220e99b59315a92", + "0xc", + "0xe", + "0x5", + "0x19b3b4955bdcfa379bfc5a4949111c4efdd79128f8676f4d0895419b22e2ad7", + "0x10", + "0x53797374656d", + "0x426f78", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x13", + "0x4e6f6e5a65726f", + "0x50", + "0x7265766f6b655f61705f747261636b696e67", + "0x656e61626c655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x73746f72655f74656d70", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x7", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x8", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x7533325f6571", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x9", + "0x6a756d70", + "0x626f6f6c5f6e6f745f696d706c", + "0x6765745f6275696c74696e5f636f737473", + "0xa", + "0x77697468647261775f6761735f616c6c", + "0x64697361626c655f61705f747261636b696e67", + "0xb", + "0xf", + "0x61727261795f6e6577", + "0x11", + "0x12", + "0x66656c743235325f636f6e7374", + "0x4f7574206f6620676173", + "0x61727261795f617070656e64", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x14", + "0x756e626f78", + "0x647570", + "0x66656c743235325f69735f7a65726f", + "0x15", + "0x66656c743235325f616464", + "0x66656c743235325f737562", + "0x122", + "0xffffffffffffffff", + "0xad", + "0x9d", + "0x8c", + "0x7a", + "0x17", + "0x18", + "0x19", + "0x1a", + "0x1b", + "0x1c", + "0x1d", + "0x1e", + "0x1f", + "0x21", + "0x20", + "0x22", + "0x25", + "0x23", + "0x24", + "0x26", + "0x65", + "0x27", + "0x28", + "0x29", + "0x2a", + "0x54", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x2f", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x30", + "0x31", + "0x32", + "0x39", + "0x4d", + "0x3a", + "0x3b", + "0x3c", + "0x3d", + "0x3e", + "0x41", + "0x42", + "0x3f", + "0x40", + "0x43", + "0x44", + "0x45", + "0x46", + "0x47", + "0x48", + "0x49", + "0x4a", + "0x4b", + "0x4c", + "0x4e", + "0x4f", + "0x51", + "0x52", + "0x53", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5d", + "0x5b", + "0x5c", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x62", + "0x63", + "0x64", + "0x66", + "0x67", + "0x68", + "0x69", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x70", + "0x71", + "0x72", + "0x73", + "0x74", + "0x75", + "0x76", + "0x77", + "0x78", + "0x79", + "0x7b", + "0x7c", + "0x7d", + "0x7e", + "0x7f", + "0x80", + "0x81", + "0x82", + "0x83", + "0x84", + "0x85", + "0x86", + "0x87", + "0x88", + "0x89", + "0x8a", + "0x8b", + "0x8d", + "0x8e", + "0x8f", + "0xc3", + "0xc8", + "0xd2", + "0x108", + "0xe9", + "0xfc", + "0x102", + "0xbc", + "0xd9", + "0x118", + "0x11e", + "0xa93", + "0x7060f02090e0d02060a0c060b02070a090606080706060502040203020100", + "0x2090a1502060a07060d02070a1402060a0213100610061202090e02111006", + "0x61e021d19061c061b02090e1a060d02070a190618061702090e090616060d", + "0x60906281a06062702260225022402232207060621100620061f02090e0706", + "0x60631020706302e06062f2e06062d0706062c1a06062b2a06062902060627", + "0x2370607350607340236350606270207350607341006063302322e0606272e", + "0x273c06062f3c06062d3c060633023b023a3906062702381006062f35060629", + "0x706062d0706063e1806062b3d06062907090628070606273c060627060606", + "0x607341c0606331a0606330906062f0906062d09090628090606270706062f", + "0x63316060633070606434207064106073f0607343f0606274006062702073f", + "0x6062702074706073407060646450706411a06062f440706410c0906281906", + "0x62702072a060734070606310706064847060629060747060734470606270c", + "0x3418060633024d06070641024c4b06062f024a0706064906072a0607342a06", + "0x4f06020602024f060202024e1006062706073d0607343d06062702073d0607", + "0x1a0239064f0609060c02024f060209022a1007501a0c074f07060207070202", + "0x4f060209021806513c064f0735062a020c064f060c061002352e074f063906", + "0x9023f06521c064f0719062a021916074f063d061a023d064f062e060c0202", + "0x6534b064f0720062a022040074f0647061a0247064f0616060c02024f0602", + "0x56074f065506390255064f065406350254064f0640062e02024f0602090200", + "0x24f0659063c025a59074f065806390258064f06021802024f0656063c0257", + "0x4f075c5b073d025b064f065b0619025c064f065a0616025b064f0657061602", + "0x64f065d0640025d064f065e063f025e064f06021c02024f06020902025d02", + "0x6400262064f066106470261064f06021c02024f060209020260060220025f", + "0x66463064f076006000260064f066006400260064f065f064b025f064f0662", + "0x570266064f066606560266064f06025502024f0663065402024f0602090265", + "0x64f06025902024f06025802024f060209026b6a07696867074f07661a0c09", + "0x4f0668065c026f064f0667061002024f066d065b026e6d074f066c065a026c", + "0x64b065d0273064f061c065d0272064f063c065d0271064f066e065e027006", + "0x9027a067978064f0777066102777675094f0674737271706f105f0274064f", + "0x665027e7d074f067b0663027c064f060260027b064f0678066202024f0602", + "0x28281074f06807f07670280064f067c0666027f064f067e065d02024f067d", + "0x285064f0684066b02024f0683066a028483074f0681066802024f06820654", + "0x89064f0676065c0288064f067506100287064f0686066d0286064f0685066c", + "0x67602024f060209028b8a89880c068b064f06870675028a064f0607066e02", + "0x75028e064f0607066e028d064f0676065c0279064f06750610028c064f067a", + "0x24f064b066502024f06025802024f06020902228e8d790c0622064f068c06", + "0x65d0290064f060277028f064f06026002024f063c066502024f061c066502", + "0x292064f06916907710269064f0602700291064f06908f076f0290064f0690", + "0x96064f0607066e0295064f066b065c0294064f066a06100293064f06920676", + "0x665065402024f06025802024f06020902979695940c0697064f0693067502", + "0x98064f0607066e02024f063c066502024f061c066502024f064b066502024f", + "0x29c064f060273029b064f06026002024f069a0654029a99074f0698067202", + "0x64f069d9e0771029e064f060270029d064f069c9b076f029c064f069c065d", + "0x4f0699066e0264064f061a065c02a1064f060c061002a0064f069f0676029f", + "0x65402024f06025802024f06020902a3a264a10c06a3064f06a0067502a206", + "0x64f06026002024f063c066502024f061c066502024f0640067402024f0600", + "0x64f06027002a6064f06a5a4076f02a5064f06a5065d02a5064f06027802a4", + "0x61a065c02aa064f060c061002a9064f06a8067602a8064f06a6a7077102a7", + "0x24f06020902adacabaa0c06ad064f06a9067502ac064f0607066e02ab064f", + "0x6026002024f063c066502024f0616067402024f063f065402024f06025802", + "0x6027002b0064f06afae076f02af064f06af065d02af064f06027802ae064f", + "0x65c02b4064f060c061002b3064f06b2067602b2064f06b0b1077102b1064f", + "0x6020902b653b5b40c06b6064f06b306750253064f0607066e02b5064f061a", + "0x7802b7064f06026002024f062e067402024f0618065402024f06025802024f", + "0x7102ba064f06027002b9064f06b8b7076f02b8064f06b8065d02b8064f0602", + "0xbe064f061a065c02bd064f060c061002bc064f06bb067602bb064f06b9ba07", + "0x25802024f06020902c0bfbebd0c06c0064f06bc067502bf064f0607066e02", + "0x64f06c2065d02c2064f06027702c1064f06026002024f0609067402024f06", + "0x6c5067602c5064f06c3c4077102c4064f06027002c3064f06c2c1076f02c2", + "0xc6067502c8064f0607066e02c7064f062a065c0252064f0610061002c6064f", + "0x20c06ca0907074f0706067a0206064f0602062e02c9c8c7520c06c9064f06", + "0x20022a064f061a067d0210064f0607067c021a064f0609067b02024f060209", + "0x4f060c067c0235064f062e067e022e064f06021c02024f0602090202cb0602", + "0x72a06810239064f0639060c0239064f0610066b022a064f0635067d021006", + "0x6800219064f0616067f0216064f063c068202024f060209021806cc3c064f", + "0x24f060209023f1c07063f064f063d0683021c064f0639060c023d064f0619", + "0x247064f0639060c0220064f064006840240064f06021c02024f0618065402", + "0x64f061006560210064f06025502024f060258024b4707064b064f06200683", + "0x3c1a074f061a068502024f06020902393507cd2e2a074f0710060209570210", + "0x24f061a066502024f060209021806ce024f073c0686022a064f062a061002", + "0x219064f062e065c0216064f062a061002024f0607065b02024f060c066502", + "0x60c068502024f0618068702024f0602090202cf060220023d064f0609065d", + "0x100220064f06401a078a0240064f060289021c064f063f090788023f0c074f", + "0x257064f060c065d0256064f0607065e0255064f062e065c0254064f062a06", + "0x2004b47094f06595857565554105f0259064f0620065d0258064f061c065d", + "0x64f06470610025c064f065a066202024f060209025b06d05a064f07000661", + "0x4f065e068c025e064f063d068b023d064f065c065d0219064f064b065c0216", + "0x62615f090662064f065d06790261064f0619065c025f064f06160610025d06", + "0x265064f064b065c0263064f064706100260064f065b068d02024f06020902", + "0x4f0607065b02024f060c066502024f06020902666563090666064f06600679", + "0x5d0268064f0602770267064f06026002024f061a066502024f060906650202", + "0x6c064f066a6b0771026b064f060270026a064f066867076f0268064f066806", + "0x64f066d06790275064f0639065c026e064f06350610026d064f066c068d02", + "0x20c064f06021c0209064f060706076f0207064f0602067f0276756e090676", + "0x602066e0206064f06021c02101a070610064f060c068e021a064f06090666", + "0x2090706023f4006020c1a4006020c1a0907070609064f0606068e0207064f", + "0x100907090707d21a0c090706023d0602090707073c060210d1022a1a071a06", + "0xd4021040074006d30602" + ], + "sierra_program_debug_info": { + "type_names": [], + "libfunc_names": [], + "user_func_names": [] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x112e35f48499939272000bd72eb840e502ca4c3aefa8800992e8defb746e0c9", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + }, + "abi": [ + { + "type": "impl", + "name": "Fibonacci", + "interface_name": "fibonacci::fibonacci::IFibonacci" + }, + { + "type": "interface", + "name": "fibonacci::fibonacci::IFibonacci", + "items": [ + { + "type": "function", + "name": "fib", + "inputs": [ + { + "name": "a", + "type": "core::felt252" + }, + { + "name": "b", + "type": "core::felt252" + }, + { + "name": "n", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "fibonacci::fibonacci::Fibonacci::Event", + "kind": "enum", + "variants": [] + } + ] +} \ No newline at end of file diff --git a/tests/account_panic.rs b/tests/account_panic.rs new file mode 100644 index 000000000..195b21d9f --- /dev/null +++ b/tests/account_panic.rs @@ -0,0 +1,117 @@ +use std::sync::Arc; + +use cairo_vm::felt::Felt252; +use starknet_in_rust::{ + core::contract_address::compute_casm_class_hash, + definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, + services::api::contract_classes::compiled_class::CompiledClass, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + }, + transaction::{InvokeFunction, Transaction}, + utils::{calculate_sn_keccak, Address}, + CasmContractClass, +}; + +#[test] +fn account_panic() { + let account_data = include_bytes!("../starknet_programs/cairo2/account_panic.casm"); + let contract_data = include_bytes!("../starknet_programs/cairo2/contract_a.casm"); + + let account_contract_class: CasmContractClass = serde_json::from_slice(account_data).unwrap(); + let account_class_hash = compute_casm_class_hash(&account_contract_class) + .unwrap() + .to_be_bytes(); + + let contract_class: CasmContractClass = serde_json::from_slice(contract_data).unwrap(); + let contract_class_hash_felt = compute_casm_class_hash(&contract_class).unwrap(); + let contract_class_hash = contract_class_hash_felt.to_be_bytes(); + + let account_address = Address(1111.into()); + let contract_address = Address(0000.into()); + let nonce = 0.into(); + + let block_context = BlockContext::default(); + + let contract_class_cache = PermanentContractClassCache::default(); + + contract_class_cache.set_contract_class( + account_class_hash, + CompiledClass::Casm(Arc::new(account_contract_class)), + ); + contract_class_cache.set_contract_class( + contract_class_hash, + CompiledClass::Casm(Arc::new(contract_class.clone())), + ); + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(account_address.clone(), account_class_hash); + state_reader + .address_to_nonce_mut() + .insert(account_address.clone(), nonce); + state_reader + .address_to_class_hash_mut() + .insert(contract_address.clone(), contract_class_hash); + state_reader + .address_to_nonce_mut() + .insert(contract_address, 1.into()); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"__execute__")); + + // arguments of contract_a contract + // calldata is a Vec of Call, which is + /* + #[derive(Drop, Serde)] + struct Call { + to: ContractAddress, + selector: felt252, + calldata: Array + } + */ + let selector_contract = &contract_class + .entry_points_by_type + .external + .get(0) + .unwrap() + .selector; + // calldata of contract_a is 1 value. + let calldata: Vec<_> = [ + 1.into(), + contract_class_hash_felt, + selector_contract.into(), + 1.into(), + 2.into(), + ] + .to_vec(); + + // set up remaining structures + + let invoke = InvokeFunction::new( + account_address, + Felt252::new(selector), + 0, + TRANSACTION_VERSION.clone(), + calldata, + vec![], + block_context.starknet_os_config().chain_id().clone(), + Some(0.into()), + ) + .unwrap(); + + let tx = Transaction::InvokeFunction(invoke); + let exec_info = tx + .execute(&mut state, &block_context, u128::MAX) + .expect("failed to invoke"); + let call_info = exec_info.call_info.as_ref().unwrap(); + + assert_eq!(exec_info.revert_error, None); + + // 482670963043u128 == 'panic' + assert_eq!(call_info.retdata[0], 482670963043u128.into()); + assert!(call_info.failure_flag); +} diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index e4b542843..c43af7bb6 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -5,6 +5,8 @@ use cairo_vm::{ }; use num_bigint::BigUint; use num_traits::{Num, One, Zero}; +use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +use starknet_in_rust::utils::calculate_sn_keccak; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ @@ -276,7 +278,7 @@ fn library_call() { let mut resources_manager = ExecutionResourcesManager::default(); let expected_execution_resources = ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 255, + n_steps: 247, #[cfg(feature = "cairo_1_tests")] n_steps: 259, n_memory_holes: 8, @@ -284,7 +286,7 @@ fn library_call() { }; let expected_execution_resources_internal_call = ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 84, + n_steps: 80, #[cfg(feature = "cairo_1_tests")] n_steps: 85, n_memory_holes: 5, @@ -300,7 +302,7 @@ fn library_call() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [5.into()].to_vec(), - execution_resources: expected_execution_resources, + execution_resources: Some(expected_execution_resources), class_hash: Some(class_hash), internal_calls: vec![CallInfo { caller_address: Address(0.into()), @@ -316,7 +318,7 @@ fn library_call() { entry_point_type: Some(EntryPointType::External), calldata: vec![25.into()], retdata: [5.into()].to_vec(), - execution_resources: expected_execution_resources_internal_call, + execution_resources: Some(expected_execution_resources_internal_call), class_hash: Some(lib_class_hash), gas_consumed: 0, ..Default::default() @@ -327,13 +329,13 @@ fn library_call() { storage_read_values: vec![], accessed_storage_keys: HashSet::new(), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 78650, + gas_consumed: 78250, #[cfg(feature = "cairo_1_tests")] gas_consumed: 78980, ..Default::default() }; - assert_eq!( + assert_eq_sorted!( exec_entry_point .execute( &mut state, @@ -359,9 +361,10 @@ fn call_contract_storage_write_read() { let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let entrypoints = contract_class.clone().entry_points_by_type; - let get_balance_entrypoint_selector = &entrypoints.external.get(1).unwrap().selector; - let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("increase_balance".as_bytes())); // Create state reader with class hash data let contract_class_cache = PermanentContractClassCache::default(); @@ -742,6 +745,7 @@ fn deploy_cairo1_from_cairo1() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -842,6 +846,7 @@ fn deploy_cairo0_from_cairo1_without_constructor() { let ret_class_hash = state.get_class_hash_at(&ret_address).unwrap(); let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), + CompiledClass::Sierra(_) => unreachable!(), CompiledClass::Casm(_) => unreachable!(), }; @@ -943,6 +948,7 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), CompiledClass::Casm(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1045,6 +1051,7 @@ fn deploy_cairo0_and_invoke() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), CompiledClass::Casm(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1156,8 +1163,18 @@ fn test_send_message_to_l1_syscall() { payload: vec![555.into(), 666.into()], }]; + #[cfg(not(feature = "cairo_1_tests"))] + let expected_n_steps = 46; + #[cfg(feature = "cairo_1_tests")] + let expected_n_steps = 50; + + #[cfg(not(feature = "cairo_1_tests"))] + let expected_gas_consumed = 9640; + #[cfg(feature = "cairo_1_tests")] + let expected_gas_consumed = 10040; + let expected_execution_resources = ExecutionResources { - n_steps: 50, + n_steps: expected_n_steps, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 2)]), }; @@ -1170,8 +1187,8 @@ fn test_send_message_to_l1_syscall() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), l2_to_l1_messages, - execution_resources: expected_execution_resources, - gas_consumed: 10040, + execution_resources: Some(expected_execution_resources), + gas_consumed: expected_gas_consumed, ..Default::default() }; @@ -1251,8 +1268,18 @@ fn test_get_execution_info() { address.0.clone(), ]; + #[cfg(not(feature = "cairo_1_tests"))] + let expected_n_steps = 213; + #[cfg(feature = "cairo_1_tests")] + let expected_n_steps = 268; + + #[cfg(not(feature = "cairo_1_tests"))] + let expected_gas_consumed = 22980; + #[cfg(feature = "cairo_1_tests")] + let expected_gas_consumed = 28580; + let expected_execution_resources = ExecutionResources { - n_steps: 268, + n_steps: expected_n_steps, n_memory_holes: 4, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 4)]), }; @@ -1265,8 +1292,8 @@ fn test_get_execution_info() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), retdata: expected_ret_data, - execution_resources: expected_execution_resources, - gas_consumed: 28580, + execution_resources: Some(expected_execution_resources), + gas_consumed: expected_gas_consumed, ..Default::default() }; @@ -3044,3 +3071,539 @@ fn keccak_syscall() { assert_eq!(retdata[0], Felt252::one()); } + +#[test] +fn library_call_recursive_50_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/square_root_recursive.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/square_root_recursive.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let entrypoints = contract_class.clone().entry_points_by_type; + let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add lib contract to the state + + #[cfg(not(feature = "cairo_1_tests"))] + let lib_program_data = include_bytes!("../starknet_programs/cairo2/math_lib.casm"); + #[cfg(feature = "cairo_1_tests")] + let lib_program_data = include_bytes!("../starknet_programs/cairo1/math_lib.casm"); + + let lib_contract_class: CasmContractClass = serde_json::from_slice(lib_program_data).unwrap(); + + let lib_address = Address(1112.into()); + let lib_class_hash: ClassHash = [2; 32]; + let lib_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + lib_class_hash, + CompiledClass::Casm(Arc::new(lib_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(lib_address.clone(), lib_class_hash); + state_reader + .address_to_nonce_mut() + .insert(lib_address, lib_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + // Create an execution entry point + let calldata = [ + felt_str!("1125899906842624"), + Felt252::from_bytes_be(&lib_class_hash), + Felt252::from(50), + ] + .to_vec(); + let caller_address = Address(0000.into()); + let entry_point_type = EntryPointType::External; + + let exec_entry_point = ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(entrypoint_selector.clone()), + caller_address, + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u128::MAX, + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + let expected_execution_resources_internal_call = ExecutionResources { + #[cfg(not(feature = "cairo_1_tests"))] + n_steps: 80, + #[cfg(feature = "cairo_1_tests")] + n_steps: 85, + n_memory_holes: 5, + builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 7)]), + }; + + let call_info = exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + + assert_eq!(call_info.internal_calls.len(), 50); + assert_eq!( + call_info.internal_calls[0], + CallInfo { + caller_address: Address(0.into()), + call_type: Some(CallType::Delegate), + contract_address: Address(1111.into()), + entry_point_selector: Some( + Felt252::from_str_radix( + "544923964202674311881044083303061611121949089655923191939299897061511784662", + 10, + ) + .unwrap(), + ), + entry_point_type: Some(EntryPointType::External), + calldata: vec![felt_str!("1125899906842624")], + retdata: [felt_str!("33554432")].to_vec(), + execution_resources: Some(expected_execution_resources_internal_call), + class_hash: Some(lib_class_hash), + gas_consumed: 0, + ..Default::default() + } + ); + assert_eq!(call_info.retdata, [1.into()].to_vec()); + assert!(!call_info.failure_flag); +} + +#[test] +fn call_contract_storage_write_read_recursive_50_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( + "increase_balance_recursive".as_bytes(), + )); + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add simple_wallet contract to the state + #[cfg(not(feature = "cairo_1_tests"))] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); + #[cfg(feature = "cairo_1_tests")] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); + + let simple_wallet_contract_class: CasmContractClass = + serde_json::from_slice(simple_wallet_program_data).unwrap(); + let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class + .entry_points_by_type + .constructor + .get(0) + .unwrap() + .selector + .clone(); + + let simple_wallet_address = Address(1112.into()); + let simple_wallet_class_hash: ClassHash = [2; 32]; + let simple_wallet_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(simple_wallet_address.clone(), simple_wallet_class_hash); + state_reader + .address_to_nonce_mut() + .insert(simple_wallet_address.clone(), simple_wallet_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + + let mut resources_manager = ExecutionResourcesManager::default(); + + let create_execute_extrypoint = |selector: &BigUint, + calldata: Vec, + entry_point_type: EntryPointType, + class_hash: [u8; 32], + address: Address| + -> ExecutionEntryPoint { + ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(selector.clone()), + Address(0000.into()), + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u64::MAX.into(), + ) + }; + + // RUN SIMPLE_WALLET CONSTRUCTOR + // Create an execution entry point + let calldata = [25.into()].to_vec(); + let constructor_exec_entry_point = create_execute_extrypoint( + &simple_wallet_constructor_entrypoint_selector, + calldata, + EntryPointType::Constructor, + simple_wallet_class_hash, + simple_wallet_address.clone(), + ); + + // Run constructor entrypoint + constructor_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0.clone()].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); + + // RUN INCREASE_BALANCE + // Create an execution entry point + let calldata = [50.into(), simple_wallet_address.0.clone()].to_vec(); + let increase_balance_entry_point = create_execute_extrypoint( + increase_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run increase_balance entrypoint + let call_info = increase_balance_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + // Check that the recursive function did in fact call the simple_wallet contract 50 times + assert_eq!(call_info.internal_calls.len(), 50); + assert!(!call_info.failure_flag); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address, + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [75.into()]) +} + +#[test] +fn call_contract_storage_write_read_recursive_100_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( + "increase_balance_recursive".as_bytes(), + )); + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add simple_wallet contract to the state + #[cfg(not(feature = "cairo_1_tests"))] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); + #[cfg(feature = "cairo_1_tests")] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); + + let simple_wallet_contract_class: CasmContractClass = + serde_json::from_slice(simple_wallet_program_data).unwrap(); + let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class + .entry_points_by_type + .constructor + .get(0) + .unwrap() + .selector + .clone(); + + let simple_wallet_address = Address(1112.into()); + let simple_wallet_class_hash: ClassHash = [2; 32]; + let simple_wallet_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(simple_wallet_address.clone(), simple_wallet_class_hash); + state_reader + .address_to_nonce_mut() + .insert(simple_wallet_address.clone(), simple_wallet_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + + let mut resources_manager = ExecutionResourcesManager::default(); + + let create_execute_extrypoint = |selector: &BigUint, + calldata: Vec, + entry_point_type: EntryPointType, + class_hash: [u8; 32], + address: Address| + -> ExecutionEntryPoint { + ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(selector.clone()), + Address(0000.into()), + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u64::MAX.into(), + ) + }; + + // RUN SIMPLE_WALLET CONSTRUCTOR + // Create an execution entry point + let calldata = [25.into()].to_vec(); + let constructor_exec_entry_point = create_execute_extrypoint( + &simple_wallet_constructor_entrypoint_selector, + calldata, + EntryPointType::Constructor, + simple_wallet_class_hash, + simple_wallet_address.clone(), + ); + + // Run constructor entrypoint + constructor_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0.clone()].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); + + // RUN INCREASE_BALANCE + // Create an execution entry point + let calldata = [100.into(), simple_wallet_address.0.clone()].to_vec(); + let increase_balance_entry_point = create_execute_extrypoint( + increase_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run increase_balance entrypoint + let call_info = increase_balance_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + // Check that the recursive function did in fact call the simple_wallet contract 50 times + assert_eq!(call_info.internal_calls.len(), 100); + assert!(!call_info.failure_flag); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address, + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) +} diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs new file mode 100644 index 000000000..dfa10b1de --- /dev/null +++ b/tests/cairo_native.rs @@ -0,0 +1,1001 @@ +#![cfg(all(feature = "cairo-native", not(feature = "cairo_1_tests")))] + +use crate::CallType::Call; +use cairo_lang_starknet::casm_contract_class::CasmContractEntryPoints; +use cairo_lang_starknet::contract_class::ContractEntryPoints; +use cairo_vm::felt::Felt252; +use num_bigint::BigUint; +use num_traits::One; +use num_traits::Zero; +use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +use starknet_in_rust::definitions::block_context::BlockContext; +use starknet_in_rust::execution::{Event, OrderedEvent}; +use starknet_in_rust::hash_utils::calculate_contract_address; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; +use starknet_in_rust::state::contract_class_cache::ContractClassCache; +use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; +use starknet_in_rust::CasmContractClass; +use starknet_in_rust::EntryPointType::{self, External}; +use starknet_in_rust::{ + definitions::constants::TRANSACTION_VERSION, + execution::{ + execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, + }, + state::cached_state::CachedState, + state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + utils::{Address, ClassHash}, +}; + +use std::collections::HashSet; +use std::sync::Arc; + +#[test] +fn integration_test_erc20() { + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/erc20.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + let casm_data = include_bytes!("../starknet_programs/cairo2/erc20.casm"); + let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + let native_entrypoints = sierra_contract_class.clone().entry_points_by_type; + let native_constructor_selector = &native_entrypoints.constructor.get(0).unwrap().selector; + + let casm_entrypoints = casm_contract_class.clone().entry_points_by_type; + let casm_constructor_selector = &casm_entrypoints.constructor.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + static NATIVE_CLASS_HASH: ClassHash = [1; 32]; + static CASM_CLASS_HASH: ClassHash = [2; 32]; + + let caller_address = Address(123456789.into()); + + contract_class_cache.set_contract_class( + NATIVE_CLASS_HASH, + CompiledClass::Sierra(Arc::new(sierra_contract_class)), + ); + contract_class_cache.set_contract_class( + CASM_CLASS_HASH, + CompiledClass::Casm(Arc::new(casm_contract_class)), + ); + let mut state_reader = InMemoryStateReader::default(); + let nonce = Felt252::zero(); + + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), CASM_CLASS_HASH); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let state_reader = Arc::new(state_reader); + let mut state_vm = + CachedState::new(state_reader.clone(), Arc::new(contract_class_cache.clone())); + let mut state_native = CachedState::new(state_reader, Arc::new(contract_class_cache)); + + /* + 1 recipient + 2 name + 3 decimals + 4 initial_supply + 5 symbol + */ + let calldata = [ + caller_address.0.clone(), + 2.into(), + 3.into(), + 4.into(), + 5.into(), + ] + .to_vec(); + + let vm_result = execute( + &mut state_vm, + &caller_address, + &caller_address, + casm_constructor_selector, + &calldata, + EntryPointType::Constructor, + &CASM_CLASS_HASH, + ); + + let native_result = execute( + &mut state_native, + &caller_address, + &caller_address, + native_constructor_selector, + &calldata, + EntryPointType::Constructor, + &NATIVE_CLASS_HASH, + ); + + assert_eq!(vm_result.caller_address, caller_address); + assert_eq!(vm_result.call_type, Some(CallType::Delegate)); + assert_eq!(vm_result.contract_address, caller_address); + assert_eq!( + vm_result.entry_point_selector, + Some(Felt252::new(casm_constructor_selector)) + ); + assert_eq!( + vm_result.entry_point_type, + Some(EntryPointType::Constructor) + ); + assert_eq!(vm_result.calldata, calldata); + assert!(!vm_result.failure_flag); + assert_eq!(vm_result.retdata, [].to_vec()); + assert_eq!(vm_result.class_hash, Some(CASM_CLASS_HASH)); + + assert_eq!(native_result.caller_address, caller_address); + assert_eq!(native_result.call_type, Some(CallType::Delegate)); + assert_eq!(native_result.contract_address, caller_address); + assert_eq!( + native_result.entry_point_selector, + Some(Felt252::new(native_constructor_selector)) + ); + assert_eq!( + native_result.entry_point_type, + Some(EntryPointType::Constructor) + ); + assert_eq!(native_result.calldata, calldata); + assert!(!native_result.failure_flag); + assert_eq!(native_result.retdata, [].to_vec()); + assert_eq!(native_result.execution_resources, None); + assert_eq!(native_result.class_hash, Some(NATIVE_CLASS_HASH)); + + assert_eq!(vm_result.events, native_result.events); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); + assert_eq!(vm_result.gas_consumed, native_result.gas_consumed); + + #[allow(clippy::too_many_arguments)] + fn compare_results( + state_vm: &mut CachedState, + state_native: &mut CachedState, + selector_idx: usize, + native_entrypoints: &ContractEntryPoints, + casm_entrypoints: &CasmContractEntryPoints, + calldata: &[Felt252], + caller_address: &Address, + debug_name: &str, + ) { + let native_selector = &native_entrypoints + .external + .get(selector_idx) + .unwrap() + .selector; + let casm_selector = &casm_entrypoints + .external + .get(selector_idx) + .unwrap() + .selector; + + let vm_result = execute( + state_vm, + caller_address, + caller_address, + casm_selector, + calldata, + EntryPointType::External, + &CASM_CLASS_HASH, + ); + + let native_result = execute( + state_native, + caller_address, + caller_address, + native_selector, + calldata, + EntryPointType::External, + &NATIVE_CLASS_HASH, + ); + + assert_eq!(vm_result.failure_flag, native_result.failure_flag); + assert_eq!(vm_result.retdata, native_result.retdata); + assert_eq!(vm_result.events, native_result.events); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); + + assert_eq!( + vm_result.gas_consumed, native_result.gas_consumed, + "gas consumed mismatch for {debug_name}", + ); + } + + // --------------- GET TOTAL SUPPLY ----------------- + + compare_results( + &mut state_vm, + &mut state_native, + 5, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get total supply 1", + ); + + // ---------------- GET DECIMALS ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 1, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get decimals 1", + ); + + // ---------------- GET NAME ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 6, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get name", + ); + + // // ---------------- GET SYMBOL ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 7, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get symbol", + ); + + // ---------------- GET BALANCE OF CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone()], + &caller_address, + "get balance of caller", + ); + + // // ---------------- ALLOWANCE OF ADDRESS 1 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 3, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone(), 1.into()], + &caller_address, + "get allowance of address 1", + ); + + // // ---------------- INCREASE ALLOWANCE OF ADDRESS 1 by 10_000 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 2, + &native_entrypoints, + &casm_entrypoints, + &[1.into(), 10_000.into()], + &caller_address, + "increase allowance of address 1 by 10000", + ); + + // ---------------- ALLOWANCE OF ADDRESS 1 ---------------------- + + // Checking again because allowance changed with previous call. + compare_results( + &mut state_vm, + &mut state_native, + 3, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone(), 1.into()], + &caller_address, + "allowance of address 1 part 2", + ); + + // ---------------- APPROVE ADDRESS 1 TO MAKE TRANSFERS ON BEHALF OF THE CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 4, + &native_entrypoints, + &casm_entrypoints, + &[1.into(), 5000.into()], + &caller_address, + "approve address 1 to make transfers", + ); + + // ---------------- TRANSFER 3 TOKENS FROM CALLER TO ADDRESS 2 --------- + + compare_results( + &mut state_vm, + &mut state_native, + 0, + &native_entrypoints, + &casm_entrypoints, + &[2.into(), 3.into()], + &caller_address, + "transfer 3 tokens", + ); + + // // ---------------- GET BALANCE OF CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone()], + &caller_address, + "GET BALANCE OF CALLER", + ); + + // // ---------------- GET BALANCE OF ADDRESS 2 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[2.into()], + &caller_address, + "GET BALANCE OF ADDRESS 2", + ); + + // // ---------------- TRANSFER 1 TOKEN FROM CALLER TO ADDRESS 2, CALLED FROM ADDRESS 1 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 9, + &native_entrypoints, + &casm_entrypoints, + &[1.into(), 2.into(), 1.into()], + &caller_address, + "TRANSFER 1 TOKEN FROM CALLER TO ADDRESS 2, CALLED FROM ADDRESS 1", + ); + + // // ---------------- GET BALANCE OF ADDRESS 2 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[2.into()], + &caller_address, + "GET BALANCE OF ADDRESS 2 part 2", + ); + + // // ---------------- GET BALANCE OF CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone()], + &caller_address, + "GET BALANCE OF CALLER last", + ); +} + +#[test] +fn call_contract_test() { + // Caller contract + let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/caller.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Callee contract + let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/callee.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Caller contract entrypoints + let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; + let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; + + // Callee contract entrypoints + let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; + let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Caller contract data + let caller_address = Address(1111.into()); + let caller_class_hash: ClassHash = [1; 32]; + let caller_nonce = Felt252::zero(); + + // Callee contract data + let callee_address = Address(1112.into()); + let callee_class_hash: ClassHash = [2; 32]; + let callee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + caller_class_hash, + CompiledClass::Sierra(Arc::new(caller_contract_class)), + ); + contract_class_cache.set_contract_class( + callee_class_hash, + CompiledClass::Sierra(Arc::new(callee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), caller_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), caller_nonce); + + // Insert callee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(callee_address.clone(), callee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(callee_address.clone(), callee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [fn_selector.into()].to_vec(); + let result = execute( + &mut state, + &caller_address, + &callee_address, + call_contract_selector, + &calldata, + EntryPointType::External, + &caller_class_hash, + ); + + assert_eq!(result.retdata, [Felt252::new(44)]); +} + +#[test] +fn call_echo_contract_test() { + // Caller contract + let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo_caller.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Callee contract + let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Caller contract entrypoints + let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; + let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; + + // Callee contract entrypoints + let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; + let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Caller contract data + let caller_address = Address(1111.into()); + let caller_class_hash: ClassHash = [1; 32]; + let caller_nonce = Felt252::zero(); + + // Callee contract data + let callee_address = Address(1112.into()); + let callee_class_hash: ClassHash = [2; 32]; + let callee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + caller_class_hash, + CompiledClass::Sierra(Arc::new(caller_contract_class)), + ); + + contract_class_cache.set_contract_class( + callee_class_hash, + CompiledClass::Sierra(Arc::new(callee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), caller_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), caller_nonce); + + // Insert callee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(callee_address.clone(), callee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(callee_address.clone(), callee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [fn_selector.into(), 99999999.into()].to_vec(); + let result = execute( + &mut state, + &caller_address, + &callee_address, + call_contract_selector, + &calldata, + EntryPointType::External, + &caller_class_hash, + ); + + assert_eq!(result.retdata, [Felt252::new(99999999)]); + assert_eq!(result.gas_consumed, 89110); +} + +#[test] +#[cfg(feature = "cairo-native")] +fn call_events_contract_test() { + // Caller contract + let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/caller.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Callee contract + let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/event_emitter.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Caller contract entrypoints + let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; + let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; + + // Event emmitter contract entrypoints + let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; + let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Caller contract data + let caller_address = Address(1111.into()); + let caller_class_hash: ClassHash = [1; 32]; + let caller_nonce = Felt252::zero(); + + // Callee contract data + let callee_address = Address(1112.into()); + let callee_class_hash: ClassHash = [2; 32]; + let callee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + caller_class_hash, + CompiledClass::Sierra(Arc::new(caller_contract_class)), + ); + + contract_class_cache.set_contract_class( + callee_class_hash, + CompiledClass::Sierra(Arc::new(callee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), caller_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), caller_nonce); + + // Insert callee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(callee_address.clone(), callee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(callee_address.clone(), callee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [fn_selector.into()].to_vec(); + let result = execute( + &mut state, + &caller_address, + &callee_address, + call_contract_selector, + &calldata, + EntryPointType::External, + &caller_class_hash, + ); + + let internal_call = CallInfo { + caller_address: Address(1111.into()), + call_type: Some(Call), + contract_address: Address(1112.into()), + code_address: None, + class_hash: Some([ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, + ]), + entry_point_selector: Some(fn_selector.into()), + entry_point_type: Some(External), + calldata: Vec::new(), + retdata: vec![1234.into()], + execution_resources: None, + events: vec![OrderedEvent { + order: 0, + keys: vec![110.into()], + data: vec![1.into()], + }], + l2_to_l1_messages: Vec::new(), + storage_read_values: Vec::new(), + accessed_storage_keys: HashSet::new(), + internal_calls: Vec::new(), + gas_consumed: 9640, + failure_flag: false, + }; + + let event = Event { + from_address: Address(1112.into()), + keys: vec![110.into()], + data: vec![1.into()], + }; + + assert_eq!(result.retdata, [1234.into()]); + assert_eq!(result.events, []); + assert_eq_sorted!(result.internal_calls, [internal_call]); + + let sorted_events = result.get_sorted_events().unwrap(); + assert_eq!(sorted_events, vec![event]); +} + +fn execute( + state: &mut CachedState, + caller_address: &Address, + callee_address: &Address, + selector: &BigUint, + calldata: &[Felt252], + entrypoint_type: EntryPointType, + class_hash: &ClassHash, +) -> CallInfo { + let exec_entry_point = ExecutionEntryPoint::new( + (*callee_address).clone(), + calldata.to_vec(), + Felt252::new(selector), + (*caller_address).clone(), + entrypoint_type, + Some(CallType::Delegate), + Some(*class_hash), + u64::MAX.into(), + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + exec_entry_point + .execute( + state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap() +} + +fn execute_deploy( + state: &mut CachedState, + caller_address: &Address, + selector: &BigUint, + calldata: &[Felt252], + entrypoint_type: EntryPointType, + class_hash: &ClassHash, +) -> CallInfo { + let exec_entry_point = ExecutionEntryPoint::new( + (*caller_address).clone(), + calldata.to_vec(), + Felt252::new(selector), + (*caller_address).clone(), + entrypoint_type, + Some(CallType::Delegate), + Some(*class_hash), + u64::MAX.into(), + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + exec_entry_point + .execute( + state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap() +} + +#[test] +#[cfg(feature = "cairo-native")] +fn deploy_syscall_test() { + // Deployer contract + + let deployer_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/deploy.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Deployee contract + let deployee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // deployer contract entrypoints + let deployer_entrypoints = deployer_contract_class.clone().entry_points_by_type; + let deploy_contract_selector = &deployer_entrypoints.external.get(0).unwrap().selector; + + // Echo contract entrypoints + let deployee_entrypoints = deployee_contract_class.clone().entry_points_by_type; + let _fn_selector = &deployee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Deployer contract data + let deployer_address = Address(1111.into()); + let deployer_class_hash: ClassHash = [1; 32]; + let deployer_nonce = Felt252::zero(); + + // Deployee contract data + let deployee_class_hash: ClassHash = Felt252::one().to_be_bytes(); + let _deployee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + deployer_class_hash, + CompiledClass::Sierra(Arc::new(deployer_contract_class)), + ); + + contract_class_cache.set_contract_class( + deployee_class_hash, + CompiledClass::Sierra(Arc::new(deployee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert deployer contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(deployer_address.clone(), deployer_class_hash); + state_reader + .address_to_nonce_mut() + .insert(deployer_address.clone(), deployer_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [Felt252::from_bytes_be(&deployee_class_hash), Felt252::one()].to_vec(); + let result = execute_deploy( + &mut state, + &deployer_address, + deploy_contract_selector, + &calldata, + EntryPointType::External, + &deployer_class_hash, + ); + let expected_deployed_contract_address = Address( + calculate_contract_address( + &Felt252::one(), + &Felt252::from_bytes_be(&deployee_class_hash), + &[100.into()], + deployer_address, + ) + .unwrap(), + ); + + assert_eq!(result.retdata, [expected_deployed_contract_address.0]); + assert_eq!(result.events, []); + assert_eq!(result.internal_calls.len(), 1); + + let sorted_events = result.get_sorted_events().unwrap(); + assert_eq!(sorted_events, vec![]); + assert_eq!(result.failure_flag, false) +} + +#[test] +#[cfg(feature = "cairo-native")] +fn deploy_syscall_address_unavailable_test() { + // Deployer contract + + use starknet_in_rust::utils::felt_to_hash; + let deployer_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/deploy.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Deployee contract + let deployee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // deployer contract entrypoints + let deployer_entrypoints = deployer_contract_class.clone().entry_points_by_type; + let deploy_contract_selector = &deployer_entrypoints.external.get(0).unwrap().selector; + + // Echo contract entrypoints + let deployee_entrypoints = deployee_contract_class.clone().entry_points_by_type; + let _fn_selector = &deployee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Deployer contract data + let deployer_address = Address(1111.into()); + let deployer_class_hash: ClassHash = [2; 32]; + let deployer_nonce = Felt252::zero(); + + // Deployee contract data + let deployee_class_hash: ClassHash = felt_to_hash(&Felt252::one()); + let deployee_nonce = Felt252::zero(); + let expected_deployed_contract_address = Address( + calculate_contract_address( + &Felt252::one(), + &Felt252::from_bytes_be(&deployee_class_hash), + &[100.into()], + deployer_address.clone(), + ) + .unwrap(), + ); + // Insert contract to be deployed so that its address is taken + let deployee_address = expected_deployed_contract_address; + + contract_class_cache.set_contract_class( + deployer_class_hash, + CompiledClass::Sierra(Arc::new(deployer_contract_class)), + ); + + contract_class_cache.set_contract_class( + deployee_class_hash, + CompiledClass::Sierra(Arc::new(deployee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert deployer contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(deployer_address.clone(), deployer_class_hash); + state_reader + .address_to_nonce_mut() + .insert(deployer_address.clone(), deployer_nonce); + + // Insert deployee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(deployee_address.clone(), deployee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(deployee_address.clone(), deployee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [Felt252::from_bytes_be(&deployee_class_hash), Felt252::one()].to_vec(); + let result = execute_deploy( + &mut state, + &deployer_address, + deploy_contract_selector, + &calldata, + EntryPointType::External, + &deployer_class_hash, + ); + + assert_eq!( + std::str::from_utf8(&result.retdata[0].to_be_bytes()) + .unwrap() + .trim_start_matches('\0'), + "Result::unwrap failed." + ); + assert_eq!(result.events, []); + assert_eq!(result.failure_flag, true); + assert!(result.internal_calls.is_empty()); +} diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index 747ddca2c..98653cd58 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -95,14 +95,14 @@ fn amm_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 232, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 14), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: vec![Felt252::zero(), Felt252::zero()], @@ -184,14 +184,14 @@ fn amm_add_demo_tokens_test() { entry_point_selector: Some(add_demo_token_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata_add_demo_token.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 393, n_memory_holes: 44, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 20), (HASH_BUILTIN_NAME.to_string(), 8), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys: accessed_storage_keys_add_demo_token, storage_read_values: vec![ @@ -263,14 +263,14 @@ fn amm_get_pool_token_balance() { entry_point_selector: Some(get_pool_balance_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata_get_pool_token_balance.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 84, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 1), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys: accessed_storage_keys_get_pool_token_balance, storage_read_values: vec![10000.into()], @@ -358,14 +358,14 @@ fn amm_swap_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata_swap.clone(), retdata: expected_return, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 820, n_memory_holes: 95, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 41), (HASH_BUILTIN_NAME.to_string(), 14), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: [ @@ -608,14 +608,14 @@ fn amm_get_account_token_balance_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata_get_balance, retdata: expected_return, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 92, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: [10.into()].to_vec(), diff --git a/tests/complex_contracts/amm_contracts/amm_proxy.rs b/tests/complex_contracts/amm_contracts/amm_proxy.rs index df8978826..88da2bb2e 100644 --- a/tests/complex_contracts/amm_contracts/amm_proxy.rs +++ b/tests/complex_contracts/amm_contracts/amm_proxy.rs @@ -82,14 +82,14 @@ fn amm_proxy_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone()[1..].to_vec(), retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 232, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 14), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, storage_read_values: vec![Felt252::zero(), Felt252::zero()], @@ -104,14 +104,14 @@ fn amm_proxy_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 280, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 14), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -190,14 +190,14 @@ fn amm_proxy_get_pool_token_balance_test() { calldata: calldata.clone()[1..].to_vec(), retdata: [555.into()].to_vec(), storage_read_values: [555.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 84, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 1), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -211,14 +211,14 @@ fn amm_proxy_get_pool_token_balance_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [555.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 140, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 1), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -304,14 +304,14 @@ fn amm_proxy_add_demo_token_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone()[1..].to_vec(), storage_read_values: vec![0.into(), 0.into(), 0.into(), 0.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 397, n_memory_holes: 42, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 8), ("range_check_builtin".to_string(), 20), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -324,14 +324,14 @@ fn amm_proxy_add_demo_token_test() { entry_point_selector: Some(amm_proxy_entrypoint_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 445, n_memory_holes: 42, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 8), ("range_check_builtin".to_string(), 20), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -429,14 +429,14 @@ fn amm_proxy_get_account_token_balance() { calldata: calldata.clone()[1..].to_vec(), retdata: [200.into()].to_vec(), storage_read_values: [200.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 92, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -450,14 +450,14 @@ fn amm_proxy_get_account_token_balance() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [200.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 151, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -572,14 +572,14 @@ fn amm_proxy_swap() { 1000.into(), ] .to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 826, n_memory_holes: 92, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 14), ("range_check_builtin".to_string(), 41), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -593,14 +593,14 @@ fn amm_proxy_swap() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 885, n_memory_holes: 92, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 14), ("range_check_builtin".to_string(), 41), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() diff --git a/tests/complex_contracts/nft/erc721.rs b/tests/complex_contracts/nft/erc721.rs index 6ae4b4894..de1a8afed 100644 --- a/tests/complex_contracts/nft/erc721.rs +++ b/tests/complex_contracts/nft/erc721.rs @@ -143,14 +143,14 @@ fn erc721_balance_of_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 105, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 1), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, @@ -225,14 +225,14 @@ fn erc721_test_owner_of() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 116, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 5), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, @@ -324,14 +324,14 @@ fn erc721_test_get_approved() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 192, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 8), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -426,14 +426,14 @@ fn erc721_test_is_approved_for_all() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 101, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -529,14 +529,14 @@ fn erc721_test_approve() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 332, n_memory_holes: 30, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 13), (HASH_BUILTIN_NAME.to_string(), 6), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -627,14 +627,14 @@ fn erc721_set_approval_for_all() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 154, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -777,14 +777,14 @@ fn erc721_transfer_from_test() { accessed_storage_keys, storage_read_values: expected_read_values, events: expected_events, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 1131, n_memory_holes: 117, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 53), (HASH_BUILTIN_NAME.to_string(), 16), ]), - }, + }), ..Default::default() }; @@ -868,14 +868,14 @@ fn erc721_transfer_from_and_get_owner_test() { class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 116, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 5), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), ..Default::default() }; diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index 842267831..f6330312c 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -103,7 +103,7 @@ fn internal_deploy_account() { ("n_steps", 3612), ("pedersen_builtin", 23), ("range_check_builtin", 83), - ("l1_gas_usage", 3672) + ("l1_gas_usage", 3060) ] .into_iter() .map(|(k, v)| (k.to_string(), v)) @@ -177,11 +177,11 @@ fn internal_deploy_account_cairo1() { let n_steps; #[cfg(not(feature = "cairo_1_tests"))] { - n_steps = 3948; + n_steps = 3921; } #[cfg(feature = "cairo_1_tests")] { - n_steps = 3952; + n_steps = 3937; } assert_eq!( @@ -195,7 +195,7 @@ fn internal_deploy_account_cairo1() { )), code_address: None, #[cfg(not(feature="cairo_1_tests"))] - gas_consumed: 16440, + gas_consumed: 15540, #[cfg(feature="cairo_1_tests")] gas_consumed: 16770, class_hash: Some([ @@ -212,12 +212,12 @@ fn internal_deploy_account_cairo1() { 2.into() ], retdata: vec![felt_str!("370462705988")], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature="cairo_1_tests"))] - n_steps: 152, + n_steps: 144, #[cfg(feature="cairo_1_tests")] n_steps: 155, - n_memory_holes: 17, + n_memory_holes: 2, builtin_instance_counter: [ ("range_check_builtin", 2), @@ -225,7 +225,7 @@ fn internal_deploy_account_cairo1() { .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), - }, + }), ..Default::default() }), @@ -242,14 +242,14 @@ fn internal_deploy_account_cairo1() { entry_point_selector: Some(felt_str!("1159040026212278395030414237414753050475174923702621880048416706425641521556")), entry_point_type: Some(EntryPointType::Constructor), #[cfg(not(feature="cairo_1_tests"))] - gas_consumed: 14240, + gas_consumed: 13840, #[cfg(feature="cairo_1_tests")] gas_consumed: 14350, calldata: vec![2.into()], accessed_storage_keys: keys, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature="cairo_1_tests"))] - n_steps: 92, + n_steps: 88, #[cfg(feature="cairo_1_tests")] n_steps: 93, n_memory_holes: 0, @@ -260,7 +260,7 @@ fn internal_deploy_account_cairo1() { .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), - }, + }), ..Default::default() }), None, @@ -270,7 +270,7 @@ fn internal_deploy_account_cairo1() { ("n_steps", n_steps), ("pedersen_builtin", 23), ("range_check_builtin", 87), - ("l1_gas_usage", 4896) + ("l1_gas_usage", 5508) ] .into_iter() .map(|(k, v)| (k.to_string(), v)) diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index abad548d8..90ef33054 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -117,10 +117,10 @@ fn integration_test() { calldata, retdata: [144.into()].to_vec(), class_hash: Some(class_hash), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 94, ..Default::default() - }, + }), ..Default::default() }; @@ -211,13 +211,13 @@ fn integration_test_cairo1() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [144.into()].to_vec(), - execution_resources: ExecutionResources { - n_steps: 418, + execution_resources: Some(ExecutionResources { + n_steps: 414, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 15)]), - }, + }), class_hash: Some(class_hash), - gas_consumed: 35220, + gas_consumed: 34820, ..Default::default() }; diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index c5910b321..6808f16de 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -123,10 +123,10 @@ fn hello_starknet_increase_balance() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 65, ..Default::default() - }, + }), class_hash: Some(class_hash), accessed_storage_keys: expected_accessed_storage_keys, storage_read_values: expected_storage_read_values, diff --git a/tests/internals.rs b/tests/internals.rs index 5a7443a92..e54d26240 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -406,10 +406,10 @@ fn expected_validate_call_info( // Entries **not** in blockifier. class_hash: Some(felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH)), call_type: Some(CallType::Call), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 13, ..Default::default() - }, + }), ..Default::default() } @@ -476,14 +476,14 @@ fn expected_fee_transfer_call_info( Felt252::zero(), Felt252::zero(), ], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 529, n_memory_holes: 57, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), ..Default::default() } } @@ -610,6 +610,20 @@ fn invoke_tx(calldata: Vec, max_fee: u128) -> InvokeFunction { .unwrap() } +fn invoke_tx_with_nonce(calldata: Vec, max_fee: u128, nonce: Felt252) -> InvokeFunction { + InvokeFunction::new( + TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), + EXECUTE_ENTRY_POINT_SELECTOR.clone(), + max_fee, + TRANSACTION_VERSION.clone(), + calldata, + vec![], + StarknetChainId::TestNet.to_felt(), + Some(nonce), + ) + .unwrap() +} + fn expected_fee_transfer_info(fee: u128) -> CallInfo { CallInfo { failure_flag: false, @@ -623,14 +637,14 @@ fn expected_fee_transfer_info(fee: u128) -> CallInfo { entry_point_type: Some(EntryPointType::External), calldata: vec![Felt252::from(4096), Felt252::from(fee), Felt252::zero()], retdata: vec![Felt252::from(1)], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), l2_to_l1_messages: vec![], internal_calls: vec![], events: vec![OrderedEvent { @@ -687,14 +701,14 @@ fn expected_fib_fee_transfer_info(fee: u128) -> CallInfo { entry_point_type: Some(EntryPointType::External), calldata: vec![Felt252::from(4096), Felt252::from(fee), Felt252::zero()], retdata: vec![Felt252::from(1)], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 21), ("pedersen_builtin".to_string(), 4), ]), - }, + }), l2_to_l1_messages: vec![], internal_calls: vec![], events: vec![OrderedEvent { @@ -708,13 +722,13 @@ fn expected_fib_fee_transfer_info(fee: u128) -> CallInfo { ], }], storage_read_values: vec![ - INITIAL_BALANCE.clone() - Felt252::from(1252), + INITIAL_BALANCE.clone() - Felt252::from(3700), Felt252::zero(), - INITIAL_BALANCE.clone() - Felt252::from(1252), + INITIAL_BALANCE.clone() - Felt252::from(3700), Felt252::zero(), - Felt252::from(1252), + Felt252::from(3700), Felt252::zero(), - Felt252::from(1252), + Felt252::from(3700), Felt252::zero(), ], accessed_storage_keys: HashSet::from([ @@ -757,7 +771,7 @@ fn declare_tx() -> Declare { fn declarev2_tx() -> DeclareV2 { #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.sierra"); + let program_data = include_bytes!("../starknet_programs/raw_contract_classes/fibonacci.sierra"); #[cfg(feature = "cairo_1_tests")] let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.sierra"); let sierra_contract_class: SierraContractClass = serde_json::from_slice(program_data).unwrap(); @@ -775,7 +789,7 @@ fn declarev2_tx() -> DeclareV2 { nonce: 0.into(), hash_value: 0.into(), compiled_class_hash: casm_class_hash, - sierra_contract_class, + sierra_contract_class: Some(sierra_contract_class), sierra_class_hash, casm_class: casm_class.into(), skip_execute: false, @@ -871,14 +885,14 @@ fn expected_declare_fee_transfer_info(fee: u128) -> CallInfo { ], ]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), ..Default::default() } } @@ -954,10 +968,10 @@ fn test_declare_tx() { entry_point_selector: Some(VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone()), entry_point_type: Some(EntryPointType::External), calldata: vec![TEST_EMPTY_CONTRACT_CLASS_HASH.clone()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 12, ..Default::default() - }, + }), ..Default::default() }), None, @@ -1034,7 +1048,7 @@ fn test_declarev2_tx() { ("n_steps".to_string(), 2715), ("range_check_builtin".to_string(), 63), ("pedersen_builtin".to_string(), 15), - ("l1_gas_usage".to_string(), 1224), + ("l1_gas_usage".to_string(), 3672), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); @@ -1055,10 +1069,10 @@ fn test_declarev2_tx() { entry_point_selector: Some(VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone()), entry_point_type: Some(EntryPointType::External), calldata: vec![contract_hash], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 12, ..Default::default() - }, + }), ..Default::default() }), None, @@ -1112,18 +1126,18 @@ fn expected_execute_call_info() -> CallInfo { internal_calls: vec![], contract_address: TEST_CONTRACT_ADDRESS.clone(), code_address: None, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 22, ..Default::default() - }, + }), ..Default::default() }], events: vec![], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 61, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 1)]), - }, + }), ..Default::default() } } @@ -1155,14 +1169,14 @@ fn expected_fib_execute_call_info() -> CallInfo { Felt252::from(0), ], retdata: vec![Felt252::from(42)], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 157, + n_steps: 153, #[cfg(feature = "cairo_1_tests")] n_steps: 160, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 4)]), - }, + }), l2_to_l1_messages: vec![], internal_calls: vec![CallInfo { caller_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), @@ -1178,17 +1192,17 @@ fn expected_fib_execute_call_info() -> CallInfo { contract_address: TEST_FIB_CONTRACT_ADDRESS.clone(), code_address: None, #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 4380, + gas_consumed: 3980, #[cfg(feature = "cairo_1_tests")] gas_consumed: 4710, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 118, + n_steps: 114, #[cfg(feature = "cairo_1_tests")] n_steps: 121, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 3)]), - }, + }), ..Default::default() }], events: vec![], @@ -1214,11 +1228,11 @@ fn expected_validate_call_info_2() -> CallInfo { Felt252::from(1), Felt252::from(2), ], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 21, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 1)]), - }, + }), ..Default::default() } } @@ -1239,11 +1253,11 @@ fn expected_fib_validate_call_info_2() -> CallInfo { Felt252::from(0), Felt252::from(0), ], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 21, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 1)]), - }, + }), ..Default::default() } } @@ -1273,7 +1287,7 @@ fn expected_fib_transaction_execution_info( let n_steps; #[cfg(not(feature = "cairo_1_tests"))] { - n_steps = 4231; + n_steps = 4227; } #[cfg(feature = "cairo_1_tests")] { @@ -1281,7 +1295,7 @@ fn expected_fib_transaction_execution_info( } let resources = HashMap::from([ ("n_steps".to_string(), n_steps), - ("l1_gas_usage".to_string(), 4896), + ("l1_gas_usage".to_string(), 6732), ("pedersen_builtin".to_string(), 16), ("range_check_builtin".to_string(), 104), ]); @@ -1504,9 +1518,9 @@ fn test_invoke_with_declarev2_tx() { Felt252::from(0), // b Felt252::from(0), // n ]; - let invoke_tx = invoke_tx(calldata, u128::MAX); + let invoke_tx = invoke_tx_with_nonce(calldata, u128::MAX, Felt252::one()); - let expected_gas_consumed = 4908; + let expected_gas_consumed = 5551; let result = invoke_tx .execute(state, block_context, expected_gas_consumed) .unwrap(); @@ -1519,7 +1533,7 @@ fn test_invoke_with_declarev2_tx() { fn test_deploy_account() { let (block_context, mut state) = create_account_tx_test_state().unwrap(); - let expected_fee = 3709; + let expected_fee = 3097; let deploy_account_tx = DeployAccount::new( felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH), @@ -1597,7 +1611,7 @@ fn test_deploy_account() { ("n_steps".to_string(), 3625), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), - ("l1_gas_usage".to_string(), 3672), + ("l1_gas_usage".to_string(), 3060), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); @@ -1744,12 +1758,12 @@ fn test_deploy_account_revert() { ("n_steps".to_string(), 3625), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), - ("l1_gas_usage".to_string(), 3672), + ("l1_gas_usage".to_string(), 3060), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); - assert_eq!(fee, 3709); + assert_eq!(fee, 3097); let mut expected_execution_info = TransactionExecutionInfo::new( None, @@ -1787,7 +1801,7 @@ fn expected_deploy_account_states() -> ( CachedState, CachedState, ) { - let fee = Felt252::from(3709); + let fee = Felt252::from(3097); let mut state_before = CachedState::new( Arc::new(InMemoryStateReader::new( HashMap::from([ @@ -1838,7 +1852,7 @@ fn expected_deploy_account_states() -> ( INITIAL_BALANCE.clone(), ); - let mut state_after = state_before.clone(); + let mut state_after = state_before.clone_for_testing(); // Make the contract cache independent (otherwise tests will fail because the initial state's // cache will not be empty anymore). @@ -2335,19 +2349,19 @@ fn test_library_call_with_declare_v2() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 30080, + gas_consumed: 29680, #[cfg(feature = "cairo_1_tests")] gas_consumed: 30410, calldata: vec![1.into(), 1.into(), 10.into()], retdata: vec![89.into()], // fib(10) - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 368, + n_steps: 364, #[cfg(feature = "cairo_1_tests")] n_steps: 371, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 13)]), - }, + }), ..Default::default() }; @@ -2359,19 +2373,19 @@ fn test_library_call_with_declare_v2() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 112490, + gas_consumed: 111690, #[cfg(feature = "cairo_1_tests")] gas_consumed: 113480, calldata, retdata: vec![89.into()], // fib(10) - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 578, + n_steps: 570, #[cfg(feature = "cairo_1_tests")] n_steps: 587, n_memory_holes: 1, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 16)]), - }, + }), internal_calls: vec![expected_internal_call_info], ..Default::default() }; diff --git a/tests/storage.rs b/tests/storage.rs index 22b87180d..73a092b17 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -120,10 +120,10 @@ fn integration_storage_test() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [42.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 68, ..Default::default() - }, + }), class_hash: Some(class_hash), storage_read_values: vec![0.into(), 42.into()], accessed_storage_keys: expected_accessed_storage_keys, diff --git a/tests/syscalls.rs b/tests/syscalls.rs index 4e96b104f..e60ecca52 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -175,7 +175,7 @@ fn test_contract<'a>( assert_eq!(result.calldata, calldata); assert_eq_sorted!(result.retdata, return_data.into()); assert_eq_sorted!(result.internal_calls, internal_calls.into()); - assert_eq!(result.execution_resources, execution_resources); + assert_eq!(result.execution_resources, Some(execution_resources)); assert_eq!(result.gas_consumed, 0); assert!(!result.failure_flag); @@ -217,10 +217,10 @@ fn call_contract_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![21.into(), 2.into()], retdata: vec![42.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 24, ..Default::default() - }, + }), ..Default::default() }, CallInfo { @@ -239,10 +239,10 @@ fn call_contract_syscall() { ]] .into_iter() .collect(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 63, ..Default::default() - }, + }), ..Default::default() }, CallInfo { @@ -256,10 +256,10 @@ fn call_contract_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![], retdata: vec![2222.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 26, ..Default::default() - }, + }), ..Default::default() }, ], @@ -709,11 +709,11 @@ fn library_call_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![21.into(), 2.into()], retdata: vec![42.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 24, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }, + }), ..Default::default() }, CallInfo { @@ -732,11 +732,11 @@ fn library_call_syscall() { ]] .into_iter() .collect(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 63, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }, + }), ..Default::default() }, CallInfo { @@ -750,11 +750,11 @@ fn library_call_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![], retdata: vec![1111.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 26, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }, + }), ..Default::default() }, ], @@ -804,10 +804,10 @@ fn library_call_l1_handler_syscall() { .into_iter() .collect(), storage_read_values: vec![0.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, ..Default::default() - }, + }), ..Default::default() }], [], @@ -949,11 +949,11 @@ fn deploy_with_constructor_syscall() { entry_point_selector: Some(entry_point_selector), entry_point_type: Some(EntryPointType::Constructor), calldata: [550.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, n_memory_holes: 0, ..Default::default() - }, + }), accessed_storage_keys: HashSet::<[u8; 32]>::from([[ 2, 63, 76, 85, 114, 157, 43, 172, 36, 175, 107, 126, 158, 121, 114, 77, 194, 27, 162, 147, 169, 199, 107, 53, 94, 246, 206, 221, 169, 114, 215, 255, @@ -1030,10 +1030,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![], storage_read_values: vec![0.into()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, ..Default::default() - }, + }), ..Default::default() }, // Invoke storage_var_and_constructor.cairo mult_constant function @@ -1055,10 +1055,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![(constructor_constant.clone() * Felt252::new(4))], storage_read_values: vec![constructor_constant.clone()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 52, ..Default::default() - }, + }), ..Default::default() }, // Invoke storage_var_and_constructor.cairo set_constant function @@ -1080,10 +1080,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![], storage_read_values: vec![constructor_constant], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, ..Default::default() - }, + }), ..Default::default() }, // Invoke storage_var_and_constructor.cairo get_constant function @@ -1105,10 +1105,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![new_constant.clone()], storage_read_values: vec![new_constant.clone()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 46, ..Default::default() - }, + }), ..Default::default() } ], @@ -1219,6 +1219,7 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1323,6 +1324,7 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1425,6 +1427,7 @@ fn deploy_cairo1_and_invoke() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); From d265c76308114a1d5c46ee7893cd694525b0a639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Calv=C3=ADn=20Garc=C3=ADa?= Date: Tue, 31 Oct 2023 18:03:28 +0100 Subject: [PATCH 47/56] Revert "Update Pr: Make contract caches shared (#1071)" (#1116) This reverts commit 8a112590e107cc69767bd31c6034c7070ca47c0a. --- .gitattributes | 2 - .github/workflows/rust-tests.yml | 297 +- Cargo.lock | 1274 +---- Cargo.toml | 39 +- Makefile | 52 +- README.md | 20 +- bench/internals.rs | 8 +- cairo_programs/erc20.sierra | 5012 ----------------- cairo_programs/wallet.sierra | 1430 ----- cli/src/main.rs | 2 +- examples/contract_execution/main.rs | 9 - examples/lru_cache/main.rs | 2 +- fuzzer/src/main.rs | 2 +- rpc_state_reader/Cargo.toml | 2 +- rpc_state_reader/src/lib.rs | 43 +- rpc_state_reader/src/rpc_state.rs | 26 +- rpc_state_reader/src/utils.rs | 20 +- rpc_state_reader/tests/blockifier_tests.rs | 134 +- rpc_state_reader/tests/sir_tests.rs | 223 +- rust-toolchain | 2 +- .../contract_address/casm_contract_address.rs | 12 +- .../deprecated_contract_address.rs | 2 +- .../sierra_contract_address.rs | 77 +- src/core/errors/state_errors.rs | 2 - src/definitions/constants.rs | 8 +- src/execution/execution_entry_point.rs | 254 +- src/execution/gas_usage.rs | 49 +- src/execution/mod.rs | 13 +- src/lib.rs | 140 +- .../api/contract_classes/compiled_class.rs | 3 +- src/state/cached_state.rs | 269 +- src/state/mod.rs | 12 +- src/state/state_api.rs | 27 +- src/state/state_cache.rs | 35 +- .../business_logic_syscall_handler.rs | 137 +- ...precated_business_logic_syscall_handler.rs | 5 +- src/syscalls/deprecated_syscall_handler.rs | 2 +- src/syscalls/mod.rs | 2 - src/syscalls/native_syscall_handler.rs | 576 -- src/syscalls/syscall_handler.rs | 2 +- src/transaction/declare.rs | 156 +- src/transaction/declare_v2.rs | 58 +- src/transaction/deploy.rs | 23 +- src/transaction/deploy_account.rs | 53 +- src/transaction/error.rs | 2 - src/transaction/fee.rs | 14 +- src/transaction/invoke_function.rs | 33 +- src/transaction/l1_handler.rs | 57 +- src/transaction/mod.rs | 1 - src/transaction/verify_version.rs | 8 +- src/utils.rs | 54 +- .../cairo1/square_root_recursive.cairo | 24 - starknet_programs/cairo1/wallet_wrapper.cairo | 9 - starknet_programs/cairo2/account_panic.cairo | 148 - starknet_programs/cairo2/callee.cairo | 22 - starknet_programs/cairo2/caller.cairo | 19 - starknet_programs/cairo2/deploy.cairo | 8 +- starknet_programs/cairo2/echo.cairo | 17 - starknet_programs/cairo2/echo_caller.cairo | 20 - starknet_programs/cairo2/erc20.cairo | 2 +- starknet_programs/cairo2/event_emitter.cairo | 30 - .../cairo2/hello_world_account.cairo | 2 +- .../cairo2/square_root_recursive.cairo | 37 - starknet_programs/cairo2/wallet_wrapper.cairo | 14 +- ...9bd7409f07591f0a04f539bdf56693eaaf3.sierra | 687 --- ...46e7e79464ad52ecdad80079ddfe486ca5eef.casm | 1429 ----- ...171713f0e5229a084989d3894c171c160ace2.casm | 524 -- ...16c42fa9b87c812dc398e49b57bf77930629f.casm | 1097 ---- ...4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm | 755 --- ...fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm | 557 -- ...f33d879f790e202eb2c4b8622005c12252641.casm | 476 -- .../raw_contract_classes/fibonacci.sierra | 373 -- tests/account_panic.rs | 117 - tests/cairo_1_syscalls.rs | 593 +- tests/cairo_native.rs | 1001 ---- tests/complex_contracts/amm_contracts/amm.rs | 20 +- .../amm_contracts/amm_proxy.rs | 40 +- tests/complex_contracts/nft/erc721.rs | 32 +- tests/deploy_account.rs | 26 +- tests/fibonacci.rs | 12 +- tests/increase_balance.rs | 4 +- tests/internals.rs | 122 +- tests/storage.rs | 4 +- tests/syscalls.rs | 53 +- 84 files changed, 1081 insertions(+), 17878 deletions(-) delete mode 100644 .gitattributes delete mode 100644 cairo_programs/erc20.sierra delete mode 100644 cairo_programs/wallet.sierra delete mode 100644 src/syscalls/native_syscall_handler.rs delete mode 100644 starknet_programs/cairo1/square_root_recursive.cairo delete mode 100644 starknet_programs/cairo2/account_panic.cairo delete mode 100644 starknet_programs/cairo2/callee.cairo delete mode 100644 starknet_programs/cairo2/caller.cairo delete mode 100644 starknet_programs/cairo2/echo.cairo delete mode 100644 starknet_programs/cairo2/echo_caller.cairo delete mode 100644 starknet_programs/cairo2/event_emitter.cairo delete mode 100644 starknet_programs/cairo2/square_root_recursive.cairo delete mode 100644 starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra delete mode 100644 starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm delete mode 100644 starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm delete mode 100644 starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm delete mode 100644 starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm delete mode 100644 starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm delete mode 100644 starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm delete mode 100644 starknet_programs/raw_contract_classes/fibonacci.sierra delete mode 100644 tests/account_panic.rs delete mode 100644 tests/cairo_native.rs diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 6630a6678..000000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.sierra linguist-generated -*.casm linguist-generated diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index 52d2dfe0e..c1bea663e 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -9,121 +9,211 @@ on: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: '1.72.1' + RUST_TOOLCHAIN: 1.70.0 + CAIRO_PROGRAMS_PATH: | + cairo_programs/**/*.casm + cairo_programs/**/*.sierra + cairo_programs/**/*.json + starknet_programs/**/*.casm + starknet_programs/**/*.sierra + starknet_programs/**/*.json + !starknet_programs/raw_contract_classes/* jobs: - build: - name: Build with release profile - runs-on: ubuntu-latest + build-programs: + strategy: + matrix: + program-target: [ + compile-cairo, + compile-starknet, + compile-cairo-1-casm, + compile-cairo-1-sierra, + compile-cairo-2-casm, + compile-cairo-2-sierra, + ] + name: Build Cairo programs + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 - - name: Install Rust $RUST_TOOLCHAIN - uses: dtolnay/rust-toolchain@master with: - toolchain: $RUST_TOOLCHAIN - components: rustfmt, clippy + fetch-depth: 0 + + - name: Fetch from cache + uses: actions/cache@v3 + id: cache-programs + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + restore-keys: ${{ matrix.program-target }}-cache- + + # This is not pretty, but we need `make` to see the compiled programs are + # actually newer than the sources, otherwise it will try to rebuild them + - name: Restore timestamps + uses: chetan/git-restore-mtime-action@v1 + - name: Python3 Build + if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' + + - name: Install deps + if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} + run: make deps + + - name: Build programs + if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} + run: make -j ${{ matrix.program-target }} + + # NOTE: used to reduce the amount of cache steps we need in later jobs + # TODO: remove this cache once the workflow finishes + merge-caches: + name: Merge Cairo programs cache + runs-on: ubuntu-22.04 + needs: build-programs + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Fetch from cache (compile-cairo) + uses: actions/cache/restore@v3 + id: cache-programs + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-cairo-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Fetch from cache (compile-starknet) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-starknet-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Fetch from cache (compile-cairo-1-casm) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-cairo-1-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Fetch from cache (compile-cairo-1-sierra) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-cairo-1-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Fetch from cache (compile-cairo-2-casm) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-cairo-2-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Fetch from cache (compile-cairo-2-sierra) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Fetch from cache (compile-cairo-2-sierra) + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + + - name: Merge caches + uses: actions/cache/save@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + + build: + name: Build with release profile + needs: merge-caches + runs-on: ubuntu-22.04 + steps: + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + - name: Checkout + uses: actions/checkout@v3 + - name: Fetch programs + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true - - name: Install deps - run: make deps - name: Build - run: make build + run: cargo build --release --workspace lint: name: Lint with fmt and clippy - runs-on: ubuntu-latest - env: - MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ - TABLEGEN_170_PREFIX: /usr/lib/llvm-17/ + needs: merge-caches + runs-on: ubuntu-22.04 steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Rust $RUST_TOOLCHAIN - uses: dtolnay/rust-toolchain@master - with: - toolchain: $RUST_TOOLCHAIN - components: rustfmt, clippy - - name: Python3 Build - uses: actions/setup-python@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable with: - python-version: '3.9' - cache: 'pip' + toolchain: ${{ env.RUST_TOOLCHAIN }} + components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: check and free hdd space left - run: | - echo "Listing 20 largest packages" - dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 - df -h - sudo apt-get update - sudo apt-get remove -y '^llvm-.*' - sudo apt-get remove -y 'php.*' - sudo apt-get remove -y '^dotnet-.*' - sudo apt-get remove -y '^temurin-.*' - sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel - sudo apt-get autoremove -y - sudo apt-get clean - df -h - echo "Removing large directories" - # deleting 15GB - sudo rm -rf /usr/share/dotnet/ - sudo rm -rf /usr/local/lib/android - df -h - - name: add llvm deb repository - uses: myci-actions/add-deb-repo@10 - with: - repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main - repo-name: llvm-repo - keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key - - name: Install LLVM - run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools - - name: Install deps - run: make deps + - name: Checkout + uses: actions/checkout@v3 + - name: Fetch programs + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + - name: Format run: cargo fmt --all -- --check - name: Run clippy - run: make clippy + run: cargo clippy --workspace --all-targets -- -D warnings tests: env: INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} - MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ - TABLEGEN_170_PREFIX: /usr/lib/llvm-17/ strategy: fail-fast: false matrix: - target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ] + target: [ test-cairo-1, test-cairo-2, test-doctests ] name: Run tests - runs-on: ubuntu-latest + needs: merge-caches + runs-on: ubuntu-22.04 steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Rust $RUST_TOOLCHAIN - uses: dtolnay/rust-toolchain@master - with: - toolchain: $RUST_TOOLCHAIN - components: rustfmt, clippy - - name: Python3 Build - uses: actions/setup-python@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable with: - python-version: '3.9' - cache: 'pip' + toolchain: ${{ env.RUST_TOOLCHAIN }} + components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true + - name: Checkout + uses: actions/checkout@v3 - - name: Install deps - run: make deps - + - name: Fetch programs + uses: actions/cache/restore@v3 + with: + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true + - name: Install testing tools # TODO: remove `if` when nextest adds doctests support if: ${{ matrix.target != 'test-doctests' }} @@ -131,47 +221,28 @@ jobs: with: tool: cargo-nextest@0.9.49 - - name: check and free hdd space left - run: | - echo "Listing 20 largest packages" - dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 - df -h - sudo apt-get update - sudo apt-get remove -y '^llvm-.*' - sudo apt-get remove -y 'php.*' - sudo apt-get remove -y '^dotnet-.*' - sudo apt-get remove -y '^temurin-.*' - sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel - sudo apt-get autoremove -y - sudo apt-get clean - df -h - echo "Removing large directories" - # deleting 15GB - sudo rm -rf /usr/share/dotnet/ - sudo rm -rf /usr/local/lib/android - df -h - - name: add llvm deb repository - uses: myci-actions/add-deb-repo@10 - with: - repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main - repo-name: llvm-repo - keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key - - name: Install LLVM - run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools - name: Run tests (${{ matrix.target }}) run: make ${{ matrix.target }} coverage: + needs: merge-caches name: Generate and upload coverage report - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 + - name: Install Rust + uses: dtolnay/rust-toolchain@nightly + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + + - name: Set nightly as default + run: rustup default nightly - - name: Install Rust nightly - uses: dtolnay/rust-toolchain@master + - name: Install testing tools + uses: taiki-e/install-action@v2 with: - toolchain: nightly + tool: cargo-nextest@0.9.49,cargo-llvm-cov - uses: Swatinem/rust-cache@v2 with: @@ -184,17 +255,13 @@ jobs: path: lcov.info key: coverage-cache-${{ github.sha }} - - name: Python3 Build - uses: actions/setup-python@v4 - with: - python-version: '3.9' - cache: 'pip' - - uses: Swatinem/rust-cache@v2 + - name: Fetch programs + if: steps.restore-report.outputs.cache-hit != 'true' + uses: actions/cache/restore@v3 with: - cache-on-failure: true - - - name: Install deps - run: make deps + path: ${{ env.CAIRO_PROGRAMS_PATH }} + key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} + fail-on-cache-miss: true - name: Generate coverage report if: steps.restore-report.outputs.cache-hit != 'true' diff --git a/Cargo.lock b/Cargo.lock index 6d46e8782..c53120744 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash 0.8.3", - "base64 0.21.4", + "base64 0.21.3", "bitflags 2.4.0", "brotli", "bytes", @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -103,7 +103,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.4", + "socket2 0.5.3", "tokio", "tracing", ] @@ -133,7 +133,7 @@ dependencies = [ "impl-more", "pin-project-lite", "rustls", - "rustls-webpki", + "rustls-webpki 0.101.4", "tokio", "tokio-util", "tracing", @@ -184,7 +184,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.5.4", + "socket2 0.5.3", "time", "url", ] @@ -198,7 +198,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -252,9 +252,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -295,17 +295,11 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "anstream" -version = "0.6.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", @@ -317,15 +311,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -341,9 +335,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys", @@ -374,7 +368,7 @@ dependencies = [ "derivative", "hashbrown 0.13.2", "itertools 0.10.5", - "num-traits 0.2.17", + "num-traits 0.2.16", "zeroize", ] @@ -392,7 +386,7 @@ dependencies = [ "digest", "itertools 0.10.5", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "paste", "rustc_version", "zeroize", @@ -415,7 +409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "proc-macro2", "quote", "syn 1.0.109", @@ -485,7 +479,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ - "num-traits 0.2.17", + "num-traits 0.2.16", "rand", ] @@ -518,7 +512,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -551,7 +545,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "base64 0.21.4", + "base64 0.21.3", "bytes", "cfg-if", "cookie", @@ -595,9 +589,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "bigdecimal" @@ -607,16 +601,7 @@ checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.17", - "serde", -] - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ + "num-traits 0.2.16", "serde", ] @@ -629,52 +614,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.66.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" -dependencies = [ - "bitflags 2.4.0", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.38", - "which", -] - -[[package]] -name = "bindgen" -version = "0.68.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" -dependencies = [ - "bitflags 2.4.0", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.38", - "which", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -745,7 +684,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "phf", "serde", "serde_json", @@ -759,9 +698,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.4.0" +version = "3.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" +checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -770,9 +709,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.5.0" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" +checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -780,9 +719,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byte-slice-cast" @@ -792,15 +731,15 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.5.0" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.5.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytestring" @@ -856,7 +795,7 @@ dependencies = [ "lazy_static", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "serde", ] @@ -869,7 +808,7 @@ dependencies = [ "cairo-lang-utils", "indoc", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "parity-scale-codec", "parity-scale-codec-derive", "schemars", @@ -924,7 +863,7 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.2", + "indexmap 2.0.0", "itertools 0.11.0", "salsa", "smol_str", @@ -951,7 +890,7 @@ checksum = "c35dddbc63b2a4870891cc74498726aa32bfaa518596352f9bb101411cc4c584" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.2", + "indexmap 2.0.0", "itertools 0.11.0", ] @@ -985,11 +924,11 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.2", + "indexmap 2.0.0", "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "once_cell", "salsa", "smol_str", @@ -1010,7 +949,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "salsa", "smol_str", "unescaper", @@ -1044,7 +983,7 @@ checksum = "170838817fc33ddb65e0a9480526df0b226b148a0fca0a5cd7071be4c6683157" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -1093,7 +1032,7 @@ dependencies = [ "keccak", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "salsa", "thiserror", ] @@ -1117,7 +1056,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "once_cell", "salsa", "smol_str", @@ -1137,7 +1076,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "regex", "salsa", "serde", @@ -1193,7 +1132,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.2", + "indexmap 2.0.0", "itertools 0.11.0", "num-bigint", "once_cell", @@ -1219,7 +1158,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "thiserror", ] @@ -1265,7 +1204,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "once_cell", "serde", "serde_json", @@ -1284,7 +1223,7 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "num-bigint", - "num-traits 0.2.17", + "num-traits 0.2.16", "salsa", "smol_str", "thiserror", @@ -1307,63 +1246,16 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f974b6e859f0b09c0f13ec8188c96e9e8bbb5da04214f911dbb5bcda67cb812b" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.0.0", "itertools 0.11.0", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "parity-scale-codec", "schemars", "serde", ] -[[package]] -name = "cairo-native" -version = "0.1.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" -dependencies = [ - "bumpalo", - "cairo-felt", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-sierra", - "cairo-lang-sierra-ap-change", - "cairo-lang-sierra-gas", - "cairo-lang-sierra-generator", - "cairo-lang-starknet", - "cairo-lang-utils", - "cairo-native-runtime", - "cc", - "clap", - "id-arena", - "itertools 0.11.0", - "lazy_static", - "libc", - "melior", - "mlir-sys", - "num-bigint", - "serde", - "serde_json", - "thiserror", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "cairo-native-runtime" -version = "0.1.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" -dependencies = [ - "cairo-felt", - "cairo-lang-runner", - "libc", - "starknet-crypto 0.6.0", - "starknet-curve 0.4.0", -] - [[package]] name = "cairo-vm" version = "0.8.7" @@ -1373,13 +1265,13 @@ dependencies = [ "anyhow", "ark-ff", "ark-std", - "bincode 2.0.0-rc.3", + "bincode", "bitvec", "cairo-felt", "cairo-lang-casm", "cairo-lang-starknet", "generic-array", - "hashbrown 0.14.1", + "hashbrown 0.14.0", "hex", "keccak", "lazy_static", @@ -1388,7 +1280,7 @@ dependencies = [ "num-bigint", "num-integer", "num-prime", - "num-traits 0.2.17", + "num-traits 0.2.16", "rand", "serde", "serde_json", @@ -1398,12 +1290,6 @@ dependencies = [ "thiserror-no-std", ] -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - [[package]] name = "cc" version = "1.0.83" @@ -1414,15 +1300,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -1431,44 +1308,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", - "num-traits 0.2.17", + "num-traits 0.2.16", "serde", "windows-targets", ] -[[package]] -name = "ciborium" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" - -[[package]] -name = "ciborium-ll" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cipher" version = "0.4.4" @@ -1479,22 +1329,11 @@ dependencies = [ "inout", ] -[[package]] -name = "clang-sys" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" -version = "4.4.6" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", "clap_derive", @@ -1502,15 +1341,14 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", - "terminal_size", ] [[package]] @@ -1522,7 +1360,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -1548,25 +1386,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "comrak" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "482aa5695bca086022be453c700a40c02893f1ba7098a2c88351de55341ae894" -dependencies = [ - "clap", - "entities", - "memchr", - "once_cell", - "regex", - "shell-words", - "slug", - "syntect", - "typed-arena", - "unicode_categories", - "xdg", -] - [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -1599,16 +1418,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -1639,66 +1448,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "is-terminal", - "itertools 0.10.5", - "num-traits 0.2.17", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", -] - [[package]] name = "crossbeam-utils" version = "0.8.16" @@ -1716,9 +1465,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ "generic-array", "subtle", @@ -1737,12 +1486,12 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.5" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" +checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" dependencies = [ "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -1799,7 +1548,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -1821,7 +1570,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -1836,19 +1585,6 @@ dependencies = [ "ordered-float", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown 0.14.1", - "lock_api", - "once_cell", - "parking_lot_core 0.9.8", -] - [[package]] name = "deranged" version = "0.3.8" @@ -1882,12 +1618,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "deunicode" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" - [[package]] name = "diff" version = "0.1.13" @@ -1934,9 +1664,9 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "either" @@ -1962,12 +1692,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "entities" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" - [[package]] name = "equivalent" version = "1.0.1" @@ -1976,14 +1700,25 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ + "errno-dragonfly", "libc", "windows-sys", ] +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "eth-keystore" version = "0.5.0" @@ -2033,21 +1768,11 @@ dependencies = [ "uint", ] -[[package]] -name = "fancy-regex" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" -dependencies = [ - "bit-set", - "regex", -] - [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fixed-hash" @@ -2142,7 +1867,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -2178,7 +1903,7 @@ version = "0.4.0" dependencies = [ "cairo-vm", "honggfuzz", - "num-traits 0.2.17", + "num-traits 0.2.16", "serde_json", "starknet_api", "starknet_in_rust", @@ -2187,9 +1912,9 @@ dependencies = [ [[package]] name = "genco" -version = "0.17.7" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fd234893ffe9cf5b81224ebb1d21bbe2eeb94d95bac3ea25c97cba7293304d" +checksum = "6973ce8518068a71d404f428f6a5b563088545546a6bd8f9c0a7f2608149bc8a" dependencies = [ "genco-macros", "relative-path", @@ -2198,13 +1923,13 @@ dependencies = [ [[package]] name = "genco-macros" -version = "0.17.7" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1c8cd3de2f32ee05ba2adaa90f8d0c354ffa0adeb2d186978d7ae70e5025e9" +checksum = "9c2c778cf01917d0fbed53900259d6604a421fab4916a2e738856ead9f1d926a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 1.0.109", ] [[package]] @@ -2248,17 +1973,11 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "good_lp" -version = "1.7.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa124423ded10046a849fa0ae9747c541895557f1af177e0890b09879e7e9e7d" +checksum = "fa7f3b0e0de4e671b6ffc1274b153a9394cb58bf04ee67505b0cb9915513115f" dependencies = [ "fnv", "minilp", @@ -2283,12 +2002,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "hashbrown" version = "0.12.3" @@ -2309,9 +2022,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -2335,9 +2048,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -2354,15 +2067,6 @@ dependencies = [ "digest", ] -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys", -] - [[package]] name = "honggfuzz" version = "0.5.55" @@ -2564,20 +2268,20 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.0", "serde", ] [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" [[package]] name = "inout" @@ -2681,7 +2385,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax 0.7.5", + "regex-syntax", "string_cache", "term", "tiny-keccak", @@ -2712,67 +2416,37 @@ dependencies = [ "spin", ] -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" -version = "0.2.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" - -[[package]] -name = "libloading" -version = "0.7.4" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libmimalloc-sys" -version = "0.1.35" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" +checksum = "25d058a81af0d1c22d7a1c948576bee6d673f7af3c0f35564abd6c81122f513d" dependencies = [ "cc", "libc", ] [[package]] -name = "line-wrap" -version = "0.1.1" +name = "linux-raw-sys" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" -dependencies = [ - "safemem", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[package]] name = "local-channel" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" +checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" dependencies = [ "futures-core", "futures-sink", + "futures-util", "local-waker", ] @@ -2813,16 +2487,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.14.1", -] - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", + "hashbrown 0.14.0", ] [[package]] @@ -2834,41 +2499,11 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "melior" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91ea0e9e00979f692a52fb127a2d352e358535168dece6fd4e7948fd7714db5" -dependencies = [ - "criterion", - "dashmap", - "melior-macro", - "mlir-sys", - "once_cell", -] - -[[package]] -name = "melior-macro" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef4083994160cca85418ff2099183160787db26ab4ef5840bcf73472f678590" -dependencies = [ - "comrak", - "convert_case 0.6.0", - "once_cell", - "proc-macro2", - "quote", - "regex", - "syn 2.0.38", - "tblgen", - "unindent", -] - [[package]] name = "memchr" -version = "2.6.4" +version = "2.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" [[package]] name = "memmap2" @@ -2879,20 +2514,11 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mimalloc" -version = "0.1.39" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" +checksum = "972e5f23f6716f62665760b0f4cbf592576a80c7b879ba9beaafc0e558894127" dependencies = [ "libmimalloc-sys", ] @@ -2940,15 +2566,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "mlir-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5e19a5391ed2759fd9060f538330b9b89191e7b13503d7499a4f9580af6699a" -dependencies = [ - "bindgen 0.68.1", -] - [[package]] name = "ndarray" version = "0.13.1" @@ -2958,7 +2575,7 @@ dependencies = [ "matrixmultiply", "num-complex", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "rawpointer", ] @@ -2978,16 +2595,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-bigint" version = "0.4.4" @@ -2996,7 +2603,7 @@ checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "rand", "serde", ] @@ -3008,7 +2615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ "autocfg", - "num-traits 0.2.17", + "num-traits 0.2.16", ] [[package]] @@ -3018,7 +2625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", - "num-traits 0.2.17", + "num-traits 0.2.16", ] [[package]] @@ -3029,7 +2636,7 @@ checksum = "64a5fe11d4135c3bcdf3a95b18b194afa9608a5f6ff034f5d857bc9a27fb0119" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", ] [[package]] @@ -3044,7 +2651,7 @@ dependencies = [ "num-bigint", "num-integer", "num-modular", - "num-traits 0.2.17", + "num-traits 0.2.16", "rand", ] @@ -3054,23 +2661,23 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "num-traits 0.2.17", + "num-traits 0.2.16", ] [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.32.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" dependencies = [ "memchr", ] @@ -3081,28 +2688,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "onig" -version = "6.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" -dependencies = [ - "bitflags 1.3.2", - "libc", - "once_cell", - "onig_sys", -] - -[[package]] -name = "onig_sys" -version = "69.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" -dependencies = [ - "cc", - "pkg-config", -] - [[package]] name = "oorandom" version = "11.1.3" @@ -3115,15 +2700,9 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" dependencies = [ - "num-traits 0.2.17", + "num-traits 0.2.16", ] -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "parity-scale-codec" version = "3.6.4" @@ -3219,12 +2798,6 @@ dependencies = [ "digest", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.3.0" @@ -3238,7 +2811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.2", + "indexmap 2.0.0", ] [[package]] @@ -3271,7 +2844,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -3316,48 +2889,6 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" -[[package]] -name = "plist" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" -dependencies = [ - "base64 0.21.4", - "indexmap 1.9.3", - "line-wrap", - "quick-xml", - "serde", - "time", -] - -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits 0.2.17", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3390,16 +2921,6 @@ dependencies = [ "pretty_assertions", ] -[[package]] -name = "prettyplease" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" -dependencies = [ - "proc-macro2", - "syn 2.0.38", -] - [[package]] name = "primitive-types" version = "0.12.1" @@ -3449,22 +2970,13 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] -[[package]] -name = "quick-xml" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" -dependencies = [ - "memchr", -] - [[package]] name = "quote" version = "1.0.33" @@ -3516,26 +3028,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" -[[package]] -name = "rayon" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - [[package]] name = "redox_syscall" version = "0.2.16" @@ -3567,54 +3059,33 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.1", - "regex-syntax 0.8.0", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.4.1" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.0", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" -[[package]] -name = "regex-syntax" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" - [[package]] name = "relative-path" version = "1.9.0" @@ -3623,11 +3094,11 @@ checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.4", + "base64 0.21.3", "bytes", "encoding_rs", "futures-core", @@ -3649,7 +3120,6 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -3657,7 +3127,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", + "webpki-roots 0.25.2", "winreg", ] @@ -3747,9 +3217,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.18" +version = "0.38.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" dependencies = [ "bitflags 2.4.0", "errno", @@ -3766,7 +3236,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.4", "sct", ] @@ -3776,14 +3246,24 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.3", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.100.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" dependencies = [ "ring", "untrusted", @@ -3801,12 +3281,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - [[package]] name = "salsa" version = "0.16.1" @@ -3845,20 +3319,11 @@ dependencies = [ "cipher", ] -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "schemars" -version = "0.8.15" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "dyn-clone", "indexmap 1.9.3", @@ -3869,9 +3334,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.15" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", "quote", @@ -3909,9 +3374,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" @@ -3930,7 +3395,7 @@ checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -3946,9 +3411,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -4009,11 +3474,11 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.4", + "base64 0.21.3", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.2", + "indexmap 2.0.0", "serde", "serde_json", "serde_with_macros 3.3.0", @@ -4029,7 +3494,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -4041,14 +3506,14 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] name = "sha1" -version = "0.10.6" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", @@ -4057,9 +3522,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", @@ -4076,27 +3541,6 @@ dependencies = [ "keccak", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shell-words" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" - -[[package]] -name = "shlex" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" - [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -4121,20 +3565,11 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slug" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" -dependencies = [ - "deunicode", -] - [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "smol_str" @@ -4157,9 +3592,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" dependencies = [ "libc", "windows-sys", @@ -4190,7 +3625,7 @@ checksum = "8fcb61961b91757a9bc2d11549067445b2f921bd957f53710db35449767a1ba3" dependencies = [ "starknet-accounts", "starknet-contract", - "starknet-core 0.5.1", + "starknet-core", "starknet-crypto 0.6.0", "starknet-ff", "starknet-macros", @@ -4205,7 +3640,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "111ed887e4db14f0df1f909905e7737e4730770c8ed70997b58a71d5d940daac" dependencies = [ "async-trait", - "starknet-core 0.5.1", + "starknet-core", "starknet-providers", "starknet-signers", "thiserror", @@ -4221,7 +3656,7 @@ dependencies = [ "serde_json", "serde_with 2.3.3", "starknet-accounts", - "starknet-core 0.5.1", + "starknet-core", "starknet-providers", "thiserror", ] @@ -4232,25 +3667,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91f89c79b641618de8aa9668d74c6b6634659ceca311c6318a35c025f9d4d969" dependencies = [ - "base64 0.21.4", - "flate2", - "hex", - "serde", - "serde_json", - "serde_json_pythonic", - "serde_with 2.3.3", - "sha3", - "starknet-crypto 0.6.0", - "starknet-ff", -] - -[[package]] -name = "starknet-core" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14139b1c39bdc2f1e663c12090ff5108fe50ebe62c09e15e32988dfaf445a7e4" -dependencies = [ - "base64 0.21.4", + "base64 0.21.3", "flate2", "hex", "serde", @@ -4273,7 +3690,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -4293,7 +3710,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -4310,7 +3727,7 @@ checksum = "af6527b845423542c8a16e060ea1bc43f67229848e7cd4c4d80be994a84220ce" dependencies = [ "starknet-curve 0.4.0", "starknet-ff", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -4348,12 +3765,12 @@ dependencies = [ [[package]] name = "starknet-macros" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef846b6bb48fc8c3e9a2aa9b5b037414f04a908d9db56493a3ae69a857eb2506" +checksum = "28a5865ee0ed22ade86bdf45e7c09c5641f1c59ccae12c21ecde535b2b6bf64a" dependencies = [ - "starknet-core 0.6.1", - "syn 2.0.38", + "starknet-core", + "syn 2.0.29", ] [[package]] @@ -4371,7 +3788,7 @@ dependencies = [ "serde", "serde_json", "serde_with 2.3.3", - "starknet-core 0.5.1", + "starknet-core", "thiserror", "url", ] @@ -4387,7 +3804,7 @@ dependencies = [ "clap", "coverage-helper", "mimalloc", - "num-traits 0.2.17", + "num-traits 0.2.16", "serde", "starknet_in_rust", ] @@ -4403,7 +3820,7 @@ dependencies = [ "crypto-bigint", "eth-keystore", "rand", - "starknet-core 0.5.1", + "starknet-core", "starknet-crypto 0.6.0", "thiserror", ] @@ -4432,13 +3849,12 @@ version = "0.4.0" dependencies = [ "anyhow", "assert_matches", - "base64 0.21.4", + "base64 0.21.3", "cairo-lang-casm", "cairo-lang-runner", "cairo-lang-sierra", "cairo-lang-starknet", "cairo-lang-utils", - "cairo-native", "cairo-vm", "coverage-helper", "flate2", @@ -4450,7 +3866,7 @@ dependencies = [ "mimalloc", "num-bigint", "num-integer", - "num-traits 0.2.17", + "num-traits 0.2.16", "once_cell", "pretty_assertions_sorted", "serde", @@ -4461,8 +3877,6 @@ dependencies = [ "starknet-crypto 0.5.1", "starknet_api", "thiserror", - "tracing", - "tracing-subscriber", ] [[package]] @@ -4528,76 +3942,21 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "syntect" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" -dependencies = [ - "bincode 1.3.3", - "bitflags 1.3.2", - "fancy-regex", - "flate2", - "fnv", - "once_cell", - "onig", - "plist", - "regex-syntax 0.7.5", - "serde", - "serde_json", - "thiserror", - "walkdir", - "yaml-rust", -] - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tblgen" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d19c09266feb8b16718d1183044d14703a0b4b59e55ce8beb4d6e21dd066b1b" -dependencies = [ - "bindgen 0.66.1", - "cc", - "paste", - "thiserror", -] - [[package]] name = "tempfile" version = "3.8.0" @@ -4622,69 +3981,59 @@ dependencies = [ "winapi", ] -[[package]] -name = "terminal_size" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" -dependencies = [ - "rustix", - "windows-sys", -] - [[package]] name = "test-case" -version = "3.2.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8f1e820b7f1d95a0cdbf97a5df9de10e1be731983ab943e56703ac1b8e9d425" +checksum = "2a1d6e7bde536b0412f20765b76e921028059adfd1b90d8974d33fd3c91b25df" dependencies = [ "test-case-macros", ] [[package]] name = "test-case-core" -version = "3.2.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c25e2cb8f5fcd7318157634e8838aa6f7e4715c96637f969fabaccd1ef5462" +checksum = "d10394d5d1e27794f772b6fc854c7e91a2dc26e2cbf807ad523370c2a59c0cee" dependencies = [ "cfg-if", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.38", + "syn 1.0.109", ] [[package]] name = "test-case-macros" -version = "3.2.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37cfd7bbc88a0104e304229fba519bdc45501a30b760fb72240342f1289ad257" +checksum = "eeb9a44b1c6a54c1ba58b152797739dba2a83ca74e18168a68c980eb142f9404" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.38", + "syn 1.0.109", "test-case-core", ] [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -4707,16 +4056,6 @@ dependencies = [ "thiserror-impl-no-std", ] -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "time" version = "0.3.26" @@ -4754,16 +4093,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -4781,9 +4110,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ "backtrace", "bytes", @@ -4792,7 +4121,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.3", "tokio-macros", "windows-sys", ] @@ -4805,7 +4134,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] @@ -4820,9 +4149,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -4834,9 +4163,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.8" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -4855,11 +4184,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -4881,21 +4210,9 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-attributes" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "tracing-core" version = "0.1.31" @@ -4903,36 +4220,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", ] [[package]] @@ -4941,17 +4228,11 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "typed-arena" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" - [[package]] name = "typenum" -version = "1.17.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "uint" @@ -4982,9 +4263,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -5007,18 +4288,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "unicode_categories" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" - -[[package]] -name = "unindent" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" - [[package]] name = "untrusted" version = "0.7.1" @@ -5027,20 +4296,20 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "ureq" -version = "2.8.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3" +checksum = "0b11c96ac7ee530603dcdf68ed1557050f374ce55a5a07193ebf8cbc9f8927e9" dependencies = [ - "base64 0.21.4", + "base64 0.21.3", "flate2", "log", "once_cell", "rustls", - "rustls-webpki", + "rustls-webpki 0.100.2", "serde", "serde_json", "url", - "webpki-roots", + "webpki-roots 0.23.1", ] [[package]] @@ -5076,28 +4345,12 @@ dependencies = [ "serde", ] -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "want" version = "0.3.1" @@ -5134,7 +4387,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -5168,7 +4421,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5191,21 +4444,18 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" +dependencies = [ + "rustls-webpki 0.100.2", +] [[package]] -name = "which" -version = "4.4.2" +name = "webpki-roots" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] name = "winapi" @@ -5223,15 +4473,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -5315,9 +4556,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.16" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] @@ -5341,12 +4582,6 @@ dependencies = [ "tap", ] -[[package]] -name = "xdg" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" - [[package]] name = "xshell" version = "0.2.5" @@ -5362,15 +4597,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yansi" version = "0.5.1" @@ -5394,7 +4620,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.29", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c4b08bf43..ccb77a306 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,57 +15,54 @@ metrics = [] members = ["cli", "fuzzer", "rpc_state_reader"] [workspace.dependencies] -cairo-lang-casm = "2.2.0" -cairo-lang-runner = "2.2.0" -cairo-lang-sierra = "2.2.0" -cairo-lang-starknet = "2.2.0" -cairo-lang-utils = "2.2.0" cairo-vm = { version = "0.8.5", features = ["cairo-1-hints"] } +starknet_api = "0.4.1" num-traits = "0.2.15" starknet = "0.5.0" -starknet_api = "0.4.1" thiserror = "1.0.32" +cairo-lang-starknet = "2.1.0-rc4" +cairo-lang-casm = "2.1.0-rc4" +cairo-lang-runner = "2.1.0-rc4" +cairo-lang-sierra = "2.1.0-rc4" +cairo-lang-utils = "2.1.0-rc4" [dependencies] -anyhow = "1.0.66" -base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } +cairo-lang-starknet = { workspace = true } cairo-lang-casm = { workspace = true } cairo-lang-runner = { workspace = true } cairo-lang-sierra = { workspace = true } -cairo-lang-starknet = { workspace = true } cairo-lang-utils = { workspace = true } -cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "03cd09ba3e51852da2234fb32a74056787abba8e", optional = true } cairo-vm = { workspace = true, features = ["cairo-1-hints"] } -flate2 = "1.0.25" getset = "0.1.2" -hex = "0.4.3" -# TODO: Replace with sha3. We should look how to integrate it correctly to calculate sn_keccak -keccak = "0.1.3" lazy_static = "1.4.0" -mimalloc = { version = "0.1.29", default-features = false, optional = true } num-bigint = { version = "0.4", features = ["serde"] } num-integer = "0.1.45" num-traits = { workspace = true } -once_cell = "1.17.1" -sha3 = "0.10.1" serde = { version = "1.0.152", features = ["derive"] } serde_json = { version = "1.0", features = [ "arbitrary_precision", "raw_value", ] } -serde_json_pythonic = "0.1.2" -starknet = { workspace = true } +sha3 = "0.10.1" +# TODO: Replace with sha3. We should look how to integrate it correctly to calculate sn_keccak +keccak = "0.1.3" starknet_api = { workspace = true } starknet-crypto = "0.5.1" thiserror = { workspace = true } -tracing = "0.1.37" +mimalloc = { version = "0.1.29", default-features = false, optional = true } +hex = "0.4.3" +anyhow = "1.0.66" +once_cell = "1.17.1" +starknet = { workspace = true } +base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } +flate2 = "1.0.25" +serde_json_pythonic = "0.1.2" [dev-dependencies] assert_matches = "1.5.0" coverage-helper = "0.2.0" lru = "0.11.0" pretty_assertions_sorted = "1.2.3" -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } [[bench]] path = "bench/internals.rs" diff --git a/Makefile b/Makefile index 61183ab26..689a4695b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: usage build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \ +.PHONY: build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \ compile-cairo-2-casm compile-cairo-2-sierra coverage deps test heaptrack check-python-version export PATH:=$(shell pyenv root)/shims:$(PATH) @@ -10,6 +10,7 @@ ifeq ($(OS), Darwin) export LDFLAGS += -L/opt/homebrew/opt/gmp/lib endif + CAIRO_SOURCES=$(wildcard cairo_programs/*.cairo) CAIRO_TARGETS=$(patsubst %.cairo,%.json,$(CAIRO_SOURCES)) CAIRO_ABI_TARGETS=$(patsubst %.cairo,%_abi.json,$(CAIRO_SOURCES)) @@ -27,24 +28,6 @@ STARKNET_SIERRA_COMPILE_CAIRO_1:=cairo1/bin/starknet-sierra-compile STARKNET_COMPILE_CAIRO_2:=cairo2/bin/starknet-compile STARKNET_SIERRA_COMPILE_CAIRO_2:=cairo2/bin/starknet-sierra-compile -usage: - @echo 'Usage:' - @echo ' build: Builds the Rust code' - @echo ' check: Runs cargo check' - @echo ' deps: Installs dependencies' - @echo ' deps-macos: Installs depedencies for MacOS' - @echo ' clean: Cleans all build artifacts' - @echo ' clippy: Runs clippy' - @echo ' test: Runs all tests' - @echo ' test-cairo-1: Runs the Cairo 1 tests' - @echo ' test-cairo-2: Runs the Cairo 2 tests' - @echo ' test-doctests: Runs the doctests' - @echo ' coverage: Runs everything necessary to generate the coverage report' - @echo ' coverage-report: Just generates the coverage report' - @echo ' heaptrack: Runs the heaptrack script' - @echo ' flamegraph: Runs cargo flamegraph' - @echo ' benchmark: Runs the benchmarks scripts' - # # VENV rules. # @@ -115,7 +98,7 @@ CAIRO_2_COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.ca CAIRO_2_COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm, $(CAIRO_2_COMPILED_SIERRA_CONTRACTS)) $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.cairo - $(STARKNET_COMPILE_CAIRO_2) --single-file $< $@ --replace-ids + $(STARKNET_COMPILE_CAIRO_2) $< $@ $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra $(STARKNET_SIERRA_COMPILE_CAIRO_2) --add-pythonic-hints $< $@ @@ -123,7 +106,8 @@ $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra compile-cairo-2-sierra: $(CAIRO_2_COMPILED_SIERRA_CONTRACTS) compile-cairo-2-casm: $(CAIRO_2_COMPILED_CASM_CONTRACTS) -CAIRO_2_VERSION=2.2.0 + +CAIRO_2_VERSION=2.0.1 cairo-repo-2-dir = cairo2 cairo-repo-2-dir-macos = cairo2-macos @@ -149,21 +133,20 @@ cairo-%-macos.tar: cairo-%.tar: curl -L -o "$@" "https://github.com/starkware-libs/cairo/releases/download/v$*/release-x86_64-unknown-linux-musl.tar.gz" + # ================= # Normal rules. # ================= -build: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra +build: compile-cairo compile-starknet cargo build --release --workspace -check: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra +check: compile-cairo compile-starknet cargo check --workspace --all-targets deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler cargo install flamegraph --version 0.6.2 cargo install cargo-llvm-cov --version 0.5.14 - -pyenv && pyenv install -s pypy3.9-7.3.9 - -pyenv && pyenv install -s 3.9.15 python3.9 -m venv starknet-venv . starknet-venv/bin/activate && $(MAKE) deps-venv cargo install cargo-nextest --version 0.9.49 @@ -171,8 +154,6 @@ deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-compiler-macos cargo install flamegraph --version 0.6.2 cargo install cargo-llvm-cov --version 0.5.14 - -pyenv install -s pypy3.9-7.3.9 - -pyenv install -s 3.9.15 python3.9 -m venv starknet-venv . starknet-venv/bin/activate && $(MAKE) deps-venv cargo install cargo-nextest @@ -192,8 +173,8 @@ clean: -rm -rf cairo2/ -rm -rf cairo-*.tar -clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra - cargo clippy --workspace --all-targets --all-features -- -D warnings +clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm + cargo clippy --workspace --all-targets -- -D warnings test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra echo "Cairo1 tests" @@ -201,14 +182,11 @@ test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra echo "Cairo2 tests" $(MAKE) test-cairo-2 -test-cairo-1: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra - cargo nextest run --workspace --all-targets --features=cairo_1_tests,metrics - -test-cairo-2: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra - cargo nextest run --workspace --all-targets --features=metrics +test-cairo-1: + cargo nextest run --workspace --all-targets --features=cairo_1_tests -test-cairo-native: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra - cargo nextest run --workspace --test cairo_native --features=cairo-native +test-cairo-2: + cargo nextest run --workspace --all-targets test-doctests: cargo test --workspace --doc @@ -216,7 +194,7 @@ test-doctests: coverage: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm $(MAKE) coverage-report -coverage-report: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra +coverage-report: cargo +nightly llvm-cov nextest --lcov --ignore-filename-regex 'main.rs' --output-path lcov.info --release heaptrack: diff --git a/README.md b/README.md index 43ce64184..b90b9f1e5 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,6 @@ It makes use of [cairo-vm](https://github.com/lambdaclass/cairo-vm), the Rust im ### Installation -If you run `make` on it's own it will print out the main targets and their description. - Run the following make targets to have a working environment (if in Mac or if you encounter an error, see the subsection below): #### Linux (x86-64) @@ -100,19 +98,7 @@ In Mac you'll also need to tell the script where to find the gmp lib: export CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib ``` -### Cairo Native support - -Starknet in Rust can be integrated with [Cairo Native](https://github.com/lambdaclass/cairo_native), which makes the execution of sierra programs possible through native machine code. To use it, the following needs to be setup: - -- LLVM `17` needs to be installed and the `MLIR_SYS_170_PREFIX` and `TABLEGEN_170_PREFIX` environment variable needs to point to said installation. In macOS, run - ``` - brew install llvm@17 - export MLIR_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17 - export TABLEGEN_170_PREFIX=/opt/homebrew/opt/llvm@17 - ``` - and you're set. -Afterwards, compiling with the feature flag `cairo-native` will enable native execution. You can check out some example test code that uses it under `tests/cairo_native.rs`. ## 🚀 Usage @@ -123,6 +109,7 @@ You can find a tutorial on running contracts [here](/examples/contract_execution ### Using the CLI You can find an example on how to use the CLI [here](/docs/CLI_USAGE_EXAMPLE.md) + ### Customization #### Contract class cache behavior @@ -166,11 +153,6 @@ cache.extend(state1.state.drain_private_contract_class_cache()); cache.extend(state2.state.drain_private_contract_class_cache()); ``` -#### Logging configuration - -This project uses the [`tracing`](https://crates.io/crates/tracing) crate as a library. Check out -its documentation for more information. - ### Testing [Add an Infura API key.](#rpc-state-reader) diff --git a/bench/internals.rs b/bench/internals.rs index bc64f8075..abb10cd2e 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -81,7 +81,7 @@ fn deploy_account() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut state_copy = state.clone_for_testing(); + let mut state_copy = state.clone(); let class_hash = *CLASS_HASH_BYTES; let signature = SIGNATURE.clone(); scope(|| { @@ -116,7 +116,7 @@ fn declare() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut cloned_state = state.clone_for_testing(); + let mut cloned_state = state.clone(); let class = CONTRACT_CLASS.clone(); let address = CONTRACT_ADDRESS.clone(); scope(|| { @@ -158,7 +158,7 @@ fn deploy() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut state_copy = state.clone_for_testing(); + let mut state_copy = state.clone(); let salt = felt_str!( "2669425616857739096022668060305620640217901643963991674344872184515580705509" ); @@ -213,7 +213,7 @@ fn invoke() { let _deploy_exec_info = deploy.execute(&mut state, block_context).unwrap(); for _ in 0..RUNS { - let mut state_copy = state.clone_for_testing(); + let mut state_copy = state.clone(); let address = CONTRACT_ADDRESS.clone(); let selector = VALIDATE_ENTRY_POINT_SELECTOR.clone(); let signature = SIGNATURE.clone(); diff --git a/cairo_programs/erc20.sierra b/cairo_programs/erc20.sierra deleted file mode 100644 index d7a57bf24..000000000 --- a/cairo_programs/erc20.sierra +++ /dev/null @@ -1,5012 +0,0 @@ -type RangeCheck = RangeCheck; -type GasBuiltin = GasBuiltin; -type felt252 = felt252; -type Array = Array; -type Snapshot> = Snapshot>; -type core::array::Span:: = Struct>>; -type u32 = u32; -type core::panics::Panic = Struct; -type Tuple> = Struct>; -type Tuple> = Struct>; -type core::panics::PanicResult::<(core::array::Span::,)> = Enum>, Tuple>>; -type System = System; -type BuiltinCosts = BuiltinCosts; -type erc20::erc20::erc_20::name::ContractState = Struct; -type erc20::erc20::erc_20::symbol::ContractState = Struct; -type erc20::erc20::erc_20::decimals::ContractState = Struct; -type erc20::erc20::erc_20::total_supply::ContractState = Struct; -type erc20::erc20::erc_20::balances::ContractState = Struct; -type erc20::erc20::erc_20::allowances::ContractState = Struct; -type erc20::erc20::erc_20::ContractState = Struct; -type Tuple = Struct; -type core::panics::PanicResult::<(core::felt252,)> = Enum, Tuple>>; -type Unit = Struct; -type u8 = u8; -type Tuple = Struct; -type core::panics::PanicResult::<(core::integer::u8,)> = Enum, Tuple>>; -type u128 = u128; -type core::integer::u256 = Struct; -type Tuple = Struct; -type core::panics::PanicResult::<(core::integer::u256,)> = Enum, Tuple>>; -type ContractAddress = ContractAddress; -type core::option::Option:: = Enum; -type Pedersen = Pedersen; -type core::option::Option:: = Enum; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())> = Enum, Tuple>>; -type core::option::Option:: = Enum; -type core::option::Option:: = Enum; -type Tuple = Struct; -type core::option::Option:: = Enum; -type Tuple = Struct; -type core::panics::PanicResult::<(core::starknet::contract_address::ContractAddress,)> = Enum, Tuple>>; -type Box = Box; -type core::option::Option::> = Enum, Unit>; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::name::ContractState, ())> = Enum, Tuple>>; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::symbol::ContractState, ())> = Enum, Tuple>>; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::decimals::ContractState, ())> = Enum, Tuple>>; -type NonZero = NonZero; -type core::bool = Enum; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::total_supply::ContractState, ())> = Enum, Tuple>>; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::balances::ContractState, ())> = Enum, Tuple>>; -type erc20::erc20::erc_20::Transfer = Struct; -type erc20::erc20::erc_20::Approval = Struct; -type erc20::erc20::erc_20::Event = Enum; -type StorageBaseAddress = StorageBaseAddress; -type StorageAddress = StorageAddress; -type core::result::Result::> = Enum>; -type core::result::Result::> = Enum>; -type Tuple>> = Struct>>; -type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; -type core::result::Result::> = Enum>; -type Tuple>> = Struct>>; -type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; -type u64 = u64; -type core::starknet::info::BlockInfo = Struct; -type Box = Box; -type core::starknet::info::TxInfo = Struct, felt252, felt252, felt252>; -type Box = Box; -type core::starknet::info::ExecutionInfo = Struct, Box, ContractAddress, ContractAddress, felt252>; -type Box = Box; -type Tuple> = Struct>; -type core::panics::PanicResult::<(core::box::Box::,)> = Enum>, Tuple>>; -type Tuple = Struct; -type core::panics::PanicResult::<(erc20::erc20::erc_20::allowances::ContractState, ())> = Enum, Tuple>>; -type core::result::Result::<(), core::array::Array::> = Enum>; -type Tuple = Struct; -type core::panics::PanicResult::<((),)> = Enum, Tuple>>; -type core::result::Result::> = Enum>; -type Tuple>> = Struct>>; -type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; -type core::result::Result::, core::array::Array::> = Enum, Array>; -type Tuple = Struct; -type Tuple = Struct; - -libfunc revoke_ap_tracking = revoke_ap_tracking; -libfunc withdraw_gas = withdraw_gas; -libfunc branch_align = branch_align; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc array_len = array_len; -libfunc snapshot_take = snapshot_take; -libfunc drop = drop; -libfunc u32_const<0> = u32_const<0>; -libfunc rename = rename; -libfunc store_temp = store_temp; -libfunc store_temp = store_temp; -libfunc u32_eq = u32_eq; -libfunc array_new = array_new; -libfunc felt252_const<7733229381460288120802334208475838166080759535023995805565484692595> = felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>; -libfunc store_temp = store_temp; -libfunc array_append = array_append; -libfunc struct_construct = struct_construct; -libfunc struct_construct>> = struct_construct>>; -libfunc enum_init,)>, 1> = enum_init,)>, 1>; -libfunc store_temp = store_temp; -libfunc store_temp = store_temp; -libfunc store_temp,)>> = store_temp,)>>; -libfunc get_builtin_costs = get_builtin_costs; -libfunc store_temp = store_temp; -libfunc withdraw_gas_all = withdraw_gas_all; -libfunc struct_construct = struct_construct; -libfunc struct_construct = struct_construct; -libfunc struct_construct = struct_construct; -libfunc struct_construct = struct_construct; -libfunc struct_construct = struct_construct; -libfunc struct_construct = struct_construct; -libfunc struct_construct = struct_construct; -libfunc snapshot_take = snapshot_take; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc snapshot_take = snapshot_take; -libfunc drop = drop; -libfunc store_temp> = store_temp>; -libfunc function_call = function_call; -libfunc drop = drop; -libfunc snapshot_take> = snapshot_take>; -libfunc drop> = drop>; -libfunc struct_construct> = struct_construct>; -libfunc struct_construct>> = struct_construct>>; -libfunc enum_init,)>, 0> = enum_init,)>, 0>; -libfunc felt252_const<375233589013918064796019> = felt252_const<375233589013918064796019>; -libfunc drop> = drop>; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc snapshot_take = snapshot_take; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc snapshot_take = snapshot_take; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc store_temp> = store_temp>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>; -libfunc function_call = function_call; -libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc drop> = drop>; -libfunc function_call = function_call; -libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc function_call = function_call; -libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917>; -libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916>; -libfunc struct_deconstruct = struct_deconstruct; -libfunc drop = drop; -libfunc drop = drop; -libfunc drop = drop; -libfunc drop = drop; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc rename = rename; -libfunc struct_construct = struct_construct; -libfunc store_temp = store_temp; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc rename = rename; -libfunc u8_to_felt252 = u8_to_felt252; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc dup = dup; -libfunc struct_deconstruct = struct_deconstruct; -libfunc drop = drop; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc rename> = rename>; -libfunc rename = rename; -libfunc contract_address_try_from_felt252 = contract_address_try_from_felt252; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc struct_construct> = struct_construct>; -libfunc store_temp = store_temp; -libfunc store_temp> = store_temp>; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc struct_construct = struct_construct; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc function_call = function_call; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc dup = dup; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc snapshot_take = snapshot_take; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc array_snapshot_pop_front = array_snapshot_pop_front; -libfunc enum_init>, 0> = enum_init>, 0>; -libfunc store_temp>> = store_temp>>; -libfunc store_temp>> = store_temp>>; -libfunc jump = jump; -libfunc enum_init>, 1> = enum_init>, 1>; -libfunc enum_match>> = enum_match>>; -libfunc unbox = unbox; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call = function_call; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc contract_address_to_felt252 = contract_address_to_felt252; -libfunc felt252_const<0> = felt252_const<0>; -libfunc felt252_sub = felt252_sub; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc felt252_is_zero = felt252_is_zero; -libfunc enum_init = enum_init; -libfunc store_temp = store_temp; -libfunc drop> = drop>; -libfunc enum_init = enum_init; -libfunc bool_not_impl = bool_not_impl; -libfunc enum_match = enum_match; -libfunc felt252_const<7300388948442106731950660484798539862217172507820428101544021685107> = felt252_const<7300388948442106731950660484798539862217172507820428101544021685107>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc contract_address_const<0> = contract_address_const<0>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_construct = struct_construct; -libfunc enum_init = enum_init; -libfunc store_temp = store_temp; -libfunc function_call>> = function_call>>; -libfunc drop> = drop>; -libfunc drop> = drop>; -libfunc drop> = drop>; -libfunc storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336> = storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>; -libfunc storage_address_from_base = storage_address_from_base; -libfunc store_temp = store_temp; -libfunc storage_read_syscall = storage_read_syscall; -libfunc enum_init>, 0> = enum_init>, 0>; -libfunc store_temp>> = store_temp>>; -libfunc enum_init>, 1> = enum_init>, 1>; -libfunc rename>> = rename>>; -libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; -libfunc storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028> = storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>; -libfunc storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321> = storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>; -libfunc store_temp = store_temp; -libfunc function_call = function_call; -libfunc enum_match>,)>> = enum_match>,)>>; -libfunc struct_deconstruct>>> = struct_deconstruct>>>; -libfunc store_temp>> = store_temp>>; -libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; -libfunc storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646> = storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>; -libfunc function_call = function_call; -libfunc enum_match>,)>> = enum_match>,)>>; -libfunc struct_deconstruct>>> = struct_deconstruct>>>; -libfunc store_temp>> = store_temp>>; -libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; -libfunc rename = rename; -libfunc u128_to_felt252 = u128_to_felt252; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call = function_call; -libfunc enum_match,)>> = enum_match,)>>; -libfunc struct_deconstruct>> = struct_deconstruct>>; -libfunc unbox = unbox; -libfunc struct_deconstruct = struct_deconstruct; -libfunc drop> = drop>; -libfunc drop> = drop>; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc felt252_const<25936191677694277552149992725516921697451103245639728> = felt252_const<25936191677694277552149992725516921697451103245639728>; -libfunc felt252_const<395754877894504967531585582359572169455970492464> = felt252_const<395754877894504967531585582359572169455970492464>; -libfunc snapshot_take = snapshot_take; -libfunc store_temp = store_temp; -libfunc function_call> = function_call>; -libfunc u128_const<340282366920938463463374607431768211455> = u128_const<340282366920938463463374607431768211455>; -libfunc snapshot_take = snapshot_take; -libfunc u128_eq = u128_eq; -libfunc felt252_const<101313248740993271302566317381896466254801065025584> = felt252_const<101313248740993271302566317381896466254801065025584>; -libfunc function_call = function_call; -libfunc enum_match> = enum_match>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_construct = struct_construct; -libfunc store_temp = store_temp; -libfunc function_call> = function_call>; -libfunc function_call = function_call; -libfunc felt252_const<39879774624079483812136948410799859986295> = felt252_const<39879774624079483812136948410799859986295>; -libfunc function_call = function_call; -libfunc felt252_const<39879774624085075084607933104993585622903> = felt252_const<39879774624085075084607933104993585622903>; -libfunc u8_try_from_felt252 = u8_try_from_felt252; -libfunc rename = rename; -libfunc rename> = rename>; -libfunc snapshot_take = snapshot_take; -libfunc storage_write_syscall = storage_write_syscall; -libfunc enum_init>, 0> = enum_init>, 0>; -libfunc store_temp>> = store_temp>>; -libfunc enum_init>, 1> = enum_init>, 1>; -libfunc rename>> = rename>>; -libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; -libfunc enum_match> = enum_match>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc snapshot_take = snapshot_take; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc snapshot_take = snapshot_take; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call = function_call; -libfunc snapshot_take = snapshot_take; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call::into> = function_call::into>; -libfunc snapshot_take = snapshot_take; -libfunc drop = drop; -libfunc function_call = function_call; -libfunc emit_event_syscall = emit_event_syscall; -libfunc enum_match>> = enum_match>>; -libfunc enum_init>, 0> = enum_init>, 0>; -libfunc struct_construct>>> = struct_construct>>>; -libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; -libfunc store_temp>,)>> = store_temp>,)>>; -libfunc felt252_const<110930490496575599150170734222081291576> = felt252_const<110930490496575599150170734222081291576>; -libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; -libfunc enum_init>, 1> = enum_init>, 1>; -libfunc enum_match>> = enum_match>>; -libfunc dup = dup; -libfunc dup = dup; -libfunc function_call = function_call; -libfunc enum_match>,)>> = enum_match>,)>>; -libfunc struct_deconstruct>>> = struct_deconstruct>>>; -libfunc enum_match>> = enum_match>>; -libfunc u8_const<1> = u8_const<1>; -libfunc storage_address_from_base_and_offset = storage_address_from_base_and_offset; -libfunc enum_init>, 0> = enum_init>, 0>; -libfunc struct_construct>>> = struct_construct>>>; -libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; -libfunc store_temp>,)>> = store_temp>,)>>; -libfunc felt252_const<476442828812030857794232422692155113556837216824> = felt252_const<476442828812030857794232422692155113556837216824>; -libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; -libfunc enum_init>, 1> = enum_init>, 1>; -libfunc drop = drop; -libfunc enum_match>> = enum_match>>; -libfunc felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564> = felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564>; -libfunc function_call = function_call; -libfunc storage_base_address_from_felt252 = storage_base_address_from_felt252; -libfunc felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719> = felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719>; -libfunc function_call::hash> = function_call::hash>; -libfunc u128s_from_felt252 = u128s_from_felt252; -libfunc rename> = rename>; -libfunc get_execution_info_syscall = get_execution_info_syscall; -libfunc enum_init, core::array::Array::>, 0> = enum_init, core::array::Array::>, 0>; -libfunc store_temp, core::array::Array::>> = store_temp, core::array::Array::>>; -libfunc enum_init, core::array::Array::>, 1> = enum_init, core::array::Array::>, 1>; -libfunc rename, core::array::Array::>> = rename, core::array::Array::>>; -libfunc function_call>::unwrap_syscall> = function_call>::unwrap_syscall>; -libfunc struct_construct>> = struct_construct>>; -libfunc enum_init,)>, 0> = enum_init,)>, 0>; -libfunc store_temp,)>> = store_temp,)>>; -libfunc enum_init,)>, 1> = enum_init,)>, 1>; -libfunc function_call = function_call; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc function_call = function_call; -libfunc function_call = function_call; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc function_call = function_call; -libfunc enum_match>> = enum_match>>; -libfunc struct_construct> = struct_construct>; -libfunc enum_init, 0> = enum_init, 0>; -libfunc store_temp> = store_temp>; -libfunc enum_init, 1> = enum_init, 1>; -libfunc enum_match = enum_match; -libfunc felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697> = felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697>; -libfunc function_call = function_call; -libfunc felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999> = felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999>; -libfunc function_call = function_call; -libfunc enum_init>, 0> = enum_init>, 0>; -libfunc struct_construct>>> = struct_construct>>>; -libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; -libfunc store_temp>,)>> = store_temp>,)>>; -libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; -libfunc enum_init>, 1> = enum_init>, 1>; -libfunc pedersen = pedersen; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc rename = rename; -libfunc enum_match, core::array::Array::>> = enum_match, core::array::Array::>>; -libfunc enum_init = enum_init; -libfunc u128_overflowing_add = u128_overflowing_add; -libfunc struct_construct> = struct_construct>; -libfunc store_temp> = store_temp>; -libfunc struct_deconstruct> = struct_deconstruct>; -libfunc struct_construct> = struct_construct>; -libfunc store_temp> = store_temp>; -libfunc u128_const<1> = u128_const<1>; -libfunc drop = drop; -libfunc rename> = rename>; -libfunc u128_overflowing_sub = u128_overflowing_sub; -libfunc dup = dup; -libfunc struct_deconstruct = struct_deconstruct; -libfunc function_call = function_call; -libfunc dup = dup; -libfunc struct_deconstruct = struct_deconstruct; -libfunc rename = rename; - -revoke_ap_tracking() -> (); -withdraw_gas([0], [1]) { fallthrough([4], [5]) 87([6], [7]) }; -branch_align() -> (); -struct_deconstruct>([3]) -> ([8]); -array_len([8]) -> ([9]); -snapshot_take([9]) -> ([10], [11]); -drop([10]) -> (); -u32_const<0>() -> ([12]); -snapshot_take([12]) -> ([13], [14]); -drop([13]) -> (); -rename([11]) -> ([15]); -rename([14]) -> ([16]); -store_temp([15]) -> ([15]); -store_temp([4]) -> ([4]); -u32_eq([15], [16]) { fallthrough() 28() }; -branch_align() -> (); -array_new() -> ([17]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); -store_temp([18]) -> ([18]); -array_append([17], [18]) -> ([19]); -struct_construct() -> ([20]); -struct_construct>>([20], [19]) -> ([21]); -enum_init,)>, 1>([21]) -> ([22]); -store_temp([4]) -> ([23]); -store_temp([5]) -> ([24]); -store_temp([2]) -> ([25]); -store_temp,)>>([22]) -> ([26]); -return([23], [24], [25], [26]); -branch_align() -> (); -get_builtin_costs() -> ([27]); -store_temp([27]) -> ([27]); -withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 74([30], [31]) }; -branch_align() -> (); -struct_construct() -> ([32]); -struct_construct() -> ([33]); -struct_construct() -> ([34]); -struct_construct() -> ([35]); -struct_construct() -> ([36]); -struct_construct() -> ([37]); -struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); -snapshot_take([38]) -> ([39], [40]); -drop([39]) -> (); -store_temp([29]) -> ([44]); -store_temp([2]) -> ([45]); -store_temp([40]) -> ([46]); -function_call([44], [45], [46]) -> ([41], [42], [43]); -store_temp([28]) -> ([28]); -enum_match>([43]) { fallthrough([47]) 67([48]) }; -branch_align() -> (); -array_new() -> ([49]); -struct_deconstruct>([47]) -> ([50]); -snapshot_take([50]) -> ([51], [52]); -drop([51]) -> (); -store_temp([52]) -> ([55]); -store_temp>([49]) -> ([56]); -function_call([55], [56]) -> ([53], [54]); -drop([54]) -> (); -snapshot_take>([53]) -> ([57], [58]); -drop>([57]) -> (); -struct_construct>([58]) -> ([59]); -struct_construct>>([59]) -> ([60]); -enum_init,)>, 0>([60]) -> ([61]); -store_temp([28]) -> ([62]); -store_temp([41]) -> ([63]); -store_temp([42]) -> ([64]); -store_temp,)>>([61]) -> ([65]); -return([62], [63], [64], [65]); -branch_align() -> (); -enum_init,)>, 1>([48]) -> ([66]); -store_temp([28]) -> ([67]); -store_temp([41]) -> ([68]); -store_temp([42]) -> ([69]); -store_temp,)>>([66]) -> ([70]); -return([67], [68], [69], [70]); -branch_align() -> (); -array_new() -> ([71]); -felt252_const<375233589013918064796019>() -> ([72]); -store_temp([72]) -> ([72]); -array_append([71], [72]) -> ([73]); -struct_construct() -> ([74]); -struct_construct>>([74], [73]) -> ([75]); -enum_init,)>, 1>([75]) -> ([76]); -store_temp([30]) -> ([77]); -store_temp([31]) -> ([78]); -store_temp([2]) -> ([79]); -store_temp,)>>([76]) -> ([80]); -return([77], [78], [79], [80]); -branch_align() -> (); -drop>([3]) -> (); -array_new() -> ([81]); -felt252_const<375233589013918064796019>() -> ([82]); -store_temp([82]) -> ([82]); -array_append([81], [82]) -> ([83]); -struct_construct() -> ([84]); -struct_construct>>([84], [83]) -> ([85]); -enum_init,)>, 1>([85]) -> ([86]); -store_temp([6]) -> ([87]); -store_temp([7]) -> ([88]); -store_temp([2]) -> ([89]); -store_temp,)>>([86]) -> ([90]); -return([87], [88], [89], [90]); -revoke_ap_tracking() -> (); -withdraw_gas([0], [1]) { fallthrough([4], [5]) 188([6], [7]) }; -branch_align() -> (); -struct_deconstruct>([3]) -> ([8]); -array_len([8]) -> ([9]); -snapshot_take([9]) -> ([10], [11]); -drop([10]) -> (); -u32_const<0>() -> ([12]); -snapshot_take([12]) -> ([13], [14]); -drop([13]) -> (); -rename([11]) -> ([15]); -rename([14]) -> ([16]); -store_temp([15]) -> ([15]); -store_temp([4]) -> ([4]); -u32_eq([15], [16]) { fallthrough() 129() }; -branch_align() -> (); -array_new() -> ([17]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); -store_temp([18]) -> ([18]); -array_append([17], [18]) -> ([19]); -struct_construct() -> ([20]); -struct_construct>>([20], [19]) -> ([21]); -enum_init,)>, 1>([21]) -> ([22]); -store_temp([4]) -> ([23]); -store_temp([5]) -> ([24]); -store_temp([2]) -> ([25]); -store_temp,)>>([22]) -> ([26]); -return([23], [24], [25], [26]); -branch_align() -> (); -get_builtin_costs() -> ([27]); -store_temp([27]) -> ([27]); -withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 175([30], [31]) }; -branch_align() -> (); -struct_construct() -> ([32]); -struct_construct() -> ([33]); -struct_construct() -> ([34]); -struct_construct() -> ([35]); -struct_construct() -> ([36]); -struct_construct() -> ([37]); -struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); -snapshot_take([38]) -> ([39], [40]); -drop([39]) -> (); -store_temp([29]) -> ([44]); -store_temp([2]) -> ([45]); -store_temp([40]) -> ([46]); -function_call([44], [45], [46]) -> ([41], [42], [43]); -store_temp([28]) -> ([28]); -enum_match>([43]) { fallthrough([47]) 168([48]) }; -branch_align() -> (); -array_new() -> ([49]); -struct_deconstruct>([47]) -> ([50]); -snapshot_take([50]) -> ([51], [52]); -drop([51]) -> (); -store_temp([52]) -> ([55]); -store_temp>([49]) -> ([56]); -function_call([55], [56]) -> ([53], [54]); -drop([54]) -> (); -snapshot_take>([53]) -> ([57], [58]); -drop>([57]) -> (); -struct_construct>([58]) -> ([59]); -struct_construct>>([59]) -> ([60]); -enum_init,)>, 0>([60]) -> ([61]); -store_temp([28]) -> ([62]); -store_temp([41]) -> ([63]); -store_temp([42]) -> ([64]); -store_temp,)>>([61]) -> ([65]); -return([62], [63], [64], [65]); -branch_align() -> (); -enum_init,)>, 1>([48]) -> ([66]); -store_temp([28]) -> ([67]); -store_temp([41]) -> ([68]); -store_temp([42]) -> ([69]); -store_temp,)>>([66]) -> ([70]); -return([67], [68], [69], [70]); -branch_align() -> (); -array_new() -> ([71]); -felt252_const<375233589013918064796019>() -> ([72]); -store_temp([72]) -> ([72]); -array_append([71], [72]) -> ([73]); -struct_construct() -> ([74]); -struct_construct>>([74], [73]) -> ([75]); -enum_init,)>, 1>([75]) -> ([76]); -store_temp([30]) -> ([77]); -store_temp([31]) -> ([78]); -store_temp([2]) -> ([79]); -store_temp,)>>([76]) -> ([80]); -return([77], [78], [79], [80]); -branch_align() -> (); -drop>([3]) -> (); -array_new() -> ([81]); -felt252_const<375233589013918064796019>() -> ([82]); -store_temp([82]) -> ([82]); -array_append([81], [82]) -> ([83]); -struct_construct() -> ([84]); -struct_construct>>([84], [83]) -> ([85]); -enum_init,)>, 1>([85]) -> ([86]); -store_temp([6]) -> ([87]); -store_temp([7]) -> ([88]); -store_temp([2]) -> ([89]); -store_temp,)>>([86]) -> ([90]); -return([87], [88], [89], [90]); -revoke_ap_tracking() -> (); -withdraw_gas([0], [1]) { fallthrough([4], [5]) 289([6], [7]) }; -branch_align() -> (); -struct_deconstruct>([3]) -> ([8]); -array_len([8]) -> ([9]); -snapshot_take([9]) -> ([10], [11]); -drop([10]) -> (); -u32_const<0>() -> ([12]); -snapshot_take([12]) -> ([13], [14]); -drop([13]) -> (); -rename([11]) -> ([15]); -rename([14]) -> ([16]); -store_temp([15]) -> ([15]); -store_temp([4]) -> ([4]); -u32_eq([15], [16]) { fallthrough() 230() }; -branch_align() -> (); -array_new() -> ([17]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); -store_temp([18]) -> ([18]); -array_append([17], [18]) -> ([19]); -struct_construct() -> ([20]); -struct_construct>>([20], [19]) -> ([21]); -enum_init,)>, 1>([21]) -> ([22]); -store_temp([4]) -> ([23]); -store_temp([5]) -> ([24]); -store_temp([2]) -> ([25]); -store_temp,)>>([22]) -> ([26]); -return([23], [24], [25], [26]); -branch_align() -> (); -get_builtin_costs() -> ([27]); -store_temp([27]) -> ([27]); -withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 276([30], [31]) }; -branch_align() -> (); -struct_construct() -> ([32]); -struct_construct() -> ([33]); -struct_construct() -> ([34]); -struct_construct() -> ([35]); -struct_construct() -> ([36]); -struct_construct() -> ([37]); -struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); -snapshot_take([38]) -> ([39], [40]); -drop([39]) -> (); -store_temp([28]) -> ([45]); -store_temp([29]) -> ([46]); -store_temp([2]) -> ([47]); -store_temp([40]) -> ([48]); -function_call([45], [46], [47], [48]) -> ([41], [42], [43], [44]); -enum_match>([44]) { fallthrough([49]) 269([50]) }; -branch_align() -> (); -array_new() -> ([51]); -struct_deconstruct>([49]) -> ([52]); -snapshot_take([52]) -> ([53], [54]); -drop([53]) -> (); -store_temp([54]) -> ([57]); -store_temp>([51]) -> ([58]); -function_call([57], [58]) -> ([55], [56]); -drop([56]) -> (); -snapshot_take>([55]) -> ([59], [60]); -drop>([59]) -> (); -struct_construct>([60]) -> ([61]); -struct_construct>>([61]) -> ([62]); -enum_init,)>, 0>([62]) -> ([63]); -store_temp([41]) -> ([64]); -store_temp([42]) -> ([65]); -store_temp([43]) -> ([66]); -store_temp,)>>([63]) -> ([67]); -return([64], [65], [66], [67]); -branch_align() -> (); -enum_init,)>, 1>([50]) -> ([68]); -store_temp([41]) -> ([69]); -store_temp([42]) -> ([70]); -store_temp([43]) -> ([71]); -store_temp,)>>([68]) -> ([72]); -return([69], [70], [71], [72]); -branch_align() -> (); -array_new() -> ([73]); -felt252_const<375233589013918064796019>() -> ([74]); -store_temp([74]) -> ([74]); -array_append([73], [74]) -> ([75]); -struct_construct() -> ([76]); -struct_construct>>([76], [75]) -> ([77]); -enum_init,)>, 1>([77]) -> ([78]); -store_temp([30]) -> ([79]); -store_temp([31]) -> ([80]); -store_temp([2]) -> ([81]); -store_temp,)>>([78]) -> ([82]); -return([79], [80], [81], [82]); -branch_align() -> (); -drop>([3]) -> (); -array_new() -> ([83]); -felt252_const<375233589013918064796019>() -> ([84]); -store_temp([84]) -> ([84]); -array_append([83], [84]) -> ([85]); -struct_construct() -> ([86]); -struct_construct>>([86], [85]) -> ([87]); -enum_init,)>, 1>([87]) -> ([88]); -store_temp([6]) -> ([89]); -store_temp([7]) -> ([90]); -store_temp([2]) -> ([91]); -store_temp,)>>([88]) -> ([92]); -return([89], [90], [91], [92]); -revoke_ap_tracking() -> (); -withdraw_gas([0], [1]) { fallthrough([4], [5]) 390([6], [7]) }; -branch_align() -> (); -struct_deconstruct>([3]) -> ([8]); -array_len([8]) -> ([9]); -snapshot_take([9]) -> ([10], [11]); -drop([10]) -> (); -u32_const<0>() -> ([12]); -snapshot_take([12]) -> ([13], [14]); -drop([13]) -> (); -rename([11]) -> ([15]); -rename([14]) -> ([16]); -store_temp([15]) -> ([15]); -store_temp([4]) -> ([4]); -u32_eq([15], [16]) { fallthrough() 331() }; -branch_align() -> (); -array_new() -> ([17]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); -store_temp([18]) -> ([18]); -array_append([17], [18]) -> ([19]); -struct_construct() -> ([20]); -struct_construct>>([20], [19]) -> ([21]); -enum_init,)>, 1>([21]) -> ([22]); -store_temp([4]) -> ([23]); -store_temp([5]) -> ([24]); -store_temp([2]) -> ([25]); -store_temp,)>>([22]) -> ([26]); -return([23], [24], [25], [26]); -branch_align() -> (); -get_builtin_costs() -> ([27]); -store_temp([27]) -> ([27]); -withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 377([30], [31]) }; -branch_align() -> (); -struct_construct() -> ([32]); -struct_construct() -> ([33]); -struct_construct() -> ([34]); -struct_construct() -> ([35]); -struct_construct() -> ([36]); -struct_construct() -> ([37]); -struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); -snapshot_take([38]) -> ([39], [40]); -drop([39]) -> (); -store_temp([28]) -> ([45]); -store_temp([29]) -> ([46]); -store_temp([2]) -> ([47]); -store_temp([40]) -> ([48]); -function_call([45], [46], [47], [48]) -> ([41], [42], [43], [44]); -enum_match>([44]) { fallthrough([49]) 370([50]) }; -branch_align() -> (); -array_new() -> ([51]); -struct_deconstruct>([49]) -> ([52]); -snapshot_take([52]) -> ([53], [54]); -drop([53]) -> (); -store_temp([54]) -> ([57]); -store_temp>([51]) -> ([58]); -function_call([57], [58]) -> ([55], [56]); -drop([56]) -> (); -snapshot_take>([55]) -> ([59], [60]); -drop>([59]) -> (); -struct_construct>([60]) -> ([61]); -struct_construct>>([61]) -> ([62]); -enum_init,)>, 0>([62]) -> ([63]); -store_temp([41]) -> ([64]); -store_temp([42]) -> ([65]); -store_temp([43]) -> ([66]); -store_temp,)>>([63]) -> ([67]); -return([64], [65], [66], [67]); -branch_align() -> (); -enum_init,)>, 1>([50]) -> ([68]); -store_temp([41]) -> ([69]); -store_temp([42]) -> ([70]); -store_temp([43]) -> ([71]); -store_temp,)>>([68]) -> ([72]); -return([69], [70], [71], [72]); -branch_align() -> (); -array_new() -> ([73]); -felt252_const<375233589013918064796019>() -> ([74]); -store_temp([74]) -> ([74]); -array_append([73], [74]) -> ([75]); -struct_construct() -> ([76]); -struct_construct>>([76], [75]) -> ([77]); -enum_init,)>, 1>([77]) -> ([78]); -store_temp([30]) -> ([79]); -store_temp([31]) -> ([80]); -store_temp([2]) -> ([81]); -store_temp,)>>([78]) -> ([82]); -return([79], [80], [81], [82]); -branch_align() -> (); -drop>([3]) -> (); -array_new() -> ([83]); -felt252_const<375233589013918064796019>() -> ([84]); -store_temp([84]) -> ([84]); -array_append([83], [84]) -> ([85]); -struct_construct() -> ([86]); -struct_construct>>([86], [85]) -> ([87]); -enum_init,)>, 1>([87]) -> ([88]); -store_temp([6]) -> ([89]); -store_temp([7]) -> ([90]); -store_temp([2]) -> ([91]); -store_temp,)>>([88]) -> ([92]); -return([89], [90], [91], [92]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 519([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 503([15]) }; -branch_align() -> (); -struct_deconstruct>([10]) -> ([16]); -array_len([16]) -> ([17]); -snapshot_take([17]) -> ([18], [19]); -drop([18]) -> (); -u32_const<0>() -> ([20]); -snapshot_take([20]) -> ([21], [22]); -drop([21]) -> (); -rename([19]) -> ([23]); -rename([22]) -> ([24]); -store_temp([23]) -> ([23]); -u32_eq([23], [24]) { fallthrough() 438() }; -branch_align() -> (); -drop([14]) -> (); -array_new() -> ([25]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([26]); -store_temp([26]) -> ([26]); -array_append([25], [26]) -> ([27]); -struct_construct() -> ([28]); -struct_construct>>([28], [27]) -> ([29]); -enum_init,)>, 1>([29]) -> ([30]); -store_temp([0]) -> ([31]); -store_temp([9]) -> ([32]); -store_temp([6]) -> ([33]); -store_temp([3]) -> ([34]); -store_temp,)>>([30]) -> ([35]); -return([31], [32], [33], [34], [35]); -branch_align() -> (); -get_builtin_costs() -> ([36]); -store_temp([36]) -> ([36]); -withdraw_gas_all([9], [6], [36]) { fallthrough([37], [38]) 488([39], [40]) }; -branch_align() -> (); -struct_construct() -> ([41]); -struct_construct() -> ([42]); -struct_construct() -> ([43]); -struct_construct() -> ([44]); -struct_construct() -> ([45]); -struct_construct() -> ([46]); -struct_construct([41], [42], [43], [44], [45], [46]) -> ([47]); -snapshot_take([47]) -> ([48], [49]); -drop([48]) -> (); -store_temp([37]) -> ([55]); -store_temp([38]) -> ([56]); -store_temp([0]) -> ([57]); -store_temp([3]) -> ([58]); -store_temp([49]) -> ([59]); -store_temp([14]) -> ([60]); -function_call([55], [56], [57], [58], [59], [60]) -> ([50], [51], [52], [53], [54]); -enum_match>([54]) { fallthrough([61]) 480([62]) }; -branch_align() -> (); -array_new() -> ([63]); -struct_deconstruct>([61]) -> ([64]); -snapshot_take([64]) -> ([65], [66]); -drop([65]) -> (); -store_temp([66]) -> ([69]); -store_temp>([63]) -> ([70]); -function_call([69], [70]) -> ([67], [68]); -drop([68]) -> (); -snapshot_take>([67]) -> ([71], [72]); -drop>([71]) -> (); -struct_construct>([72]) -> ([73]); -struct_construct>>([73]) -> ([74]); -enum_init,)>, 0>([74]) -> ([75]); -store_temp([52]) -> ([76]); -store_temp([50]) -> ([77]); -store_temp([51]) -> ([78]); -store_temp([53]) -> ([79]); -store_temp,)>>([75]) -> ([80]); -return([76], [77], [78], [79], [80]); -branch_align() -> (); -enum_init,)>, 1>([62]) -> ([81]); -store_temp([52]) -> ([82]); -store_temp([50]) -> ([83]); -store_temp([51]) -> ([84]); -store_temp([53]) -> ([85]); -store_temp,)>>([81]) -> ([86]); -return([82], [83], [84], [85], [86]); -branch_align() -> (); -drop([14]) -> (); -array_new() -> ([87]); -felt252_const<375233589013918064796019>() -> ([88]); -store_temp([88]) -> ([88]); -array_append([87], [88]) -> ([89]); -struct_construct() -> ([90]); -struct_construct>>([90], [89]) -> ([91]); -enum_init,)>, 1>([91]) -> ([92]); -store_temp([0]) -> ([93]); -store_temp([39]) -> ([94]); -store_temp([40]) -> ([95]); -store_temp([3]) -> ([96]); -store_temp,)>>([92]) -> ([97]); -return([93], [94], [95], [96], [97]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([98]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([99]); -store_temp([99]) -> ([99]); -array_append([98], [99]) -> ([100]); -struct_construct() -> ([101]); -struct_construct>>([101], [100]) -> ([102]); -enum_init,)>, 1>([102]) -> ([103]); -store_temp([0]) -> ([104]); -store_temp([9]) -> ([105]); -store_temp([6]) -> ([106]); -store_temp([3]) -> ([107]); -store_temp,)>>([103]) -> ([108]); -return([104], [105], [106], [107], [108]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([109]); -felt252_const<375233589013918064796019>() -> ([110]); -store_temp([110]) -> ([110]); -array_append([109], [110]) -> ([111]); -struct_construct() -> ([112]); -struct_construct>>([112], [111]) -> ([113]); -enum_init,)>, 1>([113]) -> ([114]); -store_temp([0]) -> ([115]); -store_temp([7]) -> ([116]); -store_temp([8]) -> ([117]); -store_temp([3]) -> ([118]); -store_temp,)>>([114]) -> ([119]); -return([115], [116], [117], [118], [119]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 674([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 658([15]) }; -branch_align() -> (); -store_temp([9]) -> ([19]); -store_temp>([10]) -> ([20]); -function_call([19], [20]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([21]) 641([22]) }; -branch_align() -> (); -struct_deconstruct>([17]) -> ([23]); -array_len([23]) -> ([24]); -snapshot_take([24]) -> ([25], [26]); -drop([25]) -> (); -u32_const<0>() -> ([27]); -snapshot_take([27]) -> ([28], [29]); -drop([28]) -> (); -rename([26]) -> ([30]); -rename([29]) -> ([31]); -store_temp([30]) -> ([30]); -u32_eq([30], [31]) { fallthrough() 574() }; -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([32]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); -store_temp([33]) -> ([33]); -array_append([32], [33]) -> ([34]); -struct_construct() -> ([35]); -struct_construct>>([35], [34]) -> ([36]); -enum_init,)>, 1>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([16]) -> ([39]); -store_temp([6]) -> ([40]); -store_temp([3]) -> ([41]); -store_temp,)>>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -branch_align() -> (); -get_builtin_costs() -> ([43]); -store_temp([43]) -> ([43]); -withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 625([46], [47]) }; -branch_align() -> (); -struct_construct() -> ([48]); -struct_construct() -> ([49]); -struct_construct() -> ([50]); -struct_construct() -> ([51]); -struct_construct() -> ([52]); -struct_construct() -> ([53]); -struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); -snapshot_take([54]) -> ([55], [56]); -drop([55]) -> (); -store_temp([44]) -> ([62]); -store_temp([45]) -> ([63]); -store_temp([0]) -> ([64]); -store_temp([3]) -> ([65]); -store_temp([56]) -> ([66]); -store_temp([14]) -> ([67]); -store_temp([21]) -> ([68]); -function_call([62], [63], [64], [65], [66], [67], [68]) -> ([57], [58], [59], [60], [61]); -enum_match>([61]) { fallthrough([69]) 617([70]) }; -branch_align() -> (); -array_new() -> ([71]); -struct_deconstruct>([69]) -> ([72]); -snapshot_take([72]) -> ([73], [74]); -drop([73]) -> (); -store_temp([74]) -> ([77]); -store_temp>([71]) -> ([78]); -function_call([77], [78]) -> ([75], [76]); -drop([76]) -> (); -snapshot_take>([75]) -> ([79], [80]); -drop>([79]) -> (); -struct_construct>([80]) -> ([81]); -struct_construct>>([81]) -> ([82]); -enum_init,)>, 0>([82]) -> ([83]); -store_temp([59]) -> ([84]); -store_temp([57]) -> ([85]); -store_temp([58]) -> ([86]); -store_temp([60]) -> ([87]); -store_temp,)>>([83]) -> ([88]); -return([84], [85], [86], [87], [88]); -branch_align() -> (); -enum_init,)>, 1>([70]) -> ([89]); -store_temp([59]) -> ([90]); -store_temp([57]) -> ([91]); -store_temp([58]) -> ([92]); -store_temp([60]) -> ([93]); -store_temp,)>>([89]) -> ([94]); -return([90], [91], [92], [93], [94]); -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([95]); -felt252_const<375233589013918064796019>() -> ([96]); -store_temp([96]) -> ([96]); -array_append([95], [96]) -> ([97]); -struct_construct() -> ([98]); -struct_construct>>([98], [97]) -> ([99]); -enum_init,)>, 1>([99]) -> ([100]); -store_temp([0]) -> ([101]); -store_temp([46]) -> ([102]); -store_temp([47]) -> ([103]); -store_temp([3]) -> ([104]); -store_temp,)>>([100]) -> ([105]); -return([101], [102], [103], [104], [105]); -branch_align() -> (); -drop([22]) -> (); -drop>([17]) -> (); -drop([14]) -> (); -array_new() -> ([106]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([107]); -store_temp([107]) -> ([107]); -array_append([106], [107]) -> ([108]); -struct_construct() -> ([109]); -struct_construct>>([109], [108]) -> ([110]); -enum_init,)>, 1>([110]) -> ([111]); -store_temp([0]) -> ([112]); -store_temp([16]) -> ([113]); -store_temp([6]) -> ([114]); -store_temp([3]) -> ([115]); -store_temp,)>>([111]) -> ([116]); -return([112], [113], [114], [115], [116]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([117]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([118]); -store_temp([118]) -> ([118]); -array_append([117], [118]) -> ([119]); -struct_construct() -> ([120]); -struct_construct>>([120], [119]) -> ([121]); -enum_init,)>, 1>([121]) -> ([122]); -store_temp([0]) -> ([123]); -store_temp([9]) -> ([124]); -store_temp([6]) -> ([125]); -store_temp([3]) -> ([126]); -store_temp,)>>([122]) -> ([127]); -return([123], [124], [125], [126], [127]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([128]); -felt252_const<375233589013918064796019>() -> ([129]); -store_temp([129]) -> ([129]); -array_append([128], [129]) -> ([130]); -struct_construct() -> ([131]); -struct_construct>>([131], [130]) -> ([132]); -enum_init,)>, 1>([132]) -> ([133]); -store_temp([0]) -> ([134]); -store_temp([7]) -> ([135]); -store_temp([8]) -> ([136]); -store_temp([3]) -> ([137]); -store_temp,)>>([133]) -> ([138]); -return([134], [135], [136], [137], [138]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 821([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 805([15]) }; -branch_align() -> (); -store_temp([9]) -> ([19]); -store_temp>([10]) -> ([20]); -function_call([19], [20]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([21]) 788([22]) }; -branch_align() -> (); -struct_deconstruct>([17]) -> ([23]); -array_len([23]) -> ([24]); -snapshot_take([24]) -> ([25], [26]); -drop([25]) -> (); -u32_const<0>() -> ([27]); -snapshot_take([27]) -> ([28], [29]); -drop([28]) -> (); -rename([26]) -> ([30]); -rename([29]) -> ([31]); -store_temp([30]) -> ([30]); -u32_eq([30], [31]) { fallthrough() 729() }; -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([32]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); -store_temp([33]) -> ([33]); -array_append([32], [33]) -> ([34]); -struct_construct() -> ([35]); -struct_construct>>([35], [34]) -> ([36]); -enum_init,)>, 1>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([16]) -> ([39]); -store_temp([6]) -> ([40]); -store_temp([3]) -> ([41]); -store_temp,)>>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -branch_align() -> (); -get_builtin_costs() -> ([43]); -store_temp([43]) -> ([43]); -withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 772([46], [47]) }; -branch_align() -> (); -struct_construct() -> ([48]); -struct_construct() -> ([49]); -struct_construct() -> ([50]); -struct_construct() -> ([51]); -struct_construct() -> ([52]); -struct_construct() -> ([53]); -struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); -store_temp([44]) -> ([60]); -store_temp([45]) -> ([61]); -store_temp([0]) -> ([62]); -store_temp([3]) -> ([63]); -store_temp([54]) -> ([64]); -store_temp([14]) -> ([65]); -store_temp([21]) -> ([66]); -function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); -enum_match>([59]) { fallthrough([67]) 764([68]) }; -branch_align() -> (); -drop>([67]) -> (); -array_new() -> ([69]); -snapshot_take>([69]) -> ([70], [71]); -drop>([70]) -> (); -struct_construct>([71]) -> ([72]); -struct_construct>>([72]) -> ([73]); -enum_init,)>, 0>([73]) -> ([74]); -store_temp([57]) -> ([75]); -store_temp([55]) -> ([76]); -store_temp([56]) -> ([77]); -store_temp([58]) -> ([78]); -store_temp,)>>([74]) -> ([79]); -return([75], [76], [77], [78], [79]); -branch_align() -> (); -enum_init,)>, 1>([68]) -> ([80]); -store_temp([57]) -> ([81]); -store_temp([55]) -> ([82]); -store_temp([56]) -> ([83]); -store_temp([58]) -> ([84]); -store_temp,)>>([80]) -> ([85]); -return([81], [82], [83], [84], [85]); -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([86]); -felt252_const<375233589013918064796019>() -> ([87]); -store_temp([87]) -> ([87]); -array_append([86], [87]) -> ([88]); -struct_construct() -> ([89]); -struct_construct>>([89], [88]) -> ([90]); -enum_init,)>, 1>([90]) -> ([91]); -store_temp([0]) -> ([92]); -store_temp([46]) -> ([93]); -store_temp([47]) -> ([94]); -store_temp([3]) -> ([95]); -store_temp,)>>([91]) -> ([96]); -return([92], [93], [94], [95], [96]); -branch_align() -> (); -drop([22]) -> (); -drop>([17]) -> (); -drop([14]) -> (); -array_new() -> ([97]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); -store_temp([98]) -> ([98]); -array_append([97], [98]) -> ([99]); -struct_construct() -> ([100]); -struct_construct>>([100], [99]) -> ([101]); -enum_init,)>, 1>([101]) -> ([102]); -store_temp([0]) -> ([103]); -store_temp([16]) -> ([104]); -store_temp([6]) -> ([105]); -store_temp([3]) -> ([106]); -store_temp,)>>([102]) -> ([107]); -return([103], [104], [105], [106], [107]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([108]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); -store_temp([109]) -> ([109]); -array_append([108], [109]) -> ([110]); -struct_construct() -> ([111]); -struct_construct>>([111], [110]) -> ([112]); -enum_init,)>, 1>([112]) -> ([113]); -store_temp([0]) -> ([114]); -store_temp([9]) -> ([115]); -store_temp([6]) -> ([116]); -store_temp([3]) -> ([117]); -store_temp,)>>([113]) -> ([118]); -return([114], [115], [116], [117], [118]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([119]); -felt252_const<375233589013918064796019>() -> ([120]); -store_temp([120]) -> ([120]); -array_append([119], [120]) -> ([121]); -struct_construct() -> ([122]); -struct_construct>>([122], [121]) -> ([123]); -enum_init,)>, 1>([123]) -> ([124]); -store_temp([0]) -> ([125]); -store_temp([7]) -> ([126]); -store_temp([8]) -> ([127]); -store_temp([3]) -> ([128]); -store_temp,)>>([124]) -> ([129]); -return([125], [126], [127], [128], [129]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 994([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 978([15]) }; -branch_align() -> (); -store_temp([9]) -> ([19]); -store_temp>([10]) -> ([20]); -function_call([19], [20]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([21]) 961([22]) }; -branch_align() -> (); -store_temp([16]) -> ([26]); -store_temp>([17]) -> ([27]); -function_call([26], [27]) -> ([23], [24], [25]); -enum_match>([25]) { fallthrough([28]) 943([29]) }; -branch_align() -> (); -struct_deconstruct>([24]) -> ([30]); -array_len([30]) -> ([31]); -snapshot_take([31]) -> ([32], [33]); -drop([32]) -> (); -u32_const<0>() -> ([34]); -snapshot_take([34]) -> ([35], [36]); -drop([35]) -> (); -rename([33]) -> ([37]); -rename([36]) -> ([38]); -store_temp([37]) -> ([37]); -u32_eq([37], [38]) { fallthrough() 882() }; -branch_align() -> (); -drop([28]) -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([39]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([40]); -store_temp([40]) -> ([40]); -array_append([39], [40]) -> ([41]); -struct_construct() -> ([42]); -struct_construct>>([42], [41]) -> ([43]); -enum_init,)>, 1>([43]) -> ([44]); -store_temp([0]) -> ([45]); -store_temp([23]) -> ([46]); -store_temp([6]) -> ([47]); -store_temp([3]) -> ([48]); -store_temp,)>>([44]) -> ([49]); -return([45], [46], [47], [48], [49]); -branch_align() -> (); -get_builtin_costs() -> ([50]); -store_temp([50]) -> ([50]); -withdraw_gas_all([23], [6], [50]) { fallthrough([51], [52]) 926([53], [54]) }; -branch_align() -> (); -struct_construct() -> ([55]); -struct_construct() -> ([56]); -struct_construct() -> ([57]); -struct_construct() -> ([58]); -struct_construct() -> ([59]); -struct_construct() -> ([60]); -struct_construct([55], [56], [57], [58], [59], [60]) -> ([61]); -store_temp([51]) -> ([67]); -store_temp([52]) -> ([68]); -store_temp([0]) -> ([69]); -store_temp([3]) -> ([70]); -store_temp([61]) -> ([71]); -store_temp([14]) -> ([72]); -store_temp([21]) -> ([73]); -store_temp([28]) -> ([74]); -function_call([67], [68], [69], [70], [71], [72], [73], [74]) -> ([62], [63], [64], [65], [66]); -enum_match>([66]) { fallthrough([75]) 918([76]) }; -branch_align() -> (); -drop>([75]) -> (); -array_new() -> ([77]); -snapshot_take>([77]) -> ([78], [79]); -drop>([78]) -> (); -struct_construct>([79]) -> ([80]); -struct_construct>>([80]) -> ([81]); -enum_init,)>, 0>([81]) -> ([82]); -store_temp([64]) -> ([83]); -store_temp([62]) -> ([84]); -store_temp([63]) -> ([85]); -store_temp([65]) -> ([86]); -store_temp,)>>([82]) -> ([87]); -return([83], [84], [85], [86], [87]); -branch_align() -> (); -enum_init,)>, 1>([76]) -> ([88]); -store_temp([64]) -> ([89]); -store_temp([62]) -> ([90]); -store_temp([63]) -> ([91]); -store_temp([65]) -> ([92]); -store_temp,)>>([88]) -> ([93]); -return([89], [90], [91], [92], [93]); -branch_align() -> (); -drop([28]) -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([94]); -felt252_const<375233589013918064796019>() -> ([95]); -store_temp([95]) -> ([95]); -array_append([94], [95]) -> ([96]); -struct_construct() -> ([97]); -struct_construct>>([97], [96]) -> ([98]); -enum_init,)>, 1>([98]) -> ([99]); -store_temp([0]) -> ([100]); -store_temp([53]) -> ([101]); -store_temp([54]) -> ([102]); -store_temp([3]) -> ([103]); -store_temp,)>>([99]) -> ([104]); -return([100], [101], [102], [103], [104]); -branch_align() -> (); -drop([29]) -> (); -drop>([24]) -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([105]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>() -> ([106]); -store_temp([106]) -> ([106]); -array_append([105], [106]) -> ([107]); -struct_construct() -> ([108]); -struct_construct>>([108], [107]) -> ([109]); -enum_init,)>, 1>([109]) -> ([110]); -store_temp([0]) -> ([111]); -store_temp([23]) -> ([112]); -store_temp([6]) -> ([113]); -store_temp([3]) -> ([114]); -store_temp,)>>([110]) -> ([115]); -return([111], [112], [113], [114], [115]); -branch_align() -> (); -drop([22]) -> (); -drop([14]) -> (); -drop>([17]) -> (); -array_new() -> ([116]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([117]); -store_temp([117]) -> ([117]); -array_append([116], [117]) -> ([118]); -struct_construct() -> ([119]); -struct_construct>>([119], [118]) -> ([120]); -enum_init,)>, 1>([120]) -> ([121]); -store_temp([0]) -> ([122]); -store_temp([16]) -> ([123]); -store_temp([6]) -> ([124]); -store_temp([3]) -> ([125]); -store_temp,)>>([121]) -> ([126]); -return([122], [123], [124], [125], [126]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([127]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([128]); -store_temp([128]) -> ([128]); -array_append([127], [128]) -> ([129]); -struct_construct() -> ([130]); -struct_construct>>([130], [129]) -> ([131]); -enum_init,)>, 1>([131]) -> ([132]); -store_temp([0]) -> ([133]); -store_temp([9]) -> ([134]); -store_temp([6]) -> ([135]); -store_temp([3]) -> ([136]); -store_temp,)>>([132]) -> ([137]); -return([133], [134], [135], [136], [137]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([138]); -felt252_const<375233589013918064796019>() -> ([139]); -store_temp([139]) -> ([139]); -array_append([138], [139]) -> ([140]); -struct_construct() -> ([141]); -struct_construct>>([141], [140]) -> ([142]); -enum_init,)>, 1>([142]) -> ([143]); -store_temp([0]) -> ([144]); -store_temp([7]) -> ([145]); -store_temp([8]) -> ([146]); -store_temp([3]) -> ([147]); -store_temp,)>>([143]) -> ([148]); -return([144], [145], [146], [147], [148]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 1141([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 1125([15]) }; -branch_align() -> (); -store_temp([9]) -> ([19]); -store_temp>([10]) -> ([20]); -function_call([19], [20]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([21]) 1108([22]) }; -branch_align() -> (); -struct_deconstruct>([17]) -> ([23]); -array_len([23]) -> ([24]); -snapshot_take([24]) -> ([25], [26]); -drop([25]) -> (); -u32_const<0>() -> ([27]); -snapshot_take([27]) -> ([28], [29]); -drop([28]) -> (); -rename([26]) -> ([30]); -rename([29]) -> ([31]); -store_temp([30]) -> ([30]); -u32_eq([30], [31]) { fallthrough() 1049() }; -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([32]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); -store_temp([33]) -> ([33]); -array_append([32], [33]) -> ([34]); -struct_construct() -> ([35]); -struct_construct>>([35], [34]) -> ([36]); -enum_init,)>, 1>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([16]) -> ([39]); -store_temp([6]) -> ([40]); -store_temp([3]) -> ([41]); -store_temp,)>>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -branch_align() -> (); -get_builtin_costs() -> ([43]); -store_temp([43]) -> ([43]); -withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1092([46], [47]) }; -branch_align() -> (); -struct_construct() -> ([48]); -struct_construct() -> ([49]); -struct_construct() -> ([50]); -struct_construct() -> ([51]); -struct_construct() -> ([52]); -struct_construct() -> ([53]); -struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); -store_temp([44]) -> ([60]); -store_temp([45]) -> ([61]); -store_temp([0]) -> ([62]); -store_temp([3]) -> ([63]); -store_temp([54]) -> ([64]); -store_temp([14]) -> ([65]); -store_temp([21]) -> ([66]); -function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); -enum_match>([59]) { fallthrough([67]) 1084([68]) }; -branch_align() -> (); -drop>([67]) -> (); -array_new() -> ([69]); -snapshot_take>([69]) -> ([70], [71]); -drop>([70]) -> (); -struct_construct>([71]) -> ([72]); -struct_construct>>([72]) -> ([73]); -enum_init,)>, 0>([73]) -> ([74]); -store_temp([57]) -> ([75]); -store_temp([55]) -> ([76]); -store_temp([56]) -> ([77]); -store_temp([58]) -> ([78]); -store_temp,)>>([74]) -> ([79]); -return([75], [76], [77], [78], [79]); -branch_align() -> (); -enum_init,)>, 1>([68]) -> ([80]); -store_temp([57]) -> ([81]); -store_temp([55]) -> ([82]); -store_temp([56]) -> ([83]); -store_temp([58]) -> ([84]); -store_temp,)>>([80]) -> ([85]); -return([81], [82], [83], [84], [85]); -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([86]); -felt252_const<375233589013918064796019>() -> ([87]); -store_temp([87]) -> ([87]); -array_append([86], [87]) -> ([88]); -struct_construct() -> ([89]); -struct_construct>>([89], [88]) -> ([90]); -enum_init,)>, 1>([90]) -> ([91]); -store_temp([0]) -> ([92]); -store_temp([46]) -> ([93]); -store_temp([47]) -> ([94]); -store_temp([3]) -> ([95]); -store_temp,)>>([91]) -> ([96]); -return([92], [93], [94], [95], [96]); -branch_align() -> (); -drop([22]) -> (); -drop>([17]) -> (); -drop([14]) -> (); -array_new() -> ([97]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); -store_temp([98]) -> ([98]); -array_append([97], [98]) -> ([99]); -struct_construct() -> ([100]); -struct_construct>>([100], [99]) -> ([101]); -enum_init,)>, 1>([101]) -> ([102]); -store_temp([0]) -> ([103]); -store_temp([16]) -> ([104]); -store_temp([6]) -> ([105]); -store_temp([3]) -> ([106]); -store_temp,)>>([102]) -> ([107]); -return([103], [104], [105], [106], [107]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([108]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); -store_temp([109]) -> ([109]); -array_append([108], [109]) -> ([110]); -struct_construct() -> ([111]); -struct_construct>>([111], [110]) -> ([112]); -enum_init,)>, 1>([112]) -> ([113]); -store_temp([0]) -> ([114]); -store_temp([9]) -> ([115]); -store_temp([6]) -> ([116]); -store_temp([3]) -> ([117]); -store_temp,)>>([113]) -> ([118]); -return([114], [115], [116], [117], [118]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([119]); -felt252_const<375233589013918064796019>() -> ([120]); -store_temp([120]) -> ([120]); -array_append([119], [120]) -> ([121]); -struct_construct() -> ([122]); -struct_construct>>([122], [121]) -> ([123]); -enum_init,)>, 1>([123]) -> ([124]); -store_temp([0]) -> ([125]); -store_temp([7]) -> ([126]); -store_temp([8]) -> ([127]); -store_temp([3]) -> ([128]); -store_temp,)>>([124]) -> ([129]); -return([125], [126], [127], [128], [129]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 1288([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 1272([15]) }; -branch_align() -> (); -store_temp([9]) -> ([19]); -store_temp>([10]) -> ([20]); -function_call([19], [20]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([21]) 1255([22]) }; -branch_align() -> (); -struct_deconstruct>([17]) -> ([23]); -array_len([23]) -> ([24]); -snapshot_take([24]) -> ([25], [26]); -drop([25]) -> (); -u32_const<0>() -> ([27]); -snapshot_take([27]) -> ([28], [29]); -drop([28]) -> (); -rename([26]) -> ([30]); -rename([29]) -> ([31]); -store_temp([30]) -> ([30]); -u32_eq([30], [31]) { fallthrough() 1196() }; -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([32]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); -store_temp([33]) -> ([33]); -array_append([32], [33]) -> ([34]); -struct_construct() -> ([35]); -struct_construct>>([35], [34]) -> ([36]); -enum_init,)>, 1>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([16]) -> ([39]); -store_temp([6]) -> ([40]); -store_temp([3]) -> ([41]); -store_temp,)>>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -branch_align() -> (); -get_builtin_costs() -> ([43]); -store_temp([43]) -> ([43]); -withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1239([46], [47]) }; -branch_align() -> (); -struct_construct() -> ([48]); -struct_construct() -> ([49]); -struct_construct() -> ([50]); -struct_construct() -> ([51]); -struct_construct() -> ([52]); -struct_construct() -> ([53]); -struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); -store_temp([44]) -> ([60]); -store_temp([45]) -> ([61]); -store_temp([0]) -> ([62]); -store_temp([3]) -> ([63]); -store_temp([54]) -> ([64]); -store_temp([14]) -> ([65]); -store_temp([21]) -> ([66]); -function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); -enum_match>([59]) { fallthrough([67]) 1231([68]) }; -branch_align() -> (); -drop>([67]) -> (); -array_new() -> ([69]); -snapshot_take>([69]) -> ([70], [71]); -drop>([70]) -> (); -struct_construct>([71]) -> ([72]); -struct_construct>>([72]) -> ([73]); -enum_init,)>, 0>([73]) -> ([74]); -store_temp([57]) -> ([75]); -store_temp([55]) -> ([76]); -store_temp([56]) -> ([77]); -store_temp([58]) -> ([78]); -store_temp,)>>([74]) -> ([79]); -return([75], [76], [77], [78], [79]); -branch_align() -> (); -enum_init,)>, 1>([68]) -> ([80]); -store_temp([57]) -> ([81]); -store_temp([55]) -> ([82]); -store_temp([56]) -> ([83]); -store_temp([58]) -> ([84]); -store_temp,)>>([80]) -> ([85]); -return([81], [82], [83], [84], [85]); -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([86]); -felt252_const<375233589013918064796019>() -> ([87]); -store_temp([87]) -> ([87]); -array_append([86], [87]) -> ([88]); -struct_construct() -> ([89]); -struct_construct>>([89], [88]) -> ([90]); -enum_init,)>, 1>([90]) -> ([91]); -store_temp([0]) -> ([92]); -store_temp([46]) -> ([93]); -store_temp([47]) -> ([94]); -store_temp([3]) -> ([95]); -store_temp,)>>([91]) -> ([96]); -return([92], [93], [94], [95], [96]); -branch_align() -> (); -drop([22]) -> (); -drop>([17]) -> (); -drop([14]) -> (); -array_new() -> ([97]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); -store_temp([98]) -> ([98]); -array_append([97], [98]) -> ([99]); -struct_construct() -> ([100]); -struct_construct>>([100], [99]) -> ([101]); -enum_init,)>, 1>([101]) -> ([102]); -store_temp([0]) -> ([103]); -store_temp([16]) -> ([104]); -store_temp([6]) -> ([105]); -store_temp([3]) -> ([106]); -store_temp,)>>([102]) -> ([107]); -return([103], [104], [105], [106], [107]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([108]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); -store_temp([109]) -> ([109]); -array_append([108], [109]) -> ([110]); -struct_construct() -> ([111]); -struct_construct>>([111], [110]) -> ([112]); -enum_init,)>, 1>([112]) -> ([113]); -store_temp([0]) -> ([114]); -store_temp([9]) -> ([115]); -store_temp([6]) -> ([116]); -store_temp([3]) -> ([117]); -store_temp,)>>([113]) -> ([118]); -return([114], [115], [116], [117], [118]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([119]); -felt252_const<375233589013918064796019>() -> ([120]); -store_temp([120]) -> ([120]); -array_append([119], [120]) -> ([121]); -struct_construct() -> ([122]); -struct_construct>>([122], [121]) -> ([123]); -enum_init,)>, 1>([123]) -> ([124]); -store_temp([0]) -> ([125]); -store_temp([7]) -> ([126]); -store_temp([8]) -> ([127]); -store_temp([3]) -> ([128]); -store_temp,)>>([124]) -> ([129]); -return([125], [126], [127], [128], [129]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 1435([7], [8]) }; -branch_align() -> (); -store_temp([5]) -> ([12]); -store_temp>([4]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 1419([15]) }; -branch_align() -> (); -store_temp([9]) -> ([19]); -store_temp>([10]) -> ([20]); -function_call([19], [20]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([21]) 1402([22]) }; -branch_align() -> (); -struct_deconstruct>([17]) -> ([23]); -array_len([23]) -> ([24]); -snapshot_take([24]) -> ([25], [26]); -drop([25]) -> (); -u32_const<0>() -> ([27]); -snapshot_take([27]) -> ([28], [29]); -drop([28]) -> (); -rename([26]) -> ([30]); -rename([29]) -> ([31]); -store_temp([30]) -> ([30]); -u32_eq([30], [31]) { fallthrough() 1343() }; -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([32]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); -store_temp([33]) -> ([33]); -array_append([32], [33]) -> ([34]); -struct_construct() -> ([35]); -struct_construct>>([35], [34]) -> ([36]); -enum_init,)>, 1>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([16]) -> ([39]); -store_temp([6]) -> ([40]); -store_temp([3]) -> ([41]); -store_temp,)>>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -branch_align() -> (); -get_builtin_costs() -> ([43]); -store_temp([43]) -> ([43]); -withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1386([46], [47]) }; -branch_align() -> (); -struct_construct() -> ([48]); -struct_construct() -> ([49]); -struct_construct() -> ([50]); -struct_construct() -> ([51]); -struct_construct() -> ([52]); -struct_construct() -> ([53]); -struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); -store_temp([44]) -> ([60]); -store_temp([45]) -> ([61]); -store_temp([0]) -> ([62]); -store_temp([3]) -> ([63]); -store_temp([54]) -> ([64]); -store_temp([14]) -> ([65]); -store_temp([21]) -> ([66]); -function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); -enum_match>([59]) { fallthrough([67]) 1378([68]) }; -branch_align() -> (); -drop>([67]) -> (); -array_new() -> ([69]); -snapshot_take>([69]) -> ([70], [71]); -drop>([70]) -> (); -struct_construct>([71]) -> ([72]); -struct_construct>>([72]) -> ([73]); -enum_init,)>, 0>([73]) -> ([74]); -store_temp([57]) -> ([75]); -store_temp([55]) -> ([76]); -store_temp([56]) -> ([77]); -store_temp([58]) -> ([78]); -store_temp,)>>([74]) -> ([79]); -return([75], [76], [77], [78], [79]); -branch_align() -> (); -enum_init,)>, 1>([68]) -> ([80]); -store_temp([57]) -> ([81]); -store_temp([55]) -> ([82]); -store_temp([56]) -> ([83]); -store_temp([58]) -> ([84]); -store_temp,)>>([80]) -> ([85]); -return([81], [82], [83], [84], [85]); -branch_align() -> (); -drop([21]) -> (); -drop([14]) -> (); -array_new() -> ([86]); -felt252_const<375233589013918064796019>() -> ([87]); -store_temp([87]) -> ([87]); -array_append([86], [87]) -> ([88]); -struct_construct() -> ([89]); -struct_construct>>([89], [88]) -> ([90]); -enum_init,)>, 1>([90]) -> ([91]); -store_temp([0]) -> ([92]); -store_temp([46]) -> ([93]); -store_temp([47]) -> ([94]); -store_temp([3]) -> ([95]); -store_temp,)>>([91]) -> ([96]); -return([92], [93], [94], [95], [96]); -branch_align() -> (); -drop([22]) -> (); -drop>([17]) -> (); -drop([14]) -> (); -array_new() -> ([97]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); -store_temp([98]) -> ([98]); -array_append([97], [98]) -> ([99]); -struct_construct() -> ([100]); -struct_construct>>([100], [99]) -> ([101]); -enum_init,)>, 1>([101]) -> ([102]); -store_temp([0]) -> ([103]); -store_temp([16]) -> ([104]); -store_temp([6]) -> ([105]); -store_temp([3]) -> ([106]); -store_temp,)>>([102]) -> ([107]); -return([103], [104], [105], [106], [107]); -branch_align() -> (); -drop([15]) -> (); -drop>([10]) -> (); -array_new() -> ([108]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); -store_temp([109]) -> ([109]); -array_append([108], [109]) -> ([110]); -struct_construct() -> ([111]); -struct_construct>>([111], [110]) -> ([112]); -enum_init,)>, 1>([112]) -> ([113]); -store_temp([0]) -> ([114]); -store_temp([9]) -> ([115]); -store_temp([6]) -> ([116]); -store_temp([3]) -> ([117]); -store_temp,)>>([113]) -> ([118]); -return([114], [115], [116], [117], [118]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([119]); -felt252_const<375233589013918064796019>() -> ([120]); -store_temp([120]) -> ([120]); -array_append([119], [120]) -> ([121]); -struct_construct() -> ([122]); -struct_construct>>([122], [121]) -> ([123]); -enum_init,)>, 1>([123]) -> ([124]); -store_temp([0]) -> ([125]); -store_temp([7]) -> ([126]); -store_temp([8]) -> ([127]); -store_temp([3]) -> ([128]); -store_temp,)>>([124]) -> ([129]); -return([125], [126], [127], [128], [129]); -revoke_ap_tracking() -> (); -withdraw_gas([1], [2]) { fallthrough([5], [6]) 1662([7], [8]) }; -branch_align() -> (); -store_temp>([4]) -> ([11]); -function_call([11]) -> ([9], [10]); -store_temp([5]) -> ([5]); -enum_match>([10]) { fallthrough([12]) 1646([13]) }; -branch_align() -> (); -store_temp>([9]) -> ([16]); -function_call([16]) -> ([14], [15]); -enum_match>([15]) { fallthrough([17]) 1629([18]) }; -branch_align() -> (); -store_temp([5]) -> ([22]); -store_temp>([14]) -> ([23]); -function_call([22], [23]) -> ([19], [20], [21]); -enum_match>([21]) { fallthrough([24]) 1611([25]) }; -branch_align() -> (); -store_temp([19]) -> ([29]); -store_temp>([20]) -> ([30]); -function_call([29], [30]) -> ([26], [27], [28]); -enum_match>([28]) { fallthrough([31]) 1592([32]) }; -branch_align() -> (); -store_temp([26]) -> ([36]); -store_temp>([27]) -> ([37]); -function_call([36], [37]) -> ([33], [34], [35]); -enum_match>([35]) { fallthrough([38]) 1572([39]) }; -branch_align() -> (); -struct_deconstruct>([34]) -> ([40]); -array_len([40]) -> ([41]); -snapshot_take([41]) -> ([42], [43]); -drop([42]) -> (); -u32_const<0>() -> ([44]); -snapshot_take([44]) -> ([45], [46]); -drop([45]) -> (); -rename([43]) -> ([47]); -rename([46]) -> ([48]); -store_temp([47]) -> ([47]); -u32_eq([47], [48]) { fallthrough() 1507() }; -branch_align() -> (); -drop([38]) -> (); -drop([31]) -> (); -drop([24]) -> (); -drop([17]) -> (); -drop([12]) -> (); -array_new() -> ([49]); -felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([50]); -store_temp([50]) -> ([50]); -array_append([49], [50]) -> ([51]); -struct_construct() -> ([52]); -struct_construct>>([52], [51]) -> ([53]); -enum_init,)>, 1>([53]) -> ([54]); -store_temp([0]) -> ([55]); -store_temp([33]) -> ([56]); -store_temp([6]) -> ([57]); -store_temp([3]) -> ([58]); -store_temp,)>>([54]) -> ([59]); -return([55], [56], [57], [58], [59]); -branch_align() -> (); -get_builtin_costs() -> ([60]); -store_temp([60]) -> ([60]); -withdraw_gas_all([33], [6], [60]) { fallthrough([61], [62]) 1553([63], [64]) }; -branch_align() -> (); -struct_construct() -> ([65]); -struct_construct() -> ([66]); -struct_construct() -> ([67]); -struct_construct() -> ([68]); -struct_construct() -> ([69]); -struct_construct() -> ([70]); -struct_construct([65], [66], [67], [68], [69], [70]) -> ([71]); -store_temp([61]) -> ([77]); -store_temp([62]) -> ([78]); -store_temp([0]) -> ([79]); -store_temp([3]) -> ([80]); -store_temp([71]) -> ([81]); -store_temp([12]) -> ([82]); -store_temp([17]) -> ([83]); -store_temp([24]) -> ([84]); -store_temp([31]) -> ([85]); -store_temp([38]) -> ([86]); -function_call([77], [78], [79], [80], [81], [82], [83], [84], [85], [86]) -> ([72], [73], [74], [75], [76]); -enum_match>([76]) { fallthrough([87]) 1545([88]) }; -branch_align() -> (); -drop>([87]) -> (); -array_new() -> ([89]); -snapshot_take>([89]) -> ([90], [91]); -drop>([90]) -> (); -struct_construct>([91]) -> ([92]); -struct_construct>>([92]) -> ([93]); -enum_init,)>, 0>([93]) -> ([94]); -store_temp([74]) -> ([95]); -store_temp([72]) -> ([96]); -store_temp([73]) -> ([97]); -store_temp([75]) -> ([98]); -store_temp,)>>([94]) -> ([99]); -return([95], [96], [97], [98], [99]); -branch_align() -> (); -enum_init,)>, 1>([88]) -> ([100]); -store_temp([74]) -> ([101]); -store_temp([72]) -> ([102]); -store_temp([73]) -> ([103]); -store_temp([75]) -> ([104]); -store_temp,)>>([100]) -> ([105]); -return([101], [102], [103], [104], [105]); -branch_align() -> (); -drop([38]) -> (); -drop([31]) -> (); -drop([24]) -> (); -drop([17]) -> (); -drop([12]) -> (); -array_new() -> ([106]); -felt252_const<375233589013918064796019>() -> ([107]); -store_temp([107]) -> ([107]); -array_append([106], [107]) -> ([108]); -struct_construct() -> ([109]); -struct_construct>>([109], [108]) -> ([110]); -enum_init,)>, 1>([110]) -> ([111]); -store_temp([0]) -> ([112]); -store_temp([63]) -> ([113]); -store_temp([64]) -> ([114]); -store_temp([3]) -> ([115]); -store_temp,)>>([111]) -> ([116]); -return([112], [113], [114], [115], [116]); -branch_align() -> (); -drop([39]) -> (); -drop>([34]) -> (); -drop([31]) -> (); -drop([24]) -> (); -drop([17]) -> (); -drop([12]) -> (); -array_new() -> ([117]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917>() -> ([118]); -store_temp([118]) -> ([118]); -array_append([117], [118]) -> ([119]); -struct_construct() -> ([120]); -struct_construct>>([120], [119]) -> ([121]); -enum_init,)>, 1>([121]) -> ([122]); -store_temp([0]) -> ([123]); -store_temp([33]) -> ([124]); -store_temp([6]) -> ([125]); -store_temp([3]) -> ([126]); -store_temp,)>>([122]) -> ([127]); -return([123], [124], [125], [126], [127]); -branch_align() -> (); -drop([32]) -> (); -drop([17]) -> (); -drop([12]) -> (); -drop([24]) -> (); -drop>([27]) -> (); -array_new() -> ([128]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916>() -> ([129]); -store_temp([129]) -> ([129]); -array_append([128], [129]) -> ([130]); -struct_construct() -> ([131]); -struct_construct>>([131], [130]) -> ([132]); -enum_init,)>, 1>([132]) -> ([133]); -store_temp([0]) -> ([134]); -store_temp([26]) -> ([135]); -store_temp([6]) -> ([136]); -store_temp([3]) -> ([137]); -store_temp,)>>([133]) -> ([138]); -return([134], [135], [136], [137], [138]); -branch_align() -> (); -drop([25]) -> (); -drop([17]) -> (); -drop([12]) -> (); -drop>([20]) -> (); -array_new() -> ([139]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>() -> ([140]); -store_temp([140]) -> ([140]); -array_append([139], [140]) -> ([141]); -struct_construct() -> ([142]); -struct_construct>>([142], [141]) -> ([143]); -enum_init,)>, 1>([143]) -> ([144]); -store_temp([0]) -> ([145]); -store_temp([19]) -> ([146]); -store_temp([6]) -> ([147]); -store_temp([3]) -> ([148]); -store_temp,)>>([144]) -> ([149]); -return([145], [146], [147], [148], [149]); -branch_align() -> (); -drop([18]) -> (); -drop([12]) -> (); -drop>([14]) -> (); -array_new() -> ([150]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([151]); -store_temp([151]) -> ([151]); -array_append([150], [151]) -> ([152]); -struct_construct() -> ([153]); -struct_construct>>([153], [152]) -> ([154]); -enum_init,)>, 1>([154]) -> ([155]); -store_temp([0]) -> ([156]); -store_temp([5]) -> ([157]); -store_temp([6]) -> ([158]); -store_temp([3]) -> ([159]); -store_temp,)>>([155]) -> ([160]); -return([156], [157], [158], [159], [160]); -branch_align() -> (); -drop([13]) -> (); -drop>([9]) -> (); -array_new() -> ([161]); -felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([162]); -store_temp([162]) -> ([162]); -array_append([161], [162]) -> ([163]); -struct_construct() -> ([164]); -struct_construct>>([164], [163]) -> ([165]); -enum_init,)>, 1>([165]) -> ([166]); -store_temp([0]) -> ([167]); -store_temp([5]) -> ([168]); -store_temp([6]) -> ([169]); -store_temp([3]) -> ([170]); -store_temp,)>>([166]) -> ([171]); -return([167], [168], [169], [170], [171]); -branch_align() -> (); -drop>([4]) -> (); -array_new() -> ([172]); -felt252_const<375233589013918064796019>() -> ([173]); -store_temp([173]) -> ([173]); -array_append([172], [173]) -> ([174]); -struct_construct() -> ([175]); -struct_construct>>([175], [174]) -> ([176]); -enum_init,)>, 1>([176]) -> ([177]); -store_temp([0]) -> ([178]); -store_temp([7]) -> ([179]); -store_temp([8]) -> ([180]); -store_temp([3]) -> ([181]); -store_temp,)>>([177]) -> ([182]); -return([178], [179], [180], [181], [182]); -struct_deconstruct([2]) -> ([3], [4], [5], [6], [7], [8]); -drop([4]) -> (); -drop([5]) -> (); -drop([6]) -> (); -drop([7]) -> (); -drop([8]) -> (); -store_temp([0]) -> ([12]); -store_temp([1]) -> ([13]); -store_temp([3]) -> ([14]); -function_call([12], [13], [14]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([15]) 1696([16]) }; -branch_align() -> (); -struct_deconstruct>([15]) -> ([17]); -struct_construct>([17]) -> ([18]); -enum_init, 0>([18]) -> ([19]); -store_temp([9]) -> ([20]); -store_temp([10]) -> ([21]); -store_temp>([19]) -> ([22]); -return([20], [21], [22]); -branch_align() -> (); -enum_init, 1>([16]) -> ([23]); -store_temp([9]) -> ([24]); -store_temp([10]) -> ([25]); -store_temp>([23]) -> ([26]); -return([24], [25], [26]); -rename([0]) -> ([2]); -array_append([1], [2]) -> ([3]); -struct_construct() -> ([4]); -store_temp>([3]) -> ([5]); -store_temp([4]) -> ([6]); -return([5], [6]); -struct_deconstruct([2]) -> ([3], [4], [5], [6], [7], [8]); -drop([3]) -> (); -drop([5]) -> (); -drop([6]) -> (); -drop([7]) -> (); -drop([8]) -> (); -store_temp([0]) -> ([12]); -store_temp([1]) -> ([13]); -store_temp([4]) -> ([14]); -function_call([12], [13], [14]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([15]) 1727([16]) }; -branch_align() -> (); -struct_deconstruct>([15]) -> ([17]); -struct_construct>([17]) -> ([18]); -enum_init, 0>([18]) -> ([19]); -store_temp([9]) -> ([20]); -store_temp([10]) -> ([21]); -store_temp>([19]) -> ([22]); -return([20], [21], [22]); -branch_align() -> (); -enum_init, 1>([16]) -> ([23]); -store_temp([9]) -> ([24]); -store_temp([10]) -> ([25]); -store_temp>([23]) -> ([26]); -return([24], [25], [26]); -struct_deconstruct([3]) -> ([4], [5], [6], [7], [8], [9]); -drop([4]) -> (); -drop([5]) -> (); -drop([7]) -> (); -drop([8]) -> (); -drop([9]) -> (); -store_temp([0]) -> ([14]); -store_temp([1]) -> ([15]); -store_temp([2]) -> ([16]); -store_temp([6]) -> ([17]); -function_call([14], [15], [16], [17]) -> ([10], [11], [12], [13]); -enum_match>([13]) { fallthrough([18]) 1754([19]) }; -branch_align() -> (); -struct_deconstruct>([18]) -> ([20]); -struct_construct>([20]) -> ([21]); -enum_init, 0>([21]) -> ([22]); -store_temp([10]) -> ([23]); -store_temp([11]) -> ([24]); -store_temp([12]) -> ([25]); -store_temp>([22]) -> ([26]); -return([23], [24], [25], [26]); -branch_align() -> (); -enum_init, 1>([19]) -> ([27]); -store_temp([10]) -> ([28]); -store_temp([11]) -> ([29]); -store_temp([12]) -> ([30]); -store_temp>([27]) -> ([31]); -return([28], [29], [30], [31]); -rename([0]) -> ([2]); -u8_to_felt252([2]) -> ([3]); -snapshot_take([3]) -> ([4], [5]); -drop([4]) -> (); -store_temp([5]) -> ([8]); -store_temp>([1]) -> ([9]); -function_call([8], [9]) -> ([6], [7]); -drop([7]) -> (); -struct_construct() -> ([10]); -store_temp>([6]) -> ([11]); -store_temp([10]) -> ([12]); -return([11], [12]); -struct_deconstruct([3]) -> ([4], [5], [6], [7], [8], [9]); -drop([4]) -> (); -drop([5]) -> (); -drop([6]) -> (); -drop([8]) -> (); -drop([9]) -> (); -store_temp([0]) -> ([14]); -store_temp([1]) -> ([15]); -store_temp([2]) -> ([16]); -store_temp([7]) -> ([17]); -function_call([14], [15], [16], [17]) -> ([10], [11], [12], [13]); -enum_match>([13]) { fallthrough([18]) 1794([19]) }; -branch_align() -> (); -struct_deconstruct>([18]) -> ([20]); -struct_construct>([20]) -> ([21]); -enum_init, 0>([21]) -> ([22]); -store_temp([10]) -> ([23]); -store_temp([11]) -> ([24]); -store_temp([12]) -> ([25]); -store_temp>([22]) -> ([26]); -return([23], [24], [25], [26]); -branch_align() -> (); -enum_init, 1>([19]) -> ([27]); -store_temp([10]) -> ([28]); -store_temp([11]) -> ([29]); -store_temp([12]) -> ([30]); -store_temp>([27]) -> ([31]); -return([28], [29], [30], [31]); -dup([0]) -> ([0], [2]); -struct_deconstruct([2]) -> ([3], [4]); -drop([4]) -> (); -store_temp([3]) -> ([7]); -store_temp>([1]) -> ([8]); -function_call([7], [8]) -> ([5], [6]); -drop([6]) -> (); -struct_deconstruct([0]) -> ([9], [10]); -drop([9]) -> (); -store_temp([10]) -> ([13]); -store_temp>([5]) -> ([14]); -function_call([13], [14]) -> ([11], [12]); -rename>([11]) -> ([15]); -rename([12]) -> ([16]); -return([15], [16]); -store_temp>([1]) -> ([4]); -function_call([4]) -> ([2], [3]); -enum_match>([3]) { fallthrough([5]) 1834([6]) }; -branch_align() -> (); -contract_address_try_from_felt252([0], [5]) { fallthrough([7], [8]) 1827([9]) }; -branch_align() -> (); -enum_init, 0>([8]) -> ([10]); -store_temp([7]) -> ([11]); -store_temp>([2]) -> ([12]); -store_temp>([10]) -> ([13]); -return([11], [12], [13]); -branch_align() -> (); -struct_construct() -> ([14]); -enum_init, 1>([14]) -> ([15]); -store_temp([9]) -> ([16]); -store_temp>([2]) -> ([17]); -store_temp>([15]) -> ([18]); -return([16], [17], [18]); -branch_align() -> (); -enum_init, 1>([6]) -> ([19]); -store_temp([0]) -> ([20]); -store_temp>([2]) -> ([21]); -store_temp>([19]) -> ([22]); -return([20], [21], [22]); -struct_deconstruct([4]) -> ([6], [7], [8], [9], [10], [11]); -drop([6]) -> (); -drop([7]) -> (); -drop([8]) -> (); -drop([9]) -> (); -drop([11]) -> (); -store_temp([0]) -> ([17]); -store_temp([1]) -> ([18]); -store_temp([2]) -> ([19]); -store_temp([3]) -> ([20]); -store_temp([10]) -> ([21]); -store_temp([5]) -> ([22]); -function_call([17], [18], [19], [20], [21], [22]) -> ([12], [13], [14], [15], [16]); -enum_match>([16]) { fallthrough([23]) 1864([24]) }; -branch_align() -> (); -struct_deconstruct>([23]) -> ([25]); -struct_construct>([25]) -> ([26]); -enum_init, 0>([26]) -> ([27]); -store_temp([12]) -> ([28]); -store_temp([13]) -> ([29]); -store_temp([14]) -> ([30]); -store_temp([15]) -> ([31]); -store_temp>([27]) -> ([32]); -return([28], [29], [30], [31], [32]); -branch_align() -> (); -enum_init, 1>([24]) -> ([33]); -store_temp([12]) -> ([34]); -store_temp([13]) -> ([35]); -store_temp([14]) -> ([36]); -store_temp([15]) -> ([37]); -store_temp>([33]) -> ([38]); -return([34], [35], [36], [37], [38]); -struct_deconstruct([4]) -> ([7], [8], [9], [10], [11], [12]); -drop([7]) -> (); -drop([8]) -> (); -drop([9]) -> (); -drop([10]) -> (); -drop([11]) -> (); -struct_construct>([5], [6]) -> ([13]); -store_temp([0]) -> ([19]); -store_temp([1]) -> ([20]); -store_temp([2]) -> ([21]); -store_temp([3]) -> ([22]); -store_temp([12]) -> ([23]); -store_temp>([13]) -> ([24]); -function_call([19], [20], [21], [22], [23], [24]) -> ([14], [15], [16], [17], [18]); -enum_match>([18]) { fallthrough([25]) 1897([26]) }; -branch_align() -> (); -struct_deconstruct>([25]) -> ([27]); -struct_construct>([27]) -> ([28]); -enum_init, 0>([28]) -> ([29]); -store_temp([14]) -> ([30]); -store_temp([15]) -> ([31]); -store_temp([16]) -> ([32]); -store_temp([17]) -> ([33]); -store_temp>([29]) -> ([34]); -return([30], [31], [32], [33], [34]); -branch_align() -> (); -enum_init, 1>([26]) -> ([35]); -store_temp([14]) -> ([36]); -store_temp([15]) -> ([37]); -store_temp([16]) -> ([38]); -store_temp([17]) -> ([39]); -store_temp>([35]) -> ([40]); -return([36], [37], [38], [39], [40]); -store_temp([0]) -> ([5]); -store_temp>([1]) -> ([6]); -function_call([5], [6]) -> ([2], [3], [4]); -enum_match>([4]) { fallthrough([7]) 1928([8]) }; -branch_align() -> (); -store_temp([2]) -> ([12]); -store_temp>([3]) -> ([13]); -function_call([12], [13]) -> ([9], [10], [11]); -enum_match>([11]) { fallthrough([14]) 1921([15]) }; -branch_align() -> (); -struct_construct([7], [14]) -> ([16]); -enum_init, 0>([16]) -> ([17]); -store_temp([9]) -> ([18]); -store_temp>([10]) -> ([19]); -store_temp>([17]) -> ([20]); -return([18], [19], [20]); -branch_align() -> (); -drop([7]) -> (); -enum_init, 1>([15]) -> ([21]); -store_temp([9]) -> ([22]); -store_temp>([10]) -> ([23]); -store_temp>([21]) -> ([24]); -return([22], [23], [24]); -branch_align() -> (); -enum_init, 1>([8]) -> ([25]); -store_temp([2]) -> ([26]); -store_temp>([3]) -> ([27]); -store_temp>([25]) -> ([28]); -return([26], [27], [28]); -store_temp([1]) -> ([10]); -store_temp([3]) -> ([11]); -function_call([10], [11]) -> ([7], [8], [9]); -enum_match>([9]) { fallthrough([12]) 1970([13]) }; -branch_align() -> (); -struct_deconstruct>([12]) -> ([14]); -store_temp([0]) -> ([20]); -store_temp([7]) -> ([21]); -store_temp([2]) -> ([22]); -store_temp([8]) -> ([23]); -store_temp([4]) -> ([24]); -store_temp([14]) -> ([25]); -store_temp([5]) -> ([26]); -store_temp([6]) -> ([27]); -function_call([20], [21], [22], [23], [24], [25], [26], [27]) -> ([15], [16], [17], [18], [19]); -enum_match>([19]) { fallthrough([28]) 1962([29]) }; -branch_align() -> (); -struct_deconstruct>([28]) -> ([30], [31]); -drop([31]) -> (); -struct_construct() -> ([32]); -struct_construct>([30], [32]) -> ([33]); -enum_init, 0>([33]) -> ([34]); -store_temp([15]) -> ([35]); -store_temp([16]) -> ([36]); -store_temp([17]) -> ([37]); -store_temp([18]) -> ([38]); -store_temp>([34]) -> ([39]); -return([35], [36], [37], [38], [39]); -branch_align() -> (); -enum_init, 1>([29]) -> ([40]); -store_temp([15]) -> ([41]); -store_temp([16]) -> ([42]); -store_temp([17]) -> ([43]); -store_temp([18]) -> ([44]); -store_temp>([40]) -> ([45]); -return([41], [42], [43], [44], [45]); -branch_align() -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([4]) -> (); -enum_init, 1>([13]) -> ([46]); -store_temp([0]) -> ([47]); -store_temp([7]) -> ([48]); -store_temp([2]) -> ([49]); -store_temp([8]) -> ([50]); -store_temp>([46]) -> ([51]); -return([47], [48], [49], [50], [51]); -store_temp([1]) -> ([11]); -store_temp([3]) -> ([12]); -function_call([11], [12]) -> ([8], [9], [10]); -enum_match>([10]) { fallthrough([13]) 2043([14]) }; -branch_align() -> (); -struct_deconstruct>([13]) -> ([15]); -store_temp([0]) -> ([21]); -store_temp([8]) -> ([22]); -store_temp([2]) -> ([23]); -store_temp([9]) -> ([24]); -store_temp([4]) -> ([25]); -dup([5]) -> ([5], [26]); -store_temp([26]) -> ([26]); -store_temp([15]) -> ([27]); -dup([7]) -> ([7], [28]); -store_temp([28]) -> ([28]); -function_call([21], [22], [23], [24], [25], [26], [27], [28]) -> ([16], [17], [18], [19], [20]); -enum_match>([20]) { fallthrough([29]) 2032([30]) }; -branch_align() -> (); -struct_deconstruct>([29]) -> ([31], [32]); -drop([32]) -> (); -store_temp([16]) -> ([38]); -store_temp([17]) -> ([39]); -store_temp([18]) -> ([40]); -store_temp([19]) -> ([41]); -store_temp([31]) -> ([42]); -store_temp([5]) -> ([43]); -store_temp([6]) -> ([44]); -store_temp([7]) -> ([45]); -function_call([38], [39], [40], [41], [42], [43], [44], [45]) -> ([33], [34], [35], [36], [37]); -enum_match>([37]) { fallthrough([46]) 2024([47]) }; -branch_align() -> (); -struct_deconstruct>([46]) -> ([48], [49]); -drop([49]) -> (); -struct_construct() -> ([50]); -struct_construct>([48], [50]) -> ([51]); -enum_init, 0>([51]) -> ([52]); -store_temp([33]) -> ([53]); -store_temp([34]) -> ([54]); -store_temp([35]) -> ([55]); -store_temp([36]) -> ([56]); -store_temp>([52]) -> ([57]); -return([53], [54], [55], [56], [57]); -branch_align() -> (); -enum_init, 1>([47]) -> ([58]); -store_temp([33]) -> ([59]); -store_temp([34]) -> ([60]); -store_temp([35]) -> ([61]); -store_temp([36]) -> ([62]); -store_temp>([58]) -> ([63]); -return([59], [60], [61], [62], [63]); -branch_align() -> (); -drop([7]) -> (); -drop([6]) -> (); -drop([5]) -> (); -enum_init, 1>([30]) -> ([64]); -store_temp([16]) -> ([65]); -store_temp([17]) -> ([66]); -store_temp([18]) -> ([67]); -store_temp([19]) -> ([68]); -store_temp>([64]) -> ([69]); -return([65], [66], [67], [68], [69]); -branch_align() -> (); -drop([7]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([4]) -> (); -enum_init, 1>([14]) -> ([70]); -store_temp([0]) -> ([71]); -store_temp([8]) -> ([72]); -store_temp([2]) -> ([73]); -store_temp([9]) -> ([74]); -store_temp>([70]) -> ([75]); -return([71], [72], [73], [74], [75]); -store_temp([1]) -> ([10]); -store_temp([3]) -> ([11]); -function_call([10], [11]) -> ([7], [8], [9]); -enum_match>([9]) { fallthrough([12]) 2091([13]) }; -branch_align() -> (); -struct_deconstruct>([12]) -> ([14]); -store_temp([0]) -> ([20]); -store_temp([7]) -> ([21]); -store_temp([2]) -> ([22]); -store_temp([8]) -> ([23]); -store_temp([4]) -> ([24]); -store_temp([14]) -> ([25]); -store_temp([5]) -> ([26]); -store_temp([6]) -> ([27]); -function_call([20], [21], [22], [23], [24], [25], [26], [27]) -> ([15], [16], [17], [18], [19]); -enum_match>([19]) { fallthrough([28]) 2083([29]) }; -branch_align() -> (); -struct_deconstruct>([28]) -> ([30], [31]); -drop([31]) -> (); -struct_construct() -> ([32]); -struct_construct>([30], [32]) -> ([33]); -enum_init, 0>([33]) -> ([34]); -store_temp([15]) -> ([35]); -store_temp([16]) -> ([36]); -store_temp([17]) -> ([37]); -store_temp([18]) -> ([38]); -store_temp>([34]) -> ([39]); -return([35], [36], [37], [38], [39]); -branch_align() -> (); -enum_init, 1>([29]) -> ([40]); -store_temp([15]) -> ([41]); -store_temp([16]) -> ([42]); -store_temp([17]) -> ([43]); -store_temp([18]) -> ([44]); -store_temp>([40]) -> ([45]); -return([41], [42], [43], [44], [45]); -branch_align() -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([4]) -> (); -enum_init, 1>([13]) -> ([46]); -store_temp([0]) -> ([47]); -store_temp([7]) -> ([48]); -store_temp([2]) -> ([49]); -store_temp([8]) -> ([50]); -store_temp>([46]) -> ([51]); -return([47], [48], [49], [50], [51]); -store_temp([1]) -> ([10]); -store_temp([3]) -> ([11]); -function_call([10], [11]) -> ([7], [8], [9]); -enum_match>([9]) { fallthrough([12]) 2194([13]) }; -branch_align() -> (); -struct_deconstruct([4]) -> ([14], [15], [16], [17], [18], [19]); -snapshot_take([19]) -> ([20], [21]); -struct_deconstruct>([12]) -> ([22]); -dup([22]) -> ([22], [23]); -dup([5]) -> ([5], [24]); -struct_construct>([23], [24]) -> ([25]); -store_temp([0]) -> ([31]); -store_temp([7]) -> ([32]); -store_temp([2]) -> ([33]); -store_temp([8]) -> ([34]); -store_temp([21]) -> ([35]); -store_temp>([25]) -> ([36]); -function_call([31], [32], [33], [34], [35], [36]) -> ([26], [27], [28], [29], [30]); -enum_match>([30]) { fallthrough([37]) 2177([38]) }; -branch_align() -> (); -struct_deconstruct>([37]) -> ([39]); -store_temp([26]) -> ([42]); -store_temp([39]) -> ([43]); -store_temp([6]) -> ([44]); -function_call([42], [43], [44]) -> ([40], [41]); -enum_match>([41]) { fallthrough([45]) 2161([46]) }; -branch_align() -> (); -struct_deconstruct>([45]) -> ([47]); -struct_construct([14], [15], [16], [17], [18], [20]) -> ([48]); -store_temp([40]) -> ([54]); -store_temp([27]) -> ([55]); -store_temp([28]) -> ([56]); -store_temp([29]) -> ([57]); -store_temp([48]) -> ([58]); -store_temp([22]) -> ([59]); -store_temp([5]) -> ([60]); -store_temp([47]) -> ([61]); -function_call([54], [55], [56], [57], [58], [59], [60], [61]) -> ([49], [50], [51], [52], [53]); -enum_match>([53]) { fallthrough([62]) 2153([63]) }; -branch_align() -> (); -struct_deconstruct>([62]) -> ([64], [65]); -drop([65]) -> (); -struct_construct() -> ([66]); -struct_construct>([64], [66]) -> ([67]); -enum_init, 0>([67]) -> ([68]); -store_temp([49]) -> ([69]); -store_temp([50]) -> ([70]); -store_temp([51]) -> ([71]); -store_temp([52]) -> ([72]); -store_temp>([68]) -> ([73]); -return([69], [70], [71], [72], [73]); -branch_align() -> (); -enum_init, 1>([63]) -> ([74]); -store_temp([49]) -> ([75]); -store_temp([50]) -> ([76]); -store_temp([51]) -> ([77]); -store_temp([52]) -> ([78]); -store_temp>([74]) -> ([79]); -return([75], [76], [77], [78], [79]); -branch_align() -> (); -drop([14]) -> (); -drop([5]) -> (); -drop([22]) -> (); -drop([20]) -> (); -drop([18]) -> (); -drop([17]) -> (); -drop([16]) -> (); -drop([15]) -> (); -enum_init, 1>([46]) -> ([80]); -store_temp([40]) -> ([81]); -store_temp([27]) -> ([82]); -store_temp([28]) -> ([83]); -store_temp([29]) -> ([84]); -store_temp>([80]) -> ([85]); -return([81], [82], [83], [84], [85]); -branch_align() -> (); -drop([14]) -> (); -drop([5]) -> (); -drop([22]) -> (); -drop([15]) -> (); -drop([20]) -> (); -drop([18]) -> (); -drop([17]) -> (); -drop([16]) -> (); -drop([6]) -> (); -enum_init, 1>([38]) -> ([86]); -store_temp([26]) -> ([87]); -store_temp([27]) -> ([88]); -store_temp([28]) -> ([89]); -store_temp([29]) -> ([90]); -store_temp>([86]) -> ([91]); -return([87], [88], [89], [90], [91]); -branch_align() -> (); -drop([4]) -> (); -drop([5]) -> (); -drop([6]) -> (); -enum_init, 1>([13]) -> ([92]); -store_temp([0]) -> ([93]); -store_temp([7]) -> ([94]); -store_temp([2]) -> ([95]); -store_temp([8]) -> ([96]); -store_temp>([92]) -> ([97]); -return([93], [94], [95], [96], [97]); -store_temp([1]) -> ([10]); -store_temp([3]) -> ([11]); -function_call([10], [11]) -> ([7], [8], [9]); -enum_match>([9]) { fallthrough([12]) 2297([13]) }; -branch_align() -> (); -struct_deconstruct([4]) -> ([14], [15], [16], [17], [18], [19]); -snapshot_take([19]) -> ([20], [21]); -struct_deconstruct>([12]) -> ([22]); -dup([22]) -> ([22], [23]); -dup([5]) -> ([5], [24]); -struct_construct>([23], [24]) -> ([25]); -store_temp([0]) -> ([31]); -store_temp([7]) -> ([32]); -store_temp([2]) -> ([33]); -store_temp([8]) -> ([34]); -store_temp([21]) -> ([35]); -store_temp>([25]) -> ([36]); -function_call([31], [32], [33], [34], [35], [36]) -> ([26], [27], [28], [29], [30]); -enum_match>([30]) { fallthrough([37]) 2280([38]) }; -branch_align() -> (); -struct_deconstruct>([37]) -> ([39]); -store_temp([26]) -> ([42]); -store_temp([39]) -> ([43]); -store_temp([6]) -> ([44]); -function_call([42], [43], [44]) -> ([40], [41]); -enum_match>([41]) { fallthrough([45]) 2264([46]) }; -branch_align() -> (); -struct_deconstruct>([45]) -> ([47]); -struct_construct([14], [15], [16], [17], [18], [20]) -> ([48]); -store_temp([40]) -> ([54]); -store_temp([27]) -> ([55]); -store_temp([28]) -> ([56]); -store_temp([29]) -> ([57]); -store_temp([48]) -> ([58]); -store_temp([22]) -> ([59]); -store_temp([5]) -> ([60]); -store_temp([47]) -> ([61]); -function_call([54], [55], [56], [57], [58], [59], [60], [61]) -> ([49], [50], [51], [52], [53]); -enum_match>([53]) { fallthrough([62]) 2256([63]) }; -branch_align() -> (); -struct_deconstruct>([62]) -> ([64], [65]); -drop([65]) -> (); -struct_construct() -> ([66]); -struct_construct>([64], [66]) -> ([67]); -enum_init, 0>([67]) -> ([68]); -store_temp([49]) -> ([69]); -store_temp([50]) -> ([70]); -store_temp([51]) -> ([71]); -store_temp([52]) -> ([72]); -store_temp>([68]) -> ([73]); -return([69], [70], [71], [72], [73]); -branch_align() -> (); -enum_init, 1>([63]) -> ([74]); -store_temp([49]) -> ([75]); -store_temp([50]) -> ([76]); -store_temp([51]) -> ([77]); -store_temp([52]) -> ([78]); -store_temp>([74]) -> ([79]); -return([75], [76], [77], [78], [79]); -branch_align() -> (); -drop([14]) -> (); -drop([5]) -> (); -drop([22]) -> (); -drop([20]) -> (); -drop([18]) -> (); -drop([17]) -> (); -drop([16]) -> (); -drop([15]) -> (); -enum_init, 1>([46]) -> ([80]); -store_temp([40]) -> ([81]); -store_temp([27]) -> ([82]); -store_temp([28]) -> ([83]); -store_temp([29]) -> ([84]); -store_temp>([80]) -> ([85]); -return([81], [82], [83], [84], [85]); -branch_align() -> (); -drop([14]) -> (); -drop([5]) -> (); -drop([22]) -> (); -drop([15]) -> (); -drop([20]) -> (); -drop([18]) -> (); -drop([17]) -> (); -drop([16]) -> (); -drop([6]) -> (); -enum_init, 1>([38]) -> ([86]); -store_temp([26]) -> ([87]); -store_temp([27]) -> ([88]); -store_temp([28]) -> ([89]); -store_temp([29]) -> ([90]); -store_temp>([86]) -> ([91]); -return([87], [88], [89], [90], [91]); -branch_align() -> (); -drop([4]) -> (); -drop([5]) -> (); -drop([6]) -> (); -enum_init, 1>([13]) -> ([92]); -store_temp([0]) -> ([93]); -store_temp([7]) -> ([94]); -store_temp([2]) -> ([95]); -store_temp([8]) -> ([96]); -store_temp>([92]) -> ([97]); -return([93], [94], [95], [96], [97]); -struct_deconstruct>([0]) -> ([1]); -array_snapshot_pop_front([1]) { fallthrough([2], [3]) 2315([4]) }; -branch_align() -> (); -enum_init>, 0>([3]) -> ([5]); -store_temp>>([2]) -> ([6]); -store_temp>>([5]) -> ([7]); -jump() { 2320() }; -branch_align() -> (); -struct_construct() -> ([8]); -enum_init>, 1>([8]) -> ([9]); -store_temp>>([4]) -> ([6]); -store_temp>>([9]) -> ([7]); -struct_construct>([6]) -> ([10]); -store_temp>([10]) -> ([10]); -enum_match>>([7]) { fallthrough([11]) 2330([12]) }; -branch_align() -> (); -unbox([11]) -> ([13]); -rename([13]) -> ([14]); -enum_init, 0>([14]) -> ([15]); -store_temp>([10]) -> ([16]); -store_temp>([15]) -> ([17]); -return([16], [17]); -branch_align() -> (); -drop([12]) -> (); -struct_construct() -> ([18]); -enum_init, 1>([18]) -> ([19]); -store_temp>([10]) -> ([20]); -store_temp>([19]) -> ([21]); -return([20], [21]); -struct_deconstruct>([1]) -> ([2]); -array_snapshot_pop_front([2]) { fallthrough([3], [4]) 2344([5]) }; -branch_align() -> (); -enum_init>, 0>([4]) -> ([6]); -store_temp>>([3]) -> ([7]); -store_temp>>([6]) -> ([8]); -jump() { 2349() }; -branch_align() -> (); -struct_construct() -> ([9]); -enum_init>, 1>([9]) -> ([10]); -store_temp>>([5]) -> ([7]); -store_temp>>([10]) -> ([8]); -struct_construct>([7]) -> ([11]); -store_temp>([11]) -> ([11]); -enum_match>>([8]) { fallthrough([12]) 2371([13]) }; -branch_align() -> (); -unbox([12]) -> ([14]); -rename([14]) -> ([15]); -store_temp([0]) -> ([18]); -store_temp([15]) -> ([19]); -function_call([18], [19]) -> ([16], [17]); -enum_match>([17]) { fallthrough([20]) 2365([21]) }; -branch_align() -> (); -enum_init, 0>([20]) -> ([22]); -store_temp([16]) -> ([23]); -store_temp>([11]) -> ([24]); -store_temp>([22]) -> ([25]); -return([23], [24], [25]); -branch_align() -> (); -enum_init, 1>([21]) -> ([26]); -store_temp([16]) -> ([27]); -store_temp>([11]) -> ([28]); -store_temp>([26]) -> ([29]); -return([27], [28], [29]); -branch_align() -> (); -drop([13]) -> (); -struct_construct() -> ([30]); -enum_init, 1>([30]) -> ([31]); -store_temp([0]) -> ([32]); -store_temp>([11]) -> ([33]); -store_temp>([31]) -> ([34]); -return([32], [33], [34]); -struct_deconstruct([4]) -> ([10], [11], [12], [13], [14], [15]); -store_temp([1]) -> ([19]); -store_temp([3]) -> ([20]); -store_temp([10]) -> ([21]); -store_temp([5]) -> ([22]); -function_call([19], [20], [21], [22]) -> ([16], [17], [18]); -enum_match>([18]) { fallthrough([23]) 2572([24]) }; -branch_align() -> (); -store_temp([16]) -> ([28]); -store_temp([17]) -> ([29]); -store_temp([11]) -> ([30]); -store_temp([6]) -> ([31]); -function_call([28], [29], [30], [31]) -> ([25], [26], [27]); -enum_match>([27]) { fallthrough([32]) 2556([33]) }; -branch_align() -> (); -store_temp([25]) -> ([37]); -store_temp([26]) -> ([38]); -store_temp([12]) -> ([39]); -store_temp([7]) -> ([40]); -function_call([37], [38], [39], [40]) -> ([34], [35], [36]); -enum_match>([36]) { fallthrough([41]) 2541([42]) }; -branch_align() -> (); -dup([9]) -> ([9], [44]); -contract_address_to_felt252([44]) -> ([43]); -snapshot_take([43]) -> ([45], [46]); -drop([45]) -> (); -felt252_const<0>() -> ([47]); -snapshot_take([47]) -> ([48], [49]); -drop([48]) -> (); -rename([46]) -> ([50]); -rename([49]) -> ([51]); -felt252_sub([50], [51]) -> ([52]); -struct_deconstruct>([23]) -> ([53], [54]); -drop([54]) -> (); -struct_deconstruct>([32]) -> ([55], [56]); -drop([56]) -> (); -struct_deconstruct>([41]) -> ([57], [58]); -drop([58]) -> (); -store_temp([52]) -> ([52]); -felt252_is_zero([52]) { fallthrough() 2424([59]) }; -branch_align() -> (); -struct_construct() -> ([60]); -enum_init([60]) -> ([61]); -store_temp([61]) -> ([62]); -jump() { 2429() }; -branch_align() -> (); -drop>([59]) -> (); -struct_construct() -> ([63]); -enum_init([63]) -> ([64]); -store_temp([64]) -> ([62]); -bool_not_impl([62]) -> ([65]); -store_temp([65]) -> ([65]); -enum_match([65]) { fallthrough([66]) 2455([67]) }; -branch_align() -> (); -drop([66]) -> (); -drop([9]) -> (); -drop([55]) -> (); -drop([53]) -> (); -drop([8]) -> (); -drop([57]) -> (); -drop([15]) -> (); -drop([14]) -> (); -drop([13]) -> (); -array_new() -> ([68]); -felt252_const<7300388948442106731950660484798539862217172507820428101544021685107>() -> ([69]); -store_temp([69]) -> ([69]); -array_append([68], [69]) -> ([70]); -struct_construct() -> ([71]); -struct_construct>>([71], [70]) -> ([72]); -enum_init, 1>([72]) -> ([73]); -store_temp([0]) -> ([74]); -store_temp([34]) -> ([75]); -store_temp([2]) -> ([76]); -store_temp([35]) -> ([77]); -store_temp>([73]) -> ([78]); -return([74], [75], [76], [77], [78]); -branch_align() -> (); -drop([67]) -> (); -store_temp([34]) -> ([82]); -store_temp([35]) -> ([83]); -store_temp([13]) -> ([84]); -dup([8]) -> ([8], [85]); -store_temp([85]) -> ([85]); -function_call([82], [83], [84], [85]) -> ([79], [80], [81]); -enum_match>([81]) { fallthrough([86]) 2526([87]) }; -branch_align() -> (); -store_temp([0]) -> ([93]); -store_temp([79]) -> ([94]); -store_temp([2]) -> ([95]); -store_temp([80]) -> ([96]); -store_temp([14]) -> ([97]); -dup([9]) -> ([9], [98]); -store_temp([98]) -> ([98]); -dup([8]) -> ([8], [99]); -store_temp([99]) -> ([99]); -function_call([93], [94], [95], [96], [97], [98], [99]) -> ([88], [89], [90], [91], [92]); -enum_match>([92]) { fallthrough([100]) 2511([101]) }; -branch_align() -> (); -contract_address_const<0>() -> ([102]); -struct_deconstruct>([86]) -> ([103], [104]); -drop([104]) -> (); -struct_deconstruct>([100]) -> ([105], [106]); -drop([106]) -> (); -struct_construct([102], [9], [8]) -> ([107]); -enum_init([107]) -> ([108]); -struct_construct([53], [55], [57], [103], [105], [15]) -> ([109]); -store_temp([89]) -> ([113]); -store_temp([91]) -> ([114]); -store_temp([109]) -> ([115]); -store_temp([108]) -> ([116]); -function_call>>([113], [114], [115], [116]) -> ([110], [111], [112]); -enum_match>([112]) { fallthrough([117]) 2503([118]) }; -branch_align() -> (); -struct_deconstruct>([117]) -> ([119], [120]); -drop([120]) -> (); -struct_construct() -> ([121]); -struct_construct>([119], [121]) -> ([122]); -enum_init, 0>([122]) -> ([123]); -store_temp([88]) -> ([124]); -store_temp([110]) -> ([125]); -store_temp([90]) -> ([126]); -store_temp([111]) -> ([127]); -store_temp>([123]) -> ([128]); -return([124], [125], [126], [127], [128]); -branch_align() -> (); -enum_init, 1>([118]) -> ([129]); -store_temp([88]) -> ([130]); -store_temp([110]) -> ([131]); -store_temp([90]) -> ([132]); -store_temp([111]) -> ([133]); -store_temp>([129]) -> ([134]); -return([130], [131], [132], [133], [134]); -branch_align() -> (); -drop([53]) -> (); -drop([15]) -> (); -drop>([86]) -> (); -drop([9]) -> (); -drop([57]) -> (); -drop([55]) -> (); -drop([8]) -> (); -enum_init, 1>([101]) -> ([135]); -store_temp([88]) -> ([136]); -store_temp([89]) -> ([137]); -store_temp([90]) -> ([138]); -store_temp([91]) -> ([139]); -store_temp>([135]) -> ([140]); -return([136], [137], [138], [139], [140]); -branch_align() -> (); -drop([9]) -> (); -drop([55]) -> (); -drop([53]) -> (); -drop([8]) -> (); -drop([57]) -> (); -drop([15]) -> (); -drop([14]) -> (); -enum_init, 1>([87]) -> ([141]); -store_temp([0]) -> ([142]); -store_temp([79]) -> ([143]); -store_temp([2]) -> ([144]); -store_temp([80]) -> ([145]); -store_temp>([141]) -> ([146]); -return([142], [143], [144], [145], [146]); -branch_align() -> (); -drop([9]) -> (); -drop([13]) -> (); -drop>([32]) -> (); -drop([8]) -> (); -drop>([23]) -> (); -drop([15]) -> (); -drop([14]) -> (); -enum_init, 1>([42]) -> ([147]); -store_temp([0]) -> ([148]); -store_temp([34]) -> ([149]); -store_temp([2]) -> ([150]); -store_temp([35]) -> ([151]); -store_temp>([147]) -> ([152]); -return([148], [149], [150], [151], [152]); -branch_align() -> (); -drop([14]) -> (); -drop([15]) -> (); -drop([9]) -> (); -drop([13]) -> (); -drop([8]) -> (); -drop>([23]) -> (); -drop([7]) -> (); -drop([12]) -> (); -enum_init, 1>([33]) -> ([153]); -store_temp([0]) -> ([154]); -store_temp([25]) -> ([155]); -store_temp([2]) -> ([156]); -store_temp([26]) -> ([157]); -store_temp>([153]) -> ([158]); -return([154], [155], [156], [157], [158]); -branch_align() -> (); -drop([14]) -> (); -drop([15]) -> (); -drop([9]) -> (); -drop([13]) -> (); -drop([12]) -> (); -drop([8]) -> (); -drop([7]) -> (); -drop([6]) -> (); -drop([11]) -> (); -enum_init, 1>([24]) -> ([159]); -store_temp([0]) -> ([160]); -store_temp([16]) -> ([161]); -store_temp([2]) -> ([162]); -store_temp([17]) -> ([163]); -store_temp>([159]) -> ([164]); -return([160], [161], [162], [163], [164]); -drop([2]) -> (); -storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>() -> ([3]); -storage_address_from_base([3]) -> ([4]); -u32_const<0>() -> ([5]); -store_temp([5]) -> ([5]); -store_temp([4]) -> ([4]); -storage_read_syscall([0], [1], [5], [4]) { fallthrough([6], [7], [8]) 2602([9], [10], [11]) }; -branch_align() -> (); -enum_init>, 0>([8]) -> ([12]); -store_temp([6]) -> ([13]); -store_temp([7]) -> ([14]); -store_temp>>([12]) -> ([15]); -jump() { 2607() }; -branch_align() -> (); -enum_init>, 1>([11]) -> ([16]); -store_temp([9]) -> ([13]); -store_temp([10]) -> ([14]); -store_temp>>([16]) -> ([15]); -rename>>([15]) -> ([18]); -function_call::unwrap_syscall>([18]) -> ([17]); -enum_match>([17]) { fallthrough([19]) 2618([20]) }; -branch_align() -> (); -struct_deconstruct>([19]) -> ([21]); -struct_construct>([21]) -> ([22]); -enum_init, 0>([22]) -> ([23]); -store_temp([13]) -> ([24]); -store_temp([14]) -> ([25]); -store_temp>([23]) -> ([26]); -return([24], [25], [26]); -branch_align() -> (); -enum_init, 1>([20]) -> ([27]); -store_temp([13]) -> ([28]); -store_temp([14]) -> ([29]); -store_temp>([27]) -> ([30]); -return([28], [29], [30]); -drop([2]) -> (); -storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>() -> ([3]); -storage_address_from_base([3]) -> ([4]); -u32_const<0>() -> ([5]); -store_temp([5]) -> ([5]); -store_temp([4]) -> ([4]); -storage_read_syscall([0], [1], [5], [4]) { fallthrough([6], [7], [8]) 2637([9], [10], [11]) }; -branch_align() -> (); -enum_init>, 0>([8]) -> ([12]); -store_temp([6]) -> ([13]); -store_temp([7]) -> ([14]); -store_temp>>([12]) -> ([15]); -jump() { 2642() }; -branch_align() -> (); -enum_init>, 1>([11]) -> ([16]); -store_temp([9]) -> ([13]); -store_temp([10]) -> ([14]); -store_temp>>([16]) -> ([15]); -rename>>([15]) -> ([18]); -function_call::unwrap_syscall>([18]) -> ([17]); -enum_match>([17]) { fallthrough([19]) 2653([20]) }; -branch_align() -> (); -struct_deconstruct>([19]) -> ([21]); -struct_construct>([21]) -> ([22]); -enum_init, 0>([22]) -> ([23]); -store_temp([13]) -> ([24]); -store_temp([14]) -> ([25]); -store_temp>([23]) -> ([26]); -return([24], [25], [26]); -branch_align() -> (); -enum_init, 1>([20]) -> ([27]); -store_temp([13]) -> ([28]); -store_temp([14]) -> ([29]); -store_temp>([27]) -> ([30]); -return([28], [29], [30]); -drop([3]) -> (); -storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>() -> ([4]); -u32_const<0>() -> ([5]); -store_temp([0]) -> ([10]); -store_temp([1]) -> ([11]); -store_temp([2]) -> ([12]); -store_temp([5]) -> ([13]); -store_temp([4]) -> ([14]); -function_call([10], [11], [12], [13], [14]) -> ([6], [7], [8], [9]); -enum_match>,)>>([9]) { fallthrough([15]) 2690([16]) }; -branch_align() -> (); -struct_deconstruct>>>([15]) -> ([17]); -store_temp>>([17]) -> ([19]); -function_call::unwrap_syscall>([19]) -> ([18]); -enum_match>([18]) { fallthrough([20]) 2683([21]) }; -branch_align() -> (); -struct_deconstruct>([20]) -> ([22]); -struct_construct>([22]) -> ([23]); -enum_init, 0>([23]) -> ([24]); -store_temp([6]) -> ([25]); -store_temp([7]) -> ([26]); -store_temp([8]) -> ([27]); -store_temp>([24]) -> ([28]); -return([25], [26], [27], [28]); -branch_align() -> (); -enum_init, 1>([21]) -> ([29]); -store_temp([6]) -> ([30]); -store_temp([7]) -> ([31]); -store_temp([8]) -> ([32]); -store_temp>([29]) -> ([33]); -return([30], [31], [32], [33]); -branch_align() -> (); -enum_init, 1>([16]) -> ([34]); -store_temp([6]) -> ([35]); -store_temp([7]) -> ([36]); -store_temp([8]) -> ([37]); -store_temp>([34]) -> ([38]); -return([35], [36], [37], [38]); -drop([3]) -> (); -storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>() -> ([4]); -u32_const<0>() -> ([5]); -store_temp([0]) -> ([10]); -store_temp([1]) -> ([11]); -store_temp([2]) -> ([12]); -store_temp([5]) -> ([13]); -store_temp([4]) -> ([14]); -function_call([10], [11], [12], [13], [14]) -> ([6], [7], [8], [9]); -enum_match>,)>>([9]) { fallthrough([15]) 2728([16]) }; -branch_align() -> (); -struct_deconstruct>>>([15]) -> ([17]); -store_temp>>([17]) -> ([19]); -function_call::unwrap_syscall>([19]) -> ([18]); -enum_match>([18]) { fallthrough([20]) 2721([21]) }; -branch_align() -> (); -struct_deconstruct>([20]) -> ([22]); -struct_construct>([22]) -> ([23]); -enum_init, 0>([23]) -> ([24]); -store_temp([6]) -> ([25]); -store_temp([7]) -> ([26]); -store_temp([8]) -> ([27]); -store_temp>([24]) -> ([28]); -return([25], [26], [27], [28]); -branch_align() -> (); -enum_init, 1>([21]) -> ([29]); -store_temp([6]) -> ([30]); -store_temp([7]) -> ([31]); -store_temp([8]) -> ([32]); -store_temp>([29]) -> ([33]); -return([30], [31], [32], [33]); -branch_align() -> (); -enum_init, 1>([16]) -> ([34]); -store_temp([6]) -> ([35]); -store_temp([7]) -> ([36]); -store_temp([8]) -> ([37]); -store_temp>([34]) -> ([38]); -return([35], [36], [37], [38]); -rename([0]) -> ([2]); -u128_to_felt252([2]) -> ([3]); -snapshot_take([3]) -> ([4], [5]); -drop([4]) -> (); -store_temp([5]) -> ([8]); -store_temp>([1]) -> ([9]); -function_call([8], [9]) -> ([6], [7]); -drop([7]) -> (); -struct_construct() -> ([10]); -store_temp>([6]) -> ([11]); -store_temp([10]) -> ([12]); -return([11], [12]); -store_temp([0]) -> ([9]); -store_temp([2]) -> ([10]); -store_temp([4]) -> ([11]); -store_temp([5]) -> ([12]); -function_call([9], [10], [11], [12]) -> ([6], [7], [8]); -u32_const<0>() -> ([13]); -store_temp([6]) -> ([18]); -store_temp([1]) -> ([19]); -store_temp([3]) -> ([20]); -store_temp([13]) -> ([21]); -store_temp([8]) -> ([22]); -function_call([18], [19], [20], [21], [22]) -> ([14], [15], [16], [17]); -enum_match>,)>>([17]) { fallthrough([23]) 2783([24]) }; -branch_align() -> (); -struct_deconstruct>>>([23]) -> ([25]); -store_temp>>([25]) -> ([27]); -function_call::unwrap_syscall>([27]) -> ([26]); -enum_match>([26]) { fallthrough([28]) 2775([29]) }; -branch_align() -> (); -struct_deconstruct>([28]) -> ([30]); -struct_construct>([30]) -> ([31]); -enum_init, 0>([31]) -> ([32]); -store_temp([14]) -> ([33]); -store_temp([15]) -> ([34]); -store_temp([7]) -> ([35]); -store_temp([16]) -> ([36]); -store_temp>([32]) -> ([37]); -return([33], [34], [35], [36], [37]); -branch_align() -> (); -enum_init, 1>([29]) -> ([38]); -store_temp([14]) -> ([39]); -store_temp([15]) -> ([40]); -store_temp([7]) -> ([41]); -store_temp([16]) -> ([42]); -store_temp>([38]) -> ([43]); -return([39], [40], [41], [42], [43]); -branch_align() -> (); -enum_init, 1>([24]) -> ([44]); -store_temp([14]) -> ([45]); -store_temp([15]) -> ([46]); -store_temp([7]) -> ([47]); -store_temp([16]) -> ([48]); -store_temp>([44]) -> ([49]); -return([45], [46], [47], [48], [49]); -store_temp([0]) -> ([9]); -store_temp([2]) -> ([10]); -store_temp([4]) -> ([11]); -store_temp>([5]) -> ([12]); -function_call([9], [10], [11], [12]) -> ([6], [7], [8]); -u32_const<0>() -> ([13]); -store_temp([6]) -> ([18]); -store_temp([1]) -> ([19]); -store_temp([3]) -> ([20]); -store_temp([13]) -> ([21]); -store_temp([8]) -> ([22]); -function_call([18], [19], [20], [21], [22]) -> ([14], [15], [16], [17]); -enum_match>,)>>([17]) { fallthrough([23]) 2827([24]) }; -branch_align() -> (); -struct_deconstruct>>>([23]) -> ([25]); -store_temp>>([25]) -> ([27]); -function_call::unwrap_syscall>([27]) -> ([26]); -enum_match>([26]) { fallthrough([28]) 2819([29]) }; -branch_align() -> (); -struct_deconstruct>([28]) -> ([30]); -struct_construct>([30]) -> ([31]); -enum_init, 0>([31]) -> ([32]); -store_temp([14]) -> ([33]); -store_temp([15]) -> ([34]); -store_temp([7]) -> ([35]); -store_temp([16]) -> ([36]); -store_temp>([32]) -> ([37]); -return([33], [34], [35], [36], [37]); -branch_align() -> (); -enum_init, 1>([29]) -> ([38]); -store_temp([14]) -> ([39]); -store_temp([15]) -> ([40]); -store_temp([7]) -> ([41]); -store_temp([16]) -> ([42]); -store_temp>([38]) -> ([43]); -return([39], [40], [41], [42], [43]); -branch_align() -> (); -enum_init, 1>([24]) -> ([44]); -store_temp([14]) -> ([45]); -store_temp([15]) -> ([46]); -store_temp([7]) -> ([47]); -store_temp([16]) -> ([48]); -store_temp>([44]) -> ([49]); -return([45], [46], [47], [48], [49]); -struct_deconstruct>([1]) -> ([2]); -array_snapshot_pop_front([2]) { fallthrough([3], [4]) 2842([5]) }; -branch_align() -> (); -enum_init>, 0>([4]) -> ([6]); -store_temp>>([3]) -> ([7]); -store_temp>>([6]) -> ([8]); -jump() { 2847() }; -branch_align() -> (); -struct_construct() -> ([9]); -enum_init>, 1>([9]) -> ([10]); -store_temp>>([5]) -> ([7]); -store_temp>>([10]) -> ([8]); -struct_construct>([7]) -> ([11]); -store_temp>([11]) -> ([11]); -enum_match>>([8]) { fallthrough([12]) 2869([13]) }; -branch_align() -> (); -unbox([12]) -> ([14]); -rename([14]) -> ([15]); -store_temp([0]) -> ([18]); -store_temp([15]) -> ([19]); -function_call([18], [19]) -> ([16], [17]); -enum_match>([17]) { fallthrough([20]) 2863([21]) }; -branch_align() -> (); -enum_init, 0>([20]) -> ([22]); -store_temp([16]) -> ([23]); -store_temp>([11]) -> ([24]); -store_temp>([22]) -> ([25]); -return([23], [24], [25]); -branch_align() -> (); -enum_init, 1>([21]) -> ([26]); -store_temp([16]) -> ([27]); -store_temp>([11]) -> ([28]); -store_temp>([26]) -> ([29]); -return([27], [28], [29]); -branch_align() -> (); -drop([13]) -> (); -struct_construct() -> ([30]); -enum_init, 1>([30]) -> ([31]); -store_temp([0]) -> ([32]); -store_temp>([11]) -> ([33]); -store_temp>([31]) -> ([34]); -return([32], [33], [34]); -store_temp([0]) -> ([5]); -store_temp([1]) -> ([6]); -function_call([5], [6]) -> ([2], [3], [4]); -enum_match,)>>([4]) { fallthrough([7]) 2895([8]) }; -branch_align() -> (); -struct_deconstruct>>([7]) -> ([9]); -unbox([9]) -> ([10]); -struct_deconstruct([10]) -> ([11], [12], [13], [14], [15]); -drop>([11]) -> (); -drop>([12]) -> (); -drop([14]) -> (); -drop([15]) -> (); -struct_construct>([13]) -> ([16]); -enum_init, 0>([16]) -> ([17]); -store_temp([2]) -> ([18]); -store_temp([3]) -> ([19]); -store_temp>([17]) -> ([20]); -return([18], [19], [20]); -branch_align() -> (); -enum_init, 1>([8]) -> ([21]); -store_temp([2]) -> ([22]); -store_temp([3]) -> ([23]); -store_temp>([21]) -> ([24]); -return([22], [23], [24]); -dup([5]) -> ([5], [9]); -contract_address_to_felt252([9]) -> ([8]); -snapshot_take([8]) -> ([10], [11]); -drop([10]) -> (); -felt252_const<0>() -> ([12]); -snapshot_take([12]) -> ([13], [14]); -drop([13]) -> (); -rename([11]) -> ([15]); -rename([14]) -> ([16]); -felt252_sub([15], [16]) -> ([17]); -store_temp([17]) -> ([17]); -felt252_is_zero([17]) { fallthrough() 2918([18]) }; -branch_align() -> (); -struct_construct() -> ([19]); -enum_init([19]) -> ([20]); -store_temp([20]) -> ([21]); -jump() { 2923() }; -branch_align() -> (); -drop>([18]) -> (); -struct_construct() -> ([22]); -enum_init([22]) -> ([23]); -store_temp([23]) -> ([21]); -bool_not_impl([21]) -> ([24]); -store_temp([24]) -> ([24]); -enum_match([24]) { fallthrough([25]) 2945([26]) }; -branch_align() -> (); -drop([25]) -> (); -drop([7]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([4]) -> (); -array_new() -> ([27]); -felt252_const<25936191677694277552149992725516921697451103245639728>() -> ([28]); -store_temp([28]) -> ([28]); -array_append([27], [28]) -> ([29]); -struct_construct() -> ([30]); -struct_construct>>([30], [29]) -> ([31]); -enum_init, 1>([31]) -> ([32]); -store_temp([0]) -> ([33]); -store_temp([1]) -> ([34]); -store_temp([2]) -> ([35]); -store_temp([3]) -> ([36]); -store_temp>([32]) -> ([37]); -return([33], [34], [35], [36], [37]); -branch_align() -> (); -drop([26]) -> (); -dup([6]) -> ([6], [39]); -contract_address_to_felt252([39]) -> ([38]); -snapshot_take([38]) -> ([40], [41]); -drop([40]) -> (); -felt252_const<0>() -> ([42]); -snapshot_take([42]) -> ([43], [44]); -drop([43]) -> (); -rename([41]) -> ([45]); -rename([44]) -> ([46]); -felt252_sub([45], [46]) -> ([47]); -store_temp([47]) -> ([47]); -felt252_is_zero([47]) { fallthrough() 2964([48]) }; -branch_align() -> (); -struct_construct() -> ([49]); -enum_init([49]) -> ([50]); -store_temp([50]) -> ([51]); -jump() { 2969() }; -branch_align() -> (); -drop>([48]) -> (); -struct_construct() -> ([52]); -enum_init([52]) -> ([53]); -store_temp([53]) -> ([51]); -bool_not_impl([51]) -> ([54]); -store_temp([54]) -> ([54]); -enum_match([54]) { fallthrough([55]) 2991([56]) }; -branch_align() -> (); -drop([55]) -> (); -drop([7]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([4]) -> (); -array_new() -> ([57]); -felt252_const<395754877894504967531585582359572169455970492464>() -> ([58]); -store_temp([58]) -> ([58]); -array_append([57], [58]) -> ([59]); -struct_construct() -> ([60]); -struct_construct>>([60], [59]) -> ([61]); -enum_init, 1>([61]) -> ([62]); -store_temp([0]) -> ([63]); -store_temp([1]) -> ([64]); -store_temp([2]) -> ([65]); -store_temp([3]) -> ([66]); -store_temp>([62]) -> ([67]); -return([63], [64], [65], [66], [67]); -branch_align() -> (); -drop([56]) -> (); -struct_deconstruct([4]) -> ([68], [69], [70], [71], [72], [73]); -snapshot_take([72]) -> ([74], [75]); -store_temp([0]) -> ([81]); -store_temp([1]) -> ([82]); -store_temp([2]) -> ([83]); -store_temp([3]) -> ([84]); -store_temp([75]) -> ([85]); -dup([5]) -> ([5], [86]); -store_temp([86]) -> ([86]); -function_call([81], [82], [83], [84], [85], [86]) -> ([76], [77], [78], [79], [80]); -enum_match>([80]) { fallthrough([87]) 3171([88]) }; -branch_align() -> (); -struct_deconstruct>([87]) -> ([89]); -store_temp([76]) -> ([92]); -store_temp([89]) -> ([93]); -dup([7]) -> ([7], [94]); -store_temp([94]) -> ([94]); -function_call([92], [93], [94]) -> ([90], [91]); -enum_match>([91]) { fallthrough([95]) 3154([96]) }; -branch_align() -> (); -struct_deconstruct>([95]) -> ([97]); -store_temp([90]) -> ([103]); -store_temp([77]) -> ([104]); -store_temp([78]) -> ([105]); -store_temp([79]) -> ([106]); -store_temp([74]) -> ([107]); -dup([5]) -> ([5], [108]); -store_temp([108]) -> ([108]); -store_temp([97]) -> ([109]); -function_call([103], [104], [105], [106], [107], [108], [109]) -> ([98], [99], [100], [101], [102]); -enum_match>([102]) { fallthrough([110]) 3138([111]) }; -branch_align() -> (); -struct_deconstruct>([110]) -> ([112], [113]); -drop([113]) -> (); -snapshot_take([112]) -> ([114], [115]); -store_temp([98]) -> ([121]); -store_temp([99]) -> ([122]); -store_temp([100]) -> ([123]); -store_temp([101]) -> ([124]); -store_temp([115]) -> ([125]); -dup([6]) -> ([6], [126]); -store_temp([126]) -> ([126]); -function_call([121], [122], [123], [124], [125], [126]) -> ([116], [117], [118], [119], [120]); -enum_match>([120]) { fallthrough([127]) 3121([128]) }; -branch_align() -> (); -struct_deconstruct>([127]) -> ([129]); -store_temp([116]) -> ([132]); -store_temp([129]) -> ([133]); -dup([7]) -> ([7], [134]); -store_temp([134]) -> ([134]); -function_call([132], [133], [134]) -> ([130], [131]); -enum_match>([131]) { fallthrough([135]) 3104([136]) }; -branch_align() -> (); -struct_deconstruct>([135]) -> ([137]); -store_temp([130]) -> ([143]); -store_temp([117]) -> ([144]); -store_temp([118]) -> ([145]); -store_temp([119]) -> ([146]); -store_temp([114]) -> ([147]); -dup([6]) -> ([6], [148]); -store_temp([148]) -> ([148]); -store_temp([137]) -> ([149]); -function_call([143], [144], [145], [146], [147], [148], [149]) -> ([138], [139], [140], [141], [142]); -enum_match>([142]) { fallthrough([150]) 3088([151]) }; -branch_align() -> (); -struct_deconstruct>([150]) -> ([152], [153]); -drop([153]) -> (); -struct_construct([5], [6], [7]) -> ([154]); -struct_construct([68], [69], [70], [71], [152], [73]) -> ([155]); -store_temp([139]) -> ([159]); -store_temp([141]) -> ([160]); -store_temp([155]) -> ([161]); -store_temp([154]) -> ([162]); -function_call>([159], [160], [161], [162]) -> ([156], [157], [158]); -enum_match>([158]) { fallthrough([163]) 3080([164]) }; -branch_align() -> (); -struct_deconstruct>([163]) -> ([165], [166]); -drop([166]) -> (); -struct_construct() -> ([167]); -struct_construct>([165], [167]) -> ([168]); -enum_init, 0>([168]) -> ([169]); -store_temp([138]) -> ([170]); -store_temp([156]) -> ([171]); -store_temp([140]) -> ([172]); -store_temp([157]) -> ([173]); -store_temp>([169]) -> ([174]); -return([170], [171], [172], [173], [174]); -branch_align() -> (); -enum_init, 1>([164]) -> ([175]); -store_temp([138]) -> ([176]); -store_temp([156]) -> ([177]); -store_temp([140]) -> ([178]); -store_temp([157]) -> ([179]); -store_temp>([175]) -> ([180]); -return([176], [177], [178], [179], [180]); -branch_align() -> (); -drop([68]) -> (); -drop([73]) -> (); -drop([5]) -> (); -drop([71]) -> (); -drop([70]) -> (); -drop([69]) -> (); -drop([7]) -> (); -drop([6]) -> (); -enum_init, 1>([151]) -> ([181]); -store_temp([138]) -> ([182]); -store_temp([139]) -> ([183]); -store_temp([140]) -> ([184]); -store_temp([141]) -> ([185]); -store_temp>([181]) -> ([186]); -return([182], [183], [184], [185], [186]); -branch_align() -> (); -drop([70]) -> (); -drop([7]) -> (); -drop([68]) -> (); -drop([6]) -> (); -drop([69]) -> (); -drop([73]) -> (); -drop([5]) -> (); -drop([71]) -> (); -drop([114]) -> (); -enum_init, 1>([136]) -> ([187]); -store_temp([130]) -> ([188]); -store_temp([117]) -> ([189]); -store_temp([118]) -> ([190]); -store_temp([119]) -> ([191]); -store_temp>([187]) -> ([192]); -return([188], [189], [190], [191], [192]); -branch_align() -> (); -drop([70]) -> (); -drop([7]) -> (); -drop([68]) -> (); -drop([6]) -> (); -drop([69]) -> (); -drop([73]) -> (); -drop([5]) -> (); -drop([71]) -> (); -drop([114]) -> (); -enum_init, 1>([128]) -> ([193]); -store_temp([116]) -> ([194]); -store_temp([117]) -> ([195]); -store_temp([118]) -> ([196]); -store_temp([119]) -> ([197]); -store_temp>([193]) -> ([198]); -return([194], [195], [196], [197], [198]); -branch_align() -> (); -drop([70]) -> (); -drop([7]) -> (); -drop([68]) -> (); -drop([6]) -> (); -drop([69]) -> (); -drop([73]) -> (); -drop([5]) -> (); -drop([71]) -> (); -enum_init, 1>([111]) -> ([199]); -store_temp([98]) -> ([200]); -store_temp([99]) -> ([201]); -store_temp([100]) -> ([202]); -store_temp([101]) -> ([203]); -store_temp>([199]) -> ([204]); -return([200], [201], [202], [203], [204]); -branch_align() -> (); -drop([70]) -> (); -drop([7]) -> (); -drop([68]) -> (); -drop([6]) -> (); -drop([69]) -> (); -drop([73]) -> (); -drop([5]) -> (); -drop([71]) -> (); -drop([74]) -> (); -enum_init, 1>([96]) -> ([205]); -store_temp([90]) -> ([206]); -store_temp([77]) -> ([207]); -store_temp([78]) -> ([208]); -store_temp([79]) -> ([209]); -store_temp>([205]) -> ([210]); -return([206], [207], [208], [209], [210]); -branch_align() -> (); -drop([70]) -> (); -drop([7]) -> (); -drop([68]) -> (); -drop([6]) -> (); -drop([69]) -> (); -drop([73]) -> (); -drop([5]) -> (); -drop([71]) -> (); -drop([74]) -> (); -enum_init, 1>([88]) -> ([211]); -store_temp([76]) -> ([212]); -store_temp([77]) -> ([213]); -store_temp([78]) -> ([214]); -store_temp([79]) -> ([215]); -store_temp>([211]) -> ([216]); -return([212], [213], [214], [215], [216]); -struct_deconstruct([4]) -> ([8], [9], [10], [11], [12], [13]); -snapshot_take([13]) -> ([14], [15]); -dup([5]) -> ([5], [16]); -dup([6]) -> ([6], [17]); -struct_construct>([16], [17]) -> ([18]); -store_temp([0]) -> ([24]); -store_temp([1]) -> ([25]); -store_temp([2]) -> ([26]); -store_temp([3]) -> ([27]); -store_temp([15]) -> ([28]); -store_temp>([18]) -> ([29]); -function_call([24], [25], [26], [27], [28], [29]) -> ([19], [20], [21], [22], [23]); -enum_match>([23]) { fallthrough([30]) 3312([31]) }; -branch_align() -> (); -u128_const<340282366920938463463374607431768211455>() -> ([32]); -snapshot_take([32]) -> ([33], [34]); -struct_deconstruct>([30]) -> ([35]); -struct_deconstruct([35]) -> ([36], [37]); -snapshot_take([36]) -> ([38], [39]); -rename([39]) -> ([40]); -rename([34]) -> ([41]); -u128_eq([40], [41]) { fallthrough() 3218() }; -branch_align() -> (); -drop([33]) -> (); -struct_construct() -> ([42]); -enum_init([42]) -> ([43]); -struct_construct([38], [37]) -> ([44]); -store_temp([44]) -> ([45]); -store_temp([43]) -> ([46]); -jump() { 3237() }; -branch_align() -> (); -snapshot_take([37]) -> ([47], [48]); -snapshot_take([33]) -> ([49], [50]); -drop([49]) -> (); -rename([48]) -> ([51]); -rename([50]) -> ([52]); -u128_eq([51], [52]) { fallthrough() 3230() }; -branch_align() -> (); -struct_construct() -> ([53]); -enum_init([53]) -> ([54]); -store_temp([54]) -> ([55]); -jump() { 3234() }; -branch_align() -> (); -struct_construct() -> ([56]); -enum_init([56]) -> ([57]); -store_temp([57]) -> ([55]); -struct_construct([38], [47]) -> ([58]); -store_temp([58]) -> ([45]); -store_temp([55]) -> ([46]); -enum_match([46]) { fallthrough([59]) 3291([60]) }; -branch_align() -> (); -drop([59]) -> (); -store_temp([19]) -> ([63]); -store_temp([45]) -> ([64]); -store_temp([7]) -> ([65]); -function_call([63], [64], [65]) -> ([61], [62]); -enum_match>([62]) { fallthrough([66]) 3275([67]) }; -branch_align() -> (); -struct_deconstruct>([66]) -> ([68]); -struct_construct([8], [9], [10], [11], [12], [14]) -> ([69]); -store_temp([61]) -> ([75]); -store_temp([20]) -> ([76]); -store_temp([21]) -> ([77]); -store_temp([22]) -> ([78]); -store_temp([69]) -> ([79]); -store_temp([5]) -> ([80]); -store_temp([6]) -> ([81]); -store_temp([68]) -> ([82]); -function_call([75], [76], [77], [78], [79], [80], [81], [82]) -> ([70], [71], [72], [73], [74]); -enum_match>([74]) { fallthrough([83]) 3267([84]) }; -branch_align() -> (); -struct_deconstruct>([83]) -> ([85], [86]); -drop([86]) -> (); -store_temp([70]) -> ([87]); -store_temp([71]) -> ([88]); -store_temp([72]) -> ([89]); -store_temp([73]) -> ([90]); -store_temp([85]) -> ([91]); -jump() { 3303() }; -branch_align() -> (); -enum_init, 1>([84]) -> ([92]); -store_temp([70]) -> ([93]); -store_temp([71]) -> ([94]); -store_temp([72]) -> ([95]); -store_temp([73]) -> ([96]); -store_temp>([92]) -> ([97]); -return([93], [94], [95], [96], [97]); -branch_align() -> (); -drop([8]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([14]) -> (); -drop([12]) -> (); -drop([11]) -> (); -drop([10]) -> (); -drop([9]) -> (); -enum_init, 1>([67]) -> ([98]); -store_temp([61]) -> ([99]); -store_temp([20]) -> ([100]); -store_temp([21]) -> ([101]); -store_temp([22]) -> ([102]); -store_temp>([98]) -> ([103]); -return([99], [100], [101], [102], [103]); -branch_align() -> (); -drop([60]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([7]) -> (); -drop([45]) -> (); -struct_construct([8], [9], [10], [11], [12], [14]) -> ([104]); -store_temp([19]) -> ([87]); -store_temp([20]) -> ([88]); -store_temp([21]) -> ([89]); -store_temp([22]) -> ([90]); -store_temp([104]) -> ([91]); -struct_construct() -> ([105]); -struct_construct>([91], [105]) -> ([106]); -enum_init, 0>([106]) -> ([107]); -store_temp([87]) -> ([108]); -store_temp([88]) -> ([109]); -store_temp([89]) -> ([110]); -store_temp([90]) -> ([111]); -store_temp>([107]) -> ([112]); -return([108], [109], [110], [111], [112]); -branch_align() -> (); -drop([8]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([9]) -> (); -drop([14]) -> (); -drop([12]) -> (); -drop([11]) -> (); -drop([10]) -> (); -drop([7]) -> (); -enum_init, 1>([31]) -> ([113]); -store_temp([19]) -> ([114]); -store_temp([20]) -> ([115]); -store_temp([21]) -> ([116]); -store_temp([22]) -> ([117]); -store_temp>([113]) -> ([118]); -return([114], [115], [116], [117], [118]); -dup([6]) -> ([6], [9]); -contract_address_to_felt252([9]) -> ([8]); -snapshot_take([8]) -> ([10], [11]); -drop([10]) -> (); -felt252_const<0>() -> ([12]); -snapshot_take([12]) -> ([13], [14]); -drop([13]) -> (); -rename([11]) -> ([15]); -rename([14]) -> ([16]); -felt252_sub([15], [16]) -> ([17]); -store_temp([17]) -> ([17]); -felt252_is_zero([17]) { fallthrough() 3346([18]) }; -branch_align() -> (); -struct_construct() -> ([19]); -enum_init([19]) -> ([20]); -store_temp([20]) -> ([21]); -jump() { 3351() }; -branch_align() -> (); -drop>([18]) -> (); -struct_construct() -> ([22]); -enum_init([22]) -> ([23]); -store_temp([23]) -> ([21]); -bool_not_impl([21]) -> ([24]); -store_temp([24]) -> ([24]); -enum_match([24]) { fallthrough([25]) 3373([26]) }; -branch_align() -> (); -drop([25]) -> (); -drop([7]) -> (); -drop([6]) -> (); -drop([5]) -> (); -drop([4]) -> (); -array_new() -> ([27]); -felt252_const<101313248740993271302566317381896466254801065025584>() -> ([28]); -store_temp([28]) -> ([28]); -array_append([27], [28]) -> ([29]); -struct_construct() -> ([30]); -struct_construct>>([30], [29]) -> ([31]); -enum_init, 1>([31]) -> ([32]); -store_temp([0]) -> ([33]); -store_temp([1]) -> ([34]); -store_temp([2]) -> ([35]); -store_temp([3]) -> ([36]); -store_temp>([32]) -> ([37]); -return([33], [34], [35], [36], [37]); -branch_align() -> (); -drop([26]) -> (); -struct_deconstruct([4]) -> ([38], [39], [40], [41], [42], [43]); -dup([5]) -> ([5], [44]); -dup([6]) -> ([6], [45]); -struct_construct>([44], [45]) -> ([46]); -store_temp([0]) -> ([52]); -store_temp([1]) -> ([53]); -store_temp([2]) -> ([54]); -store_temp([3]) -> ([55]); -store_temp([43]) -> ([56]); -store_temp>([46]) -> ([57]); -dup([7]) -> ([7], [58]); -store_temp([58]) -> ([58]); -function_call([52], [53], [54], [55], [56], [57], [58]) -> ([47], [48], [49], [50], [51]); -enum_match>([51]) { fallthrough([59]) 3420([60]) }; -branch_align() -> (); -struct_deconstruct>([59]) -> ([61], [62]); -drop([62]) -> (); -struct_construct([5], [6], [7]) -> ([63]); -struct_construct([38], [39], [40], [41], [42], [61]) -> ([64]); -store_temp([48]) -> ([68]); -store_temp([50]) -> ([69]); -store_temp([64]) -> ([70]); -store_temp([63]) -> ([71]); -function_call>([68], [69], [70], [71]) -> ([65], [66], [67]); -enum_match>([67]) { fallthrough([72]) 3412([73]) }; -branch_align() -> (); -struct_deconstruct>([72]) -> ([74], [75]); -drop([75]) -> (); -struct_construct() -> ([76]); -struct_construct>([74], [76]) -> ([77]); -enum_init, 0>([77]) -> ([78]); -store_temp([47]) -> ([79]); -store_temp([65]) -> ([80]); -store_temp([49]) -> ([81]); -store_temp([66]) -> ([82]); -store_temp>([78]) -> ([83]); -return([79], [80], [81], [82], [83]); -branch_align() -> (); -enum_init, 1>([73]) -> ([84]); -store_temp([47]) -> ([85]); -store_temp([65]) -> ([86]); -store_temp([49]) -> ([87]); -store_temp([66]) -> ([88]); -store_temp>([84]) -> ([89]); -return([85], [86], [87], [88], [89]); -branch_align() -> (); -drop([38]) -> (); -drop([5]) -> (); -drop([42]) -> (); -drop([41]) -> (); -drop([40]) -> (); -drop([39]) -> (); -drop([7]) -> (); -drop([6]) -> (); -enum_init, 1>([60]) -> ([90]); -store_temp([47]) -> ([91]); -store_temp([48]) -> ([92]); -store_temp([49]) -> ([93]); -store_temp([50]) -> ([94]); -store_temp>([90]) -> ([95]); -return([91], [92], [93], [94], [95]); -store_temp([0]) -> ([5]); -store_temp([1]) -> ([6]); -store_temp([2]) -> ([7]); -function_call([5], [6], [7]) -> ([3], [4]); -enum_match>([4]) { fallthrough([8]) 3447([9]) }; -branch_align() -> (); -struct_construct>([8]) -> ([10]); -enum_init, 0>([10]) -> ([11]); -store_temp([3]) -> ([12]); -store_temp>([11]) -> ([13]); -return([12], [13]); -branch_align() -> (); -drop([9]) -> (); -array_new() -> ([14]); -felt252_const<39879774624079483812136948410799859986295>() -> ([15]); -store_temp([15]) -> ([15]); -array_append([14], [15]) -> ([16]); -struct_construct() -> ([17]); -struct_construct>>([17], [16]) -> ([18]); -enum_init, 1>([18]) -> ([19]); -store_temp([3]) -> ([20]); -store_temp>([19]) -> ([21]); -return([20], [21]); -store_temp([0]) -> ([5]); -store_temp([1]) -> ([6]); -store_temp([2]) -> ([7]); -function_call([5], [6], [7]) -> ([3], [4]); -enum_match>([4]) { fallthrough([8]) 3470([9]) }; -branch_align() -> (); -struct_construct>([8]) -> ([10]); -enum_init, 0>([10]) -> ([11]); -store_temp([3]) -> ([12]); -store_temp>([11]) -> ([13]); -return([12], [13]); -branch_align() -> (); -drop([9]) -> (); -array_new() -> ([14]); -felt252_const<39879774624085075084607933104993585622903>() -> ([15]); -store_temp([15]) -> ([15]); -array_append([14], [15]) -> ([16]); -struct_construct() -> ([17]); -struct_construct>>([17], [16]) -> ([18]); -enum_init, 1>([18]) -> ([19]); -store_temp([3]) -> ([20]); -store_temp>([19]) -> ([21]); -return([20], [21]); -u8_try_from_felt252([0], [1]) { fallthrough([2], [3]) 3488([4]) }; -branch_align() -> (); -enum_init, 0>([3]) -> ([5]); -store_temp([2]) -> ([6]); -store_temp>([5]) -> ([7]); -jump() { 3493() }; -branch_align() -> (); -struct_construct() -> ([8]); -enum_init, 1>([8]) -> ([9]); -store_temp([4]) -> ([6]); -store_temp>([9]) -> ([7]); -rename([6]) -> ([10]); -rename>([7]) -> ([11]); -return([10], [11]); -storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>() -> ([4]); -storage_address_from_base([4]) -> ([5]); -u32_const<0>() -> ([6]); -snapshot_take([2]) -> ([7], [8]); -drop([8]) -> (); -store_temp([6]) -> ([6]); -store_temp([5]) -> ([5]); -storage_write_syscall([0], [1], [6], [5], [3]) { fallthrough([9], [10]) 3511([11], [12], [13]) }; -branch_align() -> (); -struct_construct() -> ([14]); -enum_init>, 0>([14]) -> ([15]); -store_temp([9]) -> ([16]); -store_temp([10]) -> ([17]); -store_temp>>([15]) -> ([18]); -jump() { 3516() }; -branch_align() -> (); -enum_init>, 1>([13]) -> ([19]); -store_temp([11]) -> ([16]); -store_temp([12]) -> ([17]); -store_temp>>([19]) -> ([18]); -rename>>([18]) -> ([21]); -function_call::unwrap_syscall>([21]) -> ([20]); -enum_match>([20]) { fallthrough([22]) 3527([23]) }; -branch_align() -> (); -struct_deconstruct>([22]) -> ([24]); -struct_construct>([7], [24]) -> ([25]); -enum_init, 0>([25]) -> ([26]); -store_temp([16]) -> ([27]); -store_temp([17]) -> ([28]); -store_temp>([26]) -> ([29]); -return([27], [28], [29]); -branch_align() -> (); -drop([7]) -> (); -enum_init, 1>([23]) -> ([30]); -store_temp([16]) -> ([31]); -store_temp([17]) -> ([32]); -store_temp>([30]) -> ([33]); -return([31], [32], [33]); -storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>() -> ([4]); -storage_address_from_base([4]) -> ([5]); -u32_const<0>() -> ([6]); -snapshot_take([2]) -> ([7], [8]); -drop([8]) -> (); -store_temp([6]) -> ([6]); -store_temp([5]) -> ([5]); -storage_write_syscall([0], [1], [6], [5], [3]) { fallthrough([9], [10]) 3549([11], [12], [13]) }; -branch_align() -> (); -struct_construct() -> ([14]); -enum_init>, 0>([14]) -> ([15]); -store_temp([9]) -> ([16]); -store_temp([10]) -> ([17]); -store_temp>>([15]) -> ([18]); -jump() { 3554() }; -branch_align() -> (); -enum_init>, 1>([13]) -> ([19]); -store_temp([11]) -> ([16]); -store_temp([12]) -> ([17]); -store_temp>>([19]) -> ([18]); -rename>>([18]) -> ([21]); -function_call::unwrap_syscall>([21]) -> ([20]); -enum_match>([20]) { fallthrough([22]) 3565([23]) }; -branch_align() -> (); -struct_deconstruct>([22]) -> ([24]); -struct_construct>([7], [24]) -> ([25]); -enum_init, 0>([25]) -> ([26]); -store_temp([16]) -> ([27]); -store_temp([17]) -> ([28]); -store_temp>([26]) -> ([29]); -return([27], [28], [29]); -branch_align() -> (); -drop([7]) -> (); -enum_init, 1>([23]) -> ([30]); -store_temp([16]) -> ([31]); -store_temp([17]) -> ([32]); -store_temp>([30]) -> ([33]); -return([31], [32], [33]); -storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>() -> ([4]); -u8_to_felt252([3]) -> ([5]); -storage_address_from_base([4]) -> ([6]); -u32_const<0>() -> ([7]); -snapshot_take([2]) -> ([8], [9]); -drop([9]) -> (); -store_temp([7]) -> ([7]); -store_temp([6]) -> ([6]); -storage_write_syscall([0], [1], [7], [6], [5]) { fallthrough([10], [11]) 3588([12], [13], [14]) }; -branch_align() -> (); -struct_construct() -> ([15]); -enum_init>, 0>([15]) -> ([16]); -store_temp([10]) -> ([17]); -store_temp([11]) -> ([18]); -store_temp>>([16]) -> ([19]); -jump() { 3593() }; -branch_align() -> (); -enum_init>, 1>([14]) -> ([20]); -store_temp([12]) -> ([17]); -store_temp([13]) -> ([18]); -store_temp>>([20]) -> ([19]); -rename>>([19]) -> ([22]); -function_call::unwrap_syscall>([22]) -> ([21]); -enum_match>([21]) { fallthrough([23]) 3604([24]) }; -branch_align() -> (); -struct_deconstruct>([23]) -> ([25]); -struct_construct>([8], [25]) -> ([26]); -enum_init, 0>([26]) -> ([27]); -store_temp([17]) -> ([28]); -store_temp([18]) -> ([29]); -store_temp>([27]) -> ([30]); -return([28], [29], [30]); -branch_align() -> (); -drop([8]) -> (); -enum_init, 1>([24]) -> ([31]); -store_temp([17]) -> ([32]); -store_temp([18]) -> ([33]); -store_temp>([31]) -> ([34]); -return([32], [33], [34]); -storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>() -> ([4]); -u32_const<0>() -> ([5]); -store_temp([0]) -> ([9]); -store_temp([1]) -> ([10]); -store_temp([5]) -> ([11]); -store_temp([4]) -> ([12]); -store_temp([3]) -> ([13]); -function_call([9], [10], [11], [12], [13]) -> ([6], [7], [8]); -rename>>([8]) -> ([15]); -function_call::unwrap_syscall>([15]) -> ([14]); -enum_match>([14]) { fallthrough([16]) 3632([17]) }; -branch_align() -> (); -snapshot_take([2]) -> ([18], [19]); -drop([19]) -> (); -struct_deconstruct>([16]) -> ([20]); -struct_construct>([18], [20]) -> ([21]); -enum_init, 0>([21]) -> ([22]); -store_temp([6]) -> ([23]); -store_temp([7]) -> ([24]); -store_temp>([22]) -> ([25]); -return([23], [24], [25]); -branch_align() -> (); -drop([2]) -> (); -enum_init, 1>([17]) -> ([26]); -store_temp([6]) -> ([27]); -store_temp([7]) -> ([28]); -store_temp>([26]) -> ([29]); -return([27], [28], [29]); -snapshot_take([4]) -> ([7], [8]); -store_temp([0]) -> ([12]); -store_temp([2]) -> ([13]); -store_temp([8]) -> ([14]); -store_temp([5]) -> ([15]); -function_call([12], [13], [14], [15]) -> ([9], [10], [11]); -u32_const<0>() -> ([16]); -store_temp([1]) -> ([20]); -store_temp([3]) -> ([21]); -store_temp([16]) -> ([22]); -store_temp([11]) -> ([23]); -store_temp([6]) -> ([24]); -function_call([20], [21], [22], [23], [24]) -> ([17], [18], [19]); -rename>>([19]) -> ([26]); -function_call::unwrap_syscall>([26]) -> ([25]); -enum_match>([25]) { fallthrough([27]) 3665([28]) }; -branch_align() -> (); -struct_deconstruct>([27]) -> ([29]); -struct_construct>([7], [29]) -> ([30]); -enum_init, 0>([30]) -> ([31]); -store_temp([9]) -> ([32]); -store_temp([17]) -> ([33]); -store_temp([10]) -> ([34]); -store_temp([18]) -> ([35]); -store_temp>([31]) -> ([36]); -return([32], [33], [34], [35], [36]); -branch_align() -> (); -drop([7]) -> (); -enum_init, 1>([28]) -> ([37]); -store_temp([9]) -> ([38]); -store_temp([17]) -> ([39]); -store_temp([10]) -> ([40]); -store_temp([18]) -> ([41]); -store_temp>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -store_temp([3]) -> ([5]); -function_call::into>([5]) -> ([4]); -array_new() -> ([6]); -array_new() -> ([7]); -snapshot_take([4]) -> ([8], [9]); -drop([8]) -> (); -store_temp([9]) -> ([13]); -store_temp>([6]) -> ([14]); -store_temp>([7]) -> ([15]); -function_call([13], [14], [15]) -> ([10], [11], [12]); -drop([12]) -> (); -snapshot_take>([10]) -> ([16], [17]); -drop>([16]) -> (); -struct_construct>([17]) -> ([18]); -snapshot_take>([11]) -> ([19], [20]); -drop>([19]) -> (); -struct_construct>([20]) -> ([21]); -store_temp>([18]) -> ([18]); -store_temp>([21]) -> ([21]); -emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 3701([24], [25], [26]) }; -branch_align() -> (); -struct_construct() -> ([27]); -enum_init>, 0>([27]) -> ([28]); -store_temp([22]) -> ([29]); -store_temp([23]) -> ([30]); -store_temp>>([28]) -> ([31]); -jump() { 3706() }; -branch_align() -> (); -enum_init>, 1>([26]) -> ([32]); -store_temp([24]) -> ([29]); -store_temp([25]) -> ([30]); -store_temp>>([32]) -> ([31]); -rename>>([31]) -> ([34]); -function_call::unwrap_syscall>([34]) -> ([33]); -enum_match>([33]) { fallthrough([35]) 3717([36]) }; -branch_align() -> (); -struct_deconstruct>([35]) -> ([37]); -struct_construct>([2], [37]) -> ([38]); -enum_init, 0>([38]) -> ([39]); -store_temp([29]) -> ([40]); -store_temp([30]) -> ([41]); -store_temp>([39]) -> ([42]); -return([40], [41], [42]); -branch_align() -> (); -drop([2]) -> (); -enum_init, 1>([36]) -> ([43]); -store_temp([29]) -> ([44]); -store_temp([30]) -> ([45]); -store_temp>([43]) -> ([46]); -return([44], [45], [46]); -enum_match>>([0]) { fallthrough([1]) 3730([2]) }; -branch_align() -> (); -struct_construct>([1]) -> ([3]); -enum_init, 0>([3]) -> ([4]); -store_temp>([4]) -> ([5]); -return([5]); -branch_align() -> (); -struct_construct() -> ([6]); -struct_construct>>([6], [2]) -> ([7]); -enum_init, 1>([7]) -> ([8]); -store_temp>([8]) -> ([9]); -return([9]); -storage_address_from_base([4]) -> ([5]); -storage_read_syscall([1], [2], [3], [5]) { fallthrough([6], [7], [8]) 3768([9], [10], [11]) }; -branch_align() -> (); -store_temp([0]) -> ([14]); -store_temp([8]) -> ([15]); -function_call([14], [15]) -> ([12], [13]); -store_temp([6]) -> ([6]); -store_temp([7]) -> ([7]); -enum_match>([13]) { fallthrough([16]) 3754([17]) }; -branch_align() -> (); -enum_init>, 0>([16]) -> ([18]); -struct_construct>>>([18]) -> ([19]); -enum_init>,)>, 0>([19]) -> ([20]); -store_temp([12]) -> ([21]); -store_temp([6]) -> ([22]); -store_temp([7]) -> ([23]); -store_temp>,)>>([20]) -> ([24]); -return([21], [22], [23], [24]); -branch_align() -> (); -drop([17]) -> (); -array_new() -> ([25]); -felt252_const<110930490496575599150170734222081291576>() -> ([26]); -store_temp([26]) -> ([26]); -array_append([25], [26]) -> ([27]); -struct_construct() -> ([28]); -struct_construct>>([28], [27]) -> ([29]); -enum_init>,)>, 1>([29]) -> ([30]); -store_temp([12]) -> ([31]); -store_temp([6]) -> ([32]); -store_temp([7]) -> ([33]); -store_temp>,)>>([30]) -> ([34]); -return([31], [32], [33], [34]); -branch_align() -> (); -enum_init>, 1>([11]) -> ([35]); -struct_construct>>>([35]) -> ([36]); -enum_init>,)>, 0>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([9]) -> ([39]); -store_temp([10]) -> ([40]); -store_temp>,)>>([37]) -> ([41]); -return([38], [39], [40], [41]); -enum_match>>([0]) { fallthrough([1]) 3783([2]) }; -branch_align() -> (); -struct_construct>([1]) -> ([3]); -enum_init, 0>([3]) -> ([4]); -store_temp>([4]) -> ([5]); -return([5]); -branch_align() -> (); -struct_construct() -> ([6]); -struct_construct>>([6], [2]) -> ([7]); -enum_init, 1>([7]) -> ([8]); -store_temp>([8]) -> ([9]); -return([9]); -store_temp([0]) -> ([9]); -store_temp([1]) -> ([10]); -store_temp([2]) -> ([11]); -dup([3]) -> ([3], [12]); -store_temp([12]) -> ([12]); -dup([4]) -> ([4], [13]); -store_temp([13]) -> ([13]); -function_call([9], [10], [11], [12], [13]) -> ([5], [6], [7], [8]); -enum_match>,)>>([8]) { fallthrough([14]) 3859([15]) }; -branch_align() -> (); -struct_deconstruct>>>([14]) -> ([16]); -enum_match>>([16]) { fallthrough([17]) 3848([18]) }; -branch_align() -> (); -u8_const<1>() -> ([19]); -storage_address_from_base_and_offset([4], [19]) -> ([20]); -store_temp([20]) -> ([20]); -storage_read_syscall([6], [7], [3], [20]) { fallthrough([21], [22], [23]) 3838([24], [25], [26]) }; -branch_align() -> (); -store_temp([5]) -> ([29]); -store_temp([23]) -> ([30]); -function_call([29], [30]) -> ([27], [28]); -store_temp([21]) -> ([21]); -store_temp([22]) -> ([22]); -enum_match>([28]) { fallthrough([31]) 3823([32]) }; -branch_align() -> (); -struct_construct([17], [31]) -> ([33]); -enum_init>, 0>([33]) -> ([34]); -struct_construct>>>([34]) -> ([35]); -enum_init>,)>, 0>([35]) -> ([36]); -store_temp([27]) -> ([37]); -store_temp([21]) -> ([38]); -store_temp([22]) -> ([39]); -store_temp>,)>>([36]) -> ([40]); -return([37], [38], [39], [40]); -branch_align() -> (); -drop([32]) -> (); -drop([17]) -> (); -array_new() -> ([41]); -felt252_const<476442828812030857794232422692155113556837216824>() -> ([42]); -store_temp([42]) -> ([42]); -array_append([41], [42]) -> ([43]); -struct_construct() -> ([44]); -struct_construct>>([44], [43]) -> ([45]); -enum_init>,)>, 1>([45]) -> ([46]); -store_temp([27]) -> ([47]); -store_temp([21]) -> ([48]); -store_temp([22]) -> ([49]); -store_temp>,)>>([46]) -> ([50]); -return([47], [48], [49], [50]); -branch_align() -> (); -drop([17]) -> (); -enum_init>, 1>([26]) -> ([51]); -struct_construct>>>([51]) -> ([52]); -enum_init>,)>, 0>([52]) -> ([53]); -store_temp([5]) -> ([54]); -store_temp([24]) -> ([55]); -store_temp([25]) -> ([56]); -store_temp>,)>>([53]) -> ([57]); -return([54], [55], [56], [57]); -branch_align() -> (); -drop([4]) -> (); -drop([3]) -> (); -enum_init>, 1>([18]) -> ([58]); -struct_construct>>>([58]) -> ([59]); -enum_init>,)>, 0>([59]) -> ([60]); -store_temp([5]) -> ([61]); -store_temp([6]) -> ([62]); -store_temp([7]) -> ([63]); -store_temp>,)>>([60]) -> ([64]); -return([61], [62], [63], [64]); -branch_align() -> (); -drop([4]) -> (); -drop([3]) -> (); -enum_init>,)>, 1>([15]) -> ([65]); -store_temp([5]) -> ([66]); -store_temp([6]) -> ([67]); -store_temp([7]) -> ([68]); -store_temp>,)>>([65]) -> ([69]); -return([66], [67], [68], [69]); -enum_match>>([0]) { fallthrough([1]) 3874([2]) }; -branch_align() -> (); -struct_construct>([1]) -> ([3]); -enum_init, 0>([3]) -> ([4]); -store_temp>([4]) -> ([5]); -return([5]); -branch_align() -> (); -struct_construct() -> ([6]); -struct_construct>>([6], [2]) -> ([7]); -enum_init, 1>([7]) -> ([8]); -store_temp>([8]) -> ([9]); -return([9]); -drop([2]) -> (); -felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564>() -> ([4]); -store_temp([1]) -> ([7]); -store_temp([4]) -> ([8]); -store_temp([3]) -> ([9]); -function_call([7], [8], [9]) -> ([5], [6]); -storage_base_address_from_felt252([0], [6]) -> ([10], [11]); -store_temp([10]) -> ([12]); -store_temp([5]) -> ([13]); -store_temp([11]) -> ([14]); -return([12], [13], [14]); -drop([2]) -> (); -felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719>() -> ([4]); -store_temp([1]) -> ([7]); -store_temp([4]) -> ([8]); -store_temp>([3]) -> ([9]); -function_call::hash>([7], [8], [9]) -> ([5], [6]); -storage_base_address_from_felt252([0], [6]) -> ([10], [11]); -store_temp([10]) -> ([12]); -store_temp([5]) -> ([13]); -store_temp([11]) -> ([14]); -return([12], [13], [14]); -u128s_from_felt252([0], [1]) { fallthrough([2], [3]) 3908([4], [5], [6]) }; -branch_align() -> (); -enum_init, 0>([3]) -> ([7]); -store_temp([2]) -> ([8]); -store_temp>([7]) -> ([9]); -jump() { 3915() }; -branch_align() -> (); -drop([5]) -> (); -drop([6]) -> (); -struct_construct() -> ([10]); -enum_init, 1>([10]) -> ([11]); -store_temp([4]) -> ([8]); -store_temp>([11]) -> ([9]); -rename([8]) -> ([12]); -rename>([9]) -> ([13]); -return([12], [13]); -get_execution_info_syscall([0], [1]) { fallthrough([2], [3], [4]) 3925([5], [6], [7]) }; -branch_align() -> (); -enum_init, core::array::Array::>, 0>([4]) -> ([8]); -store_temp([2]) -> ([9]); -store_temp([3]) -> ([10]); -store_temp, core::array::Array::>>([8]) -> ([11]); -jump() { 3930() }; -branch_align() -> (); -enum_init, core::array::Array::>, 1>([7]) -> ([12]); -store_temp([5]) -> ([9]); -store_temp([6]) -> ([10]); -store_temp, core::array::Array::>>([12]) -> ([11]); -rename, core::array::Array::>>([11]) -> ([14]); -function_call>::unwrap_syscall>([14]) -> ([13]); -enum_match,)>>([13]) { fallthrough([15]) 3941([16]) }; -branch_align() -> (); -struct_deconstruct>>([15]) -> ([17]); -struct_construct>>([17]) -> ([18]); -enum_init,)>, 0>([18]) -> ([19]); -store_temp([9]) -> ([20]); -store_temp([10]) -> ([21]); -store_temp,)>>([19]) -> ([22]); -return([20], [21], [22]); -branch_align() -> (); -enum_init,)>, 1>([16]) -> ([23]); -store_temp([9]) -> ([24]); -store_temp([10]) -> ([25]); -store_temp,)>>([23]) -> ([26]); -return([24], [25], [26]); -store_temp([3]) -> ([5]); -function_call([5]) -> ([4]); -array_new() -> ([6]); -array_new() -> ([7]); -snapshot_take([4]) -> ([8], [9]); -drop([8]) -> (); -store_temp([9]) -> ([13]); -store_temp>([6]) -> ([14]); -store_temp>([7]) -> ([15]); -function_call([13], [14], [15]) -> ([10], [11], [12]); -drop([12]) -> (); -snapshot_take>([10]) -> ([16], [17]); -drop>([16]) -> (); -struct_construct>([17]) -> ([18]); -snapshot_take>([11]) -> ([19], [20]); -drop>([19]) -> (); -struct_construct>([20]) -> ([21]); -store_temp>([18]) -> ([18]); -store_temp>([21]) -> ([21]); -emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 3974([24], [25], [26]) }; -branch_align() -> (); -struct_construct() -> ([27]); -enum_init>, 0>([27]) -> ([28]); -store_temp([22]) -> ([29]); -store_temp([23]) -> ([30]); -store_temp>>([28]) -> ([31]); -jump() { 3979() }; -branch_align() -> (); -enum_init>, 1>([26]) -> ([32]); -store_temp([24]) -> ([29]); -store_temp([25]) -> ([30]); -store_temp>>([32]) -> ([31]); -rename>>([31]) -> ([34]); -function_call::unwrap_syscall>([34]) -> ([33]); -enum_match>([33]) { fallthrough([35]) 3990([36]) }; -branch_align() -> (); -struct_deconstruct>([35]) -> ([37]); -struct_construct>([2], [37]) -> ([38]); -enum_init, 0>([38]) -> ([39]); -store_temp([29]) -> ([40]); -store_temp([30]) -> ([41]); -store_temp>([39]) -> ([42]); -return([40], [41], [42]); -branch_align() -> (); -drop([2]) -> (); -enum_init, 1>([36]) -> ([43]); -store_temp([29]) -> ([44]); -store_temp([30]) -> ([45]); -store_temp>([43]) -> ([46]); -return([44], [45], [46]); -snapshot_take([4]) -> ([7], [8]); -store_temp([0]) -> ([12]); -store_temp([2]) -> ([13]); -store_temp([8]) -> ([14]); -store_temp>([5]) -> ([15]); -function_call([12], [13], [14], [15]) -> ([9], [10], [11]); -u32_const<0>() -> ([16]); -store_temp([1]) -> ([20]); -store_temp([3]) -> ([21]); -store_temp([16]) -> ([22]); -store_temp([11]) -> ([23]); -store_temp([6]) -> ([24]); -function_call([20], [21], [22], [23], [24]) -> ([17], [18], [19]); -rename>>([19]) -> ([26]); -function_call::unwrap_syscall>([26]) -> ([25]); -enum_match>([25]) { fallthrough([27]) 4023([28]) }; -branch_align() -> (); -struct_deconstruct>([27]) -> ([29]); -struct_construct>([7], [29]) -> ([30]); -enum_init, 0>([30]) -> ([31]); -store_temp([9]) -> ([32]); -store_temp([17]) -> ([33]); -store_temp([10]) -> ([34]); -store_temp([18]) -> ([35]); -store_temp>([31]) -> ([36]); -return([32], [33], [34], [35], [36]); -branch_align() -> (); -drop([7]) -> (); -enum_init, 1>([28]) -> ([37]); -store_temp([9]) -> ([38]); -store_temp([17]) -> ([39]); -store_temp([10]) -> ([40]); -store_temp([18]) -> ([41]); -store_temp>([37]) -> ([42]); -return([38], [39], [40], [41], [42]); -store_temp([3]) -> ([5]); -function_call([5]) -> ([4]); -array_new() -> ([6]); -array_new() -> ([7]); -snapshot_take([4]) -> ([8], [9]); -drop([8]) -> (); -store_temp([9]) -> ([13]); -store_temp>([6]) -> ([14]); -store_temp>([7]) -> ([15]); -function_call([13], [14], [15]) -> ([10], [11], [12]); -drop([12]) -> (); -snapshot_take>([10]) -> ([16], [17]); -drop>([16]) -> (); -struct_construct>([17]) -> ([18]); -snapshot_take>([11]) -> ([19], [20]); -drop>([19]) -> (); -struct_construct>([20]) -> ([21]); -store_temp>([18]) -> ([18]); -store_temp>([21]) -> ([21]); -emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 4059([24], [25], [26]) }; -branch_align() -> (); -struct_construct() -> ([27]); -enum_init>, 0>([27]) -> ([28]); -store_temp([22]) -> ([29]); -store_temp([23]) -> ([30]); -store_temp>>([28]) -> ([31]); -jump() { 4064() }; -branch_align() -> (); -enum_init>, 1>([26]) -> ([32]); -store_temp([24]) -> ([29]); -store_temp([25]) -> ([30]); -store_temp>>([32]) -> ([31]); -rename>>([31]) -> ([34]); -function_call::unwrap_syscall>([34]) -> ([33]); -enum_match>([33]) { fallthrough([35]) 4075([36]) }; -branch_align() -> (); -struct_deconstruct>([35]) -> ([37]); -struct_construct>([2], [37]) -> ([38]); -enum_init, 0>([38]) -> ([39]); -store_temp([29]) -> ([40]); -store_temp([30]) -> ([41]); -store_temp>([39]) -> ([42]); -return([40], [41], [42]); -branch_align() -> (); -drop([2]) -> (); -enum_init, 1>([36]) -> ([43]); -store_temp([29]) -> ([44]); -store_temp([30]) -> ([45]); -store_temp>([43]) -> ([46]); -return([44], [45], [46]); -store_temp([0]) -> ([5]); -store_temp([1]) -> ([6]); -store_temp([2]) -> ([7]); -function_call([5], [6], [7]) -> ([3], [4]); -struct_deconstruct>([4]) -> ([8], [9]); -enum_match([9]) { fallthrough([10]) 4093([11]) }; -branch_align() -> (); -drop([10]) -> (); -enum_init, 0>([8]) -> ([12]); -store_temp>([12]) -> ([13]); -jump() { 4099() }; -branch_align() -> (); -drop([11]) -> (); -drop([8]) -> (); -struct_construct() -> ([14]); -enum_init, 1>([14]) -> ([15]); -store_temp>([15]) -> ([13]); -store_temp([3]) -> ([16]); -store_temp>([13]) -> ([17]); -return([16], [17]); -store_temp([0]) -> ([5]); -store_temp([1]) -> ([6]); -store_temp([2]) -> ([7]); -function_call([5], [6], [7]) -> ([3], [4]); -struct_deconstruct>([4]) -> ([8], [9]); -enum_match([9]) { fallthrough([10]) 4113([11]) }; -branch_align() -> (); -drop([10]) -> (); -enum_init, 0>([8]) -> ([12]); -store_temp>([12]) -> ([13]); -jump() { 4119() }; -branch_align() -> (); -drop([11]) -> (); -drop([8]) -> (); -struct_construct() -> ([14]); -enum_init, 1>([14]) -> ([15]); -store_temp>([15]) -> ([13]); -store_temp([3]) -> ([16]); -store_temp>([13]) -> ([17]); -return([16], [17]); -enum_match>>([0]) { fallthrough([1]) 4128([2]) }; -branch_align() -> (); -struct_construct>([1]) -> ([3]); -enum_init, 0>([3]) -> ([4]); -store_temp>([4]) -> ([5]); -return([5]); -branch_align() -> (); -struct_construct() -> ([6]); -struct_construct>>([6], [2]) -> ([7]); -enum_init, 1>([7]) -> ([8]); -store_temp>([8]) -> ([9]); -return([9]); -struct_deconstruct([4]) -> ([5], [6]); -u128_to_felt252([5]) -> ([7]); -dup([3]) -> ([3], [9]); -storage_address_from_base([9]) -> ([8]); -dup([2]) -> ([2], [10]); -storage_write_syscall([0], [1], [10], [8], [7]) { fallthrough([11], [12]) 4160([13], [14], [15]) }; -branch_align() -> (); -u128_to_felt252([6]) -> ([16]); -u8_const<1>() -> ([17]); -storage_address_from_base_and_offset([3], [17]) -> ([18]); -store_temp([11]) -> ([11]); -store_temp([18]) -> ([18]); -storage_write_syscall([11], [12], [2], [18], [16]) { fallthrough([19], [20]) 4154([21], [22], [23]) }; -branch_align() -> (); -struct_construct() -> ([24]); -enum_init>, 0>([24]) -> ([25]); -store_temp([19]) -> ([26]); -store_temp([20]) -> ([27]); -store_temp>>([25]) -> ([28]); -return([26], [27], [28]); -branch_align() -> (); -enum_init>, 1>([23]) -> ([29]); -store_temp([21]) -> ([30]); -store_temp([22]) -> ([31]); -store_temp>>([29]) -> ([32]); -return([30], [31], [32]); -branch_align() -> (); -drop([3]) -> (); -drop([6]) -> (); -drop([2]) -> (); -enum_init>, 1>([15]) -> ([33]); -store_temp([13]) -> ([34]); -store_temp([14]) -> ([35]); -store_temp>>([33]) -> ([36]); -return([34], [35], [36]); -store_temp([0]) -> ([1]); -return([1]); -enum_match([0]) { fallthrough([3]) 4184([4]) }; -branch_align() -> (); -felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697>() -> ([5]); -store_temp([5]) -> ([5]); -array_append([1], [5]) -> ([6]); -store_temp([3]) -> ([10]); -store_temp>([6]) -> ([11]); -store_temp>([2]) -> ([12]); -function_call([10], [11], [12]) -> ([7], [8], [9]); -drop([9]) -> (); -store_temp>([7]) -> ([13]); -store_temp>([8]) -> ([14]); -jump() { 4195() }; -branch_align() -> (); -felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999>() -> ([15]); -store_temp([15]) -> ([15]); -array_append([1], [15]) -> ([16]); -store_temp([4]) -> ([20]); -store_temp>([16]) -> ([21]); -store_temp>([2]) -> ([22]); -function_call([20], [21], [22]) -> ([17], [18], [19]); -drop([19]) -> (); -store_temp>([17]) -> ([13]); -store_temp>([18]) -> ([14]); -struct_construct() -> ([23]); -rename>([13]) -> ([24]); -rename>([14]) -> ([25]); -store_temp([23]) -> ([26]); -return([24], [25], [26]); -storage_address_from_base([4]) -> ([5]); -storage_read_syscall([1], [2], [3], [5]) { fallthrough([6], [7], [8]) 4232([9], [10], [11]) }; -branch_align() -> (); -store_temp([0]) -> ([14]); -store_temp([8]) -> ([15]); -function_call([14], [15]) -> ([12], [13]); -store_temp([6]) -> ([6]); -store_temp([7]) -> ([7]); -enum_match>([13]) { fallthrough([16]) 4218([17]) }; -branch_align() -> (); -enum_init>, 0>([16]) -> ([18]); -struct_construct>>>([18]) -> ([19]); -enum_init>,)>, 0>([19]) -> ([20]); -store_temp([12]) -> ([21]); -store_temp([6]) -> ([22]); -store_temp([7]) -> ([23]); -store_temp>,)>>([20]) -> ([24]); -return([21], [22], [23], [24]); -branch_align() -> (); -drop([17]) -> (); -array_new() -> ([25]); -felt252_const<476442828812030857794232422692155113556837216824>() -> ([26]); -store_temp([26]) -> ([26]); -array_append([25], [26]) -> ([27]); -struct_construct() -> ([28]); -struct_construct>>([28], [27]) -> ([29]); -enum_init>,)>, 1>([29]) -> ([30]); -store_temp([12]) -> ([31]); -store_temp([6]) -> ([32]); -store_temp([7]) -> ([33]); -store_temp>,)>>([30]) -> ([34]); -return([31], [32], [33], [34]); -branch_align() -> (); -enum_init>, 1>([11]) -> ([35]); -struct_construct>>>([35]) -> ([36]); -enum_init>,)>, 0>([36]) -> ([37]); -store_temp([0]) -> ([38]); -store_temp([9]) -> ([39]); -store_temp([10]) -> ([40]); -store_temp>,)>>([37]) -> ([41]); -return([38], [39], [40], [41]); -contract_address_to_felt252([2]) -> ([3]); -pedersen([0], [1], [3]) -> ([4], [5]); -store_temp([4]) -> ([6]); -store_temp([5]) -> ([7]); -return([6], [7]); -struct_deconstruct>([2]) -> ([3], [4]); -store_temp([0]) -> ([7]); -store_temp([1]) -> ([8]); -store_temp([3]) -> ([9]); -function_call([7], [8], [9]) -> ([5], [6]); -rename([5]) -> ([12]); -rename([6]) -> ([13]); -store_temp([4]) -> ([14]); -function_call([12], [13], [14]) -> ([10], [11]); -rename([10]) -> ([15]); -rename([11]) -> ([16]); -return([15], [16]); -enum_match, core::array::Array::>>([0]) { fallthrough([1]) 4264([2]) }; -branch_align() -> (); -struct_construct>>([1]) -> ([3]); -enum_init,)>, 0>([3]) -> ([4]); -store_temp,)>>([4]) -> ([5]); -return([5]); -branch_align() -> (); -struct_construct() -> ([6]); -struct_construct>>([6], [2]) -> ([7]); -enum_init,)>, 1>([7]) -> ([8]); -store_temp,)>>([8]) -> ([9]); -return([9]); -enum_init([0]) -> ([1]); -store_temp([1]) -> ([2]); -return([2]); -enum_init([0]) -> ([1]); -store_temp([1]) -> ([2]); -return([2]); -struct_deconstruct([1]) -> ([3], [4]); -struct_deconstruct([2]) -> ([5], [6]); -u128_overflowing_add([0], [4], [6]) { fallthrough([7], [8]) 4286([9], [10]) }; -branch_align() -> (); -struct_construct() -> ([11]); -enum_init([11]) -> ([12]); -struct_construct>([8], [12]) -> ([13]); -store_temp([7]) -> ([14]); -store_temp>([13]) -> ([15]); -jump() { 4292() }; -branch_align() -> (); -struct_construct() -> ([16]); -enum_init([16]) -> ([17]); -struct_construct>([10], [17]) -> ([18]); -store_temp([9]) -> ([14]); -store_temp>([18]) -> ([15]); -struct_deconstruct>([15]) -> ([19], [20]); -u128_overflowing_add([14], [3], [5]) { fallthrough([21], [22]) 4300([23], [24]) }; -branch_align() -> (); -struct_construct([22], [19]) -> ([25]); -struct_construct>([25], [20]) -> ([26]); -store_temp([21]) -> ([27]); -store_temp>([26]) -> ([28]); -jump() { 4320() }; -branch_align() -> (); -u128_const<1>() -> ([29]); -store_temp([29]) -> ([29]); -u128_overflowing_add([23], [19], [29]) { fallthrough([30], [31]) 4310([32], [33]) }; -branch_align() -> (); -struct_construct([24], [31]) -> ([34]); -struct_construct>([34], [20]) -> ([35]); -store_temp([30]) -> ([36]); -store_temp>([35]) -> ([37]); -jump() { 4318() }; -branch_align() -> (); -drop([20]) -> (); -struct_construct([24], [33]) -> ([38]); -struct_construct() -> ([39]); -enum_init([39]) -> ([40]); -struct_construct>([38], [40]) -> ([41]); -store_temp([32]) -> ([36]); -store_temp>([41]) -> ([37]); -rename([36]) -> ([27]); -rename>([37]) -> ([28]); -rename([27]) -> ([42]); -rename>([28]) -> ([43]); -return([42], [43]); -struct_deconstruct([1]) -> ([3], [4]); -struct_deconstruct([2]) -> ([5], [6]); -u128_overflowing_sub([0], [4], [6]) { fallthrough([7], [8]) 4333([9], [10]) }; -branch_align() -> (); -struct_construct() -> ([11]); -enum_init([11]) -> ([12]); -struct_construct>([8], [12]) -> ([13]); -store_temp([7]) -> ([14]); -store_temp>([13]) -> ([15]); -jump() { 4339() }; -branch_align() -> (); -struct_construct() -> ([16]); -enum_init([16]) -> ([17]); -struct_construct>([10], [17]) -> ([18]); -store_temp([9]) -> ([14]); -store_temp>([18]) -> ([15]); -struct_deconstruct>([15]) -> ([19], [20]); -u128_overflowing_sub([14], [3], [5]) { fallthrough([21], [22]) 4347([23], [24]) }; -branch_align() -> (); -struct_construct([22], [19]) -> ([25]); -struct_construct>([25], [20]) -> ([26]); -store_temp([21]) -> ([27]); -store_temp>([26]) -> ([28]); -jump() { 4367() }; -branch_align() -> (); -u128_const<1>() -> ([29]); -store_temp([29]) -> ([29]); -u128_overflowing_sub([23], [19], [29]) { fallthrough([30], [31]) 4357([32], [33]) }; -branch_align() -> (); -struct_construct([24], [31]) -> ([34]); -struct_construct>([34], [20]) -> ([35]); -store_temp([30]) -> ([36]); -store_temp>([35]) -> ([37]); -jump() { 4365() }; -branch_align() -> (); -drop([20]) -> (); -struct_construct([24], [33]) -> ([38]); -struct_construct() -> ([39]); -enum_init([39]) -> ([40]); -struct_construct>([38], [40]) -> ([41]); -store_temp([32]) -> ([36]); -store_temp>([41]) -> ([37]); -rename([36]) -> ([27]); -rename>([37]) -> ([28]); -rename([27]) -> ([42]); -rename>([28]) -> ([43]); -return([42], [43]); -dup([0]) -> ([0], [3]); -struct_deconstruct([3]) -> ([4], [5], [6]); -drop([5]) -> (); -drop([6]) -> (); -store_temp([4]) -> ([9]); -store_temp>([2]) -> ([10]); -function_call([9], [10]) -> ([7], [8]); -drop([8]) -> (); -dup([0]) -> ([0], [11]); -struct_deconstruct([11]) -> ([12], [13], [14]); -drop([12]) -> (); -drop([14]) -> (); -store_temp([13]) -> ([17]); -store_temp>([7]) -> ([18]); -function_call([17], [18]) -> ([15], [16]); -drop([16]) -> (); -struct_deconstruct([0]) -> ([19], [20], [21]); -drop([19]) -> (); -drop([20]) -> (); -store_temp([21]) -> ([24]); -store_temp>([15]) -> ([25]); -function_call([24], [25]) -> ([22], [23]); -drop([23]) -> (); -struct_construct() -> ([26]); -store_temp>([1]) -> ([27]); -store_temp>([22]) -> ([28]); -store_temp([26]) -> ([29]); -return([27], [28], [29]); -dup([0]) -> ([0], [3]); -struct_deconstruct([3]) -> ([4], [5], [6]); -drop([5]) -> (); -drop([6]) -> (); -store_temp([4]) -> ([9]); -store_temp>([2]) -> ([10]); -function_call([9], [10]) -> ([7], [8]); -drop([8]) -> (); -dup([0]) -> ([0], [11]); -struct_deconstruct([11]) -> ([12], [13], [14]); -drop([12]) -> (); -drop([14]) -> (); -store_temp([13]) -> ([17]); -store_temp>([7]) -> ([18]); -function_call([17], [18]) -> ([15], [16]); -drop([16]) -> (); -struct_deconstruct([0]) -> ([19], [20], [21]); -drop([19]) -> (); -drop([20]) -> (); -store_temp([21]) -> ([24]); -store_temp>([15]) -> ([25]); -function_call([24], [25]) -> ([22], [23]); -drop([23]) -> (); -struct_construct() -> ([26]); -store_temp>([1]) -> ([27]); -store_temp>([22]) -> ([28]); -store_temp([26]) -> ([29]); -return([27], [28], [29]); -rename([0]) -> ([2]); -contract_address_to_felt252([2]) -> ([3]); -snapshot_take([3]) -> ([4], [5]); -drop([4]) -> (); -store_temp([5]) -> ([8]); -store_temp>([1]) -> ([9]); -function_call([8], [9]) -> ([6], [7]); -drop([7]) -> (); -struct_construct() -> ([10]); -store_temp>([6]) -> ([11]); -store_temp([10]) -> ([12]); -return([11], [12]); - -erc20::erc20::erc_20::__external::get_name@0([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::get_symbol@101([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::get_decimals@202([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::get_total_supply@303([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::balance_of@404([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::allowance@534([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::transfer@689([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::transfer_from@836([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::approve@1009([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::increase_allowance@1156([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__external::decrease_allowance@1303([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::__constructor::constructor@1450([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); -erc20::erc20::erc_20::IERC20Impl::get_name@1677([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); -core::Felt252Serde::serialize@1702([0]: felt252, [1]: Array) -> (Array, Unit); -erc20::erc20::erc_20::IERC20Impl::get_symbol@1708([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); -erc20::erc20::erc_20::IERC20Impl::get_decimals@1733([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u8,)>); -core::integer::U8Serde::serialize@1761([0]: u8, [1]: Array) -> (Array, Unit); -erc20::erc20::erc_20::IERC20Impl::get_total_supply@1773([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u256,)>); -core::integer::u256Serde::serialize@1801([0]: core::integer::u256, [1]: Array) -> (Array, Unit); -core::starknet::contract_address::ContractAddressSerde::deserialize@1816([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); -erc20::erc20::erc_20::IERC20Impl::balance_of@1840([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); -erc20::erc20::erc_20::IERC20Impl::allowance@1872([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); -core::integer::u256Serde::deserialize@1905([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); -erc20::erc20::erc_20::IERC20Impl::transfer@1934([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::IERC20Impl::transfer_from@1981([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::IERC20Impl::approve@2055([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::IERC20Impl::increase_allowance@2102([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::IERC20Impl::decrease_allowance@2205([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -core::Felt252Serde::deserialize@2308([0]: core::array::Span::) -> (core::array::Span::, core::option::Option::); -core::integer::U8Serde::deserialize@2337([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); -erc20::erc20::erc_20::constructor@2379([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: felt252, [6]: felt252, [7]: u8, [8]: core::integer::u256, [9]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::name::InternalContractStateImpl::read@2589([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::name::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); -erc20::erc20::erc_20::symbol::InternalContractStateImpl::read@2624([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::symbol::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); -erc20::erc20::erc_20::decimals::InternalContractStateImpl::read@2659([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::decimals::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u8,)>); -erc20::erc20::erc_20::total_supply::InternalContractStateImpl::read@2697([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::total_supply::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u256,)>); -core::integer::U128Serde::serialize@2735([0]: u128, [1]: Array) -> (Array, Unit); -erc20::erc20::erc_20::balances::InternalContractStateImpl::read@2747([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::balances::ContractState, [5]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); -erc20::erc20::erc_20::allowances::InternalContractStateImpl::read@2791([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::allowances::ContractState, [5]: Tuple) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); -core::integer::U128Serde::deserialize@2835([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); -core::starknet::info::get_caller_address@2877([0]: GasBuiltin, [1]: System) -> (GasBuiltin, System, core::panics::PanicResult::<(core::starknet::contract_address::ContractAddress,)>); -erc20::erc20::erc_20::StorageImpl::transfer_helper@2901([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::StorageImpl::spend_allowance@3188([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::StorageImpl::approve_helper@3329([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -core::integer::U256Add::add@3436([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::panics::PanicResult::<(core::integer::u256,)>); -core::integer::U256Sub::sub@3459([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::panics::PanicResult::<(core::integer::u256,)>); -core::integer::Felt252TryIntoU8::try_into@3482([0]: RangeCheck, [1]: felt252) -> (RangeCheck, core::option::Option::); -erc20::erc20::erc_20::name::InternalContractStateImpl::write@3496([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::name::ContractState, [3]: felt252) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::name::ContractState, ())>); -erc20::erc20::erc_20::symbol::InternalContractStateImpl::write@3534([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::symbol::ContractState, [3]: felt252) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::symbol::ContractState, ())>); -erc20::erc20::erc_20::decimals::InternalContractStateImpl::write@3572([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::decimals::ContractState, [3]: u8) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::decimals::ContractState, ())>); -erc20::erc20::erc_20::total_supply::InternalContractStateImpl::write@3611([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::total_supply::ContractState, [3]: core::integer::u256) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::total_supply::ContractState, ())>); -erc20::erc20::erc_20::balances::InternalContractStateImpl::write@3639([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::balances::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::balances::ContractState, ())>); -erc20::erc20::erc_20::ContractStateEventEmitter::emit::>@3674([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Event) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3724([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::felt252,)>); -core::starknet::storage_access::StoreU8::read@3736([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); -core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3777([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::integer::u8,)>); -core::integer::Storeu256::read@3789([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); -core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3868([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::integer::u256,)>); -erc20::erc20::erc_20::balances::InternalContractStateImpl::address@3880([0]: RangeCheck, [1]: Pedersen, [2]: erc20::erc20::erc_20::balances::ContractState, [3]: ContractAddress) -> (RangeCheck, Pedersen, StorageBaseAddress); -erc20::erc20::erc_20::allowances::InternalContractStateImpl::address@3891([0]: RangeCheck, [1]: Pedersen, [2]: erc20::erc20::erc_20::allowances::ContractState, [3]: Tuple) -> (RangeCheck, Pedersen, StorageBaseAddress); -core::integer::u128_try_from_felt252@3902([0]: RangeCheck, [1]: felt252) -> (RangeCheck, core::option::Option::); -core::starknet::info::get_execution_info@3918([0]: GasBuiltin, [1]: System) -> (GasBuiltin, System, core::panics::PanicResult::<(core::box::Box::,)>); -erc20::erc20::erc_20::ContractStateEventEmitter::emit::@3947([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Transfer) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -erc20::erc20::erc_20::allowances::InternalContractStateImpl::write@3997([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::allowances::ContractState, [5]: Tuple, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::allowances::ContractState, ())>); -erc20::erc20::erc_20::ContractStateEventEmitter::emit::@4032([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Approval) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); -core::integer::u256_checked_add@4082([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::option::Option::); -core::integer::u256_checked_sub@4102([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::option::Option::); -core::starknet::SyscallResultTraitImpl::<()>::unwrap_syscall@4122([0]: core::result::Result::<(), core::array::Array::>) -> (core::panics::PanicResult::<((),)>); -core::integer::Storeu256::write@4134([0]: GasBuiltin, [1]: System, [2]: u32, [3]: StorageBaseAddress, [4]: core::integer::u256) -> (GasBuiltin, System, core::result::Result::<(), core::array::Array::>); -core::traits::TIntoT::::into@4169([0]: erc20::erc20::erc_20::Event) -> (erc20::erc20::erc_20::Event); -erc20::erc20::erc_20::EventIsEvent::append_keys_and_data@4171([0]: erc20::erc20::erc_20::Event, [1]: Array, [2]: Array) -> (Array, Array, Unit); -core::starknet::storage_access::StoreU128::read@4200([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); -core::hash::LegacyHashContractAddress::hash@4241([0]: Pedersen, [1]: felt252, [2]: ContractAddress) -> (Pedersen, felt252); -core::hash::TupleSize2LegacyHash::::hash@4246([0]: Pedersen, [1]: felt252, [2]: Tuple) -> (Pedersen, felt252); -core::starknet::SyscallResultTraitImpl::>::unwrap_syscall@4258([0]: core::result::Result::, core::array::Array::>) -> (core::panics::PanicResult::<(core::box::Box::,)>); -erc20::erc20::erc_20::EventTransferIntoEvent::into@4270([0]: erc20::erc20::erc_20::Transfer) -> (erc20::erc20::erc_20::Event); -erc20::erc20::erc_20::EventApprovalIntoEvent::into@4273([0]: erc20::erc20::erc_20::Approval) -> (erc20::erc20::erc_20::Event); -core::integer::u256_overflowing_add@4276([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, Tuple); -core::integer::u256_overflow_sub@4323([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, Tuple); -erc20::erc20::erc_20::TransferIsEvent::append_keys_and_data@4370([0]: erc20::erc20::erc_20::Transfer, [1]: Array, [2]: Array) -> (Array, Array, Unit); -erc20::erc20::erc_20::ApprovalIsEvent::append_keys_and_data@4398([0]: erc20::erc20::erc_20::Approval, [1]: Array, [2]: Array) -> (Array, Array, Unit); -core::starknet::contract_address::ContractAddressSerde::serialize@4426([0]: ContractAddress, [1]: Array) -> (Array, Unit); diff --git a/cairo_programs/wallet.sierra b/cairo_programs/wallet.sierra deleted file mode 100644 index 51f9a924c..000000000 --- a/cairo_programs/wallet.sierra +++ /dev/null @@ -1,1430 +0,0 @@ -{ - "sierra_program": [ - "0x1", - "0x3", - "0x0", - "0x2", - "0x2", - "0x0", - "0x110", - "0xf0", - "0x25", - "0x52616e6765436865636b", - "0x800000000000000100000000000000000000000000000000", - "0x537472756374", - "0x800000000000000f00000000000000000000000000000001", - "0x0", - "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", - "0x800000000000000f00000000000000000000000000000002", - "0x1", - "0x16a4c8d7c05909052238a862d8cc3e7975bf05a07b3a69c6b28951083a6d672", - "0x4172726179", - "0x800000000000000300000000000000000000000000000001", - "0x8", - "0x800000000000000300000000000000000000000000000003", - "0x3", - "0x4", - "0x456e756d", - "0xcc5e86243f861d2d64b08c35db21013e773ac5cf10097946fe0011304886d5", - "0x2", - "0x5", - "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", - "0x66656c74323532", - "0x800000000000000700000000000000000000000000000000", - "0x90d0203c41ad646d024845257a6eceb2f8b59b29ce7420dd518053d2edeedc", - "0x53746f7261676541646472657373", - "0x53746f726167654261736541646472657373", - "0x2633efa4b25602d1290a27d6aeb948fa53ef8a1976814cd1d78ed018207d9cd", - "0x800000000000000f00000000000000000000000000000003", - "0xc", - "0x289f3ec570490cc3a75d679992a6fbe6de8132318d9d268c66b360184dfa286", - "0xd", - "0x75313238", - "0x800000000000000700000000000000000000000000000003", - "0x25e2ca4b84968c2d8b83ef476ca8549410346b00836ce79beaf538155990bb2", - "0xf", - "0x800000000000000700000000000000000000000000000002", - "0x33dd38c898783061cd5539eddd96ee07d9522f364cb597d41a5d52b5c33314d", - "0x10", - "0x38ebd195e334343351be418d9529f6ec84f863f4b4de353979c00728b133d95", - "0x11", - "0x426f78", - "0x800000000000000700000000000000000000000000000001", - "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", - "0x13", - "0x10203be321c62a7bd4c060d69539c1fbe065baa9e253c74d2cc48be163e259", - "0x15", - "0x3520cd02f0e8297127614983b88bdaefde065b3fb4003d1a9d69b11592f6415", - "0x17", - "0x208991af02aa9b701a77c2c14af12d805ccecd643d794ba6794d824caf0095c", - "0x18", - "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", - "0x536e617073686f74", - "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", - "0x1b", - "0x1c", - "0x39d7e2f385e5d511ae0a83d1ae4f716c2c908fa7833dd212825a421b655f6c8", - "0x1e", - "0x4275696c74696e436f737473", - "0x53797374656d", - "0x9931c641b913035ae674b400b61a51476d506bbe8bba2ff8a6272790aba9e6", - "0x1d", - "0x753332", - "0x4761734275696c74696e", - "0x92", - "0x7265766f6b655f61705f747261636b696e67", - "0x77697468647261775f676173", - "0x6272616e63685f616c69676e", - "0x7374727563745f6465636f6e737472756374", - "0x61727261795f6c656e", - "0x736e617073686f745f74616b65", - "0x23", - "0x64726f70", - "0x7533325f636f6e7374", - "0x72656e616d65", - "0x73746f72655f74656d70", - "0x7533325f6571", - "0x61727261795f6e6577", - "0x66656c743235325f636f6e7374", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x61727261795f617070656e64", - "0x7374727563745f636f6e737472756374", - "0x656e756d5f696e6974", - "0x22", - "0x24", - "0x21", - "0x6765745f6275696c74696e5f636f737473", - "0x20", - "0x77697468647261775f6761735f616c6c", - "0x66756e6374696f6e5f63616c6c", - "0x656e756d5f6d61746368", - "0x1f", - "0x4f7574206f6620676173", - "0x1a", - "0x6", - "0x19", - "0x4661696c656420746f20646573657269616c697a6520706172616d202331", - "0x7", - "0x16", - "0x61727261795f736e617073686f745f706f705f66726f6e74", - "0x14", - "0x6a756d70", - "0x756e626f78", - "0x753132385f636f6e7374", - "0x12", - "0x9", - "0x66656c743235325f616464", - "0xa", - "0xe", - "0x73746f726167655f626173655f616464726573735f636f6e7374", - "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091", - "0x73746f726167655f616464726573735f66726f6d5f62617365", - "0x73746f726167655f726561645f73797363616c6c", - "0xb", - "0x656d69745f6576656e745f73797363616c6c", - "0x73746f726167655f77726974655f73797363616c6c", - "0x155e08616bcbb7488110b83d2b0fbb666a76c8444c7199784579e8339c7e629", - "0x647570", - "0x753132385f746f5f66656c74323532", - "0x295", - "0xffffffffffffffff", - "0x51", - "0x44", - "0x26", - "0x27", - "0x28", - "0x3d", - "0x29", - "0x2a", - "0x2b", - "0x2c", - "0x2d", - "0x2e", - "0x31", - "0x32", - "0x2f", - "0x30", - "0x33", - "0x34", - "0x35", - "0x36", - "0x37", - "0x38", - "0x39", - "0x3a", - "0x3b", - "0x3c", - "0x3e", - "0x3f", - "0x40", - "0x41", - "0x42", - "0x43", - "0x45", - "0x46", - "0x47", - "0x48", - "0x49", - "0x4a", - "0x4b", - "0x4c", - "0x4d", - "0x4e", - "0x4f", - "0x50", - "0x52", - "0x53", - "0x54", - "0xbf", - "0xb0", - "0x80", - "0xa2", - "0x9b", - "0x55", - "0x56", - "0x57", - "0x58", - "0x59", - "0x5a", - "0x5b", - "0x5c", - "0x12d", - "0x11e", - "0xee", - "0x110", - "0x109", - "0x14b", - "0x15f", - "0x164", - "0x16e", - "0x1ac", - "0x1a4", - "0x19e", - "0x5d", - "0x1c6", - "0x5e", - "0x5f", - "0x60", - "0x61", - "0x1d9", - "0x62", - "0x63", - "0x1de", - "0x64", - "0x65", - "0x66", - "0x1e9", - "0x67", - "0x68", - "0x69", - "0x6a", - "0x6b", - "0x6c", - "0x6d", - "0x6e", - "0x6f", - "0x20a", - "0x70", - "0x71", - "0x20f", - "0x72", - "0x73", - "0x74", - "0x75", - "0x21a", - "0x76", - "0x77", - "0x230", - "0x235", - "0x240", - "0x78", - "0x79", - "0x7a", - "0x7b", - "0x7c", - "0x24d", - "0x7d", - "0x7e", - "0x7f", - "0x81", - "0x26a", - "0x82", - "0x83", - "0x84", - "0x85", - "0x86", - "0x87", - "0x88", - "0x89", - "0x8a", - "0x8b", - "0x8c", - "0x8d", - "0x8e", - "0x8f", - "0x90", - "0x91", - "0xcd", - "0x13b", - "0x152", - "0x158", - "0x175", - "0x1b4", - "0x1cc", - "0x1ef", - "0x221", - "0x247", - "0x253", - "0x255", - "0x264", - "0x270", - "0x27a", - "0x289", - "0x1815", - "0x38100602834060c0402c1409028100608040180a07018180a04018080200", - "0x2018080b8141a100b0541e08040202805068402608090202205068401e08", - "0x583e1304078101d0283420080407010060286c061a0281006160c858300f", - "0x144010060205228138204c05118404a08120144603110204408108144003", - "0x6c061c040b80a070184c102d040b00a0d0803010060288c0608040ac102a", - "0xc1e08148cc1008060206405100402608188206005068401008178200c05", - "0x4c1038040dc0a0d08030102f040180a20018d810060288c0635040d00a23", - "0xd8100821814840520814803f010f82c3d0982078081d8141a10010e82c39", - "0x20104a23020104a230201049028481048230201047230201045060201044", - "0x4c1008280381008280301008278301008251382408268301008260149605", - "0x1400a572b020104a02954a40804128a80804128a608041281012290202451", - "0xbc1008238e010082196810082c8381c082c0bc1008250bc1008280701008", - "0x20104707820104504020104707838105807820104a060201047060201045", - "0xd81008250d810082396c240826814245204048a23c04020a03604020a00f", - "0x3810582f848104d1882010472f02010592e83810582e0201059098381058", - "0x20a02d04020866104020b20c07020b01c04020941c040208a2f040208660", - "0x14018080412410122d02024510e02010472d020104a02848b408091447008", - "0x14c8630402094350402094050918c1012288301008310201008250201008", - "0x2024512e020104a02848b80809144180804194c608041641012318202451", - "0x2094050919c10122889c100828094100828014240833048240833020245c", - "0x2010500f0201043358201059350381058188201043029a4d00e04160ce08", - "0x14dc6d09020d82d040208e0809178101228978100825014245e04048a231", - "0x160d00804124101234020245134020104a02848d008091440a6f35020104a", - "0x701c082c020246104048a261040209405091841012288b41008281c01c08", - "0x20245130020104a02848c008091440a710f0381058338201047338201045", - "0x48a21e04020a0053904810082197410082c9ac1c082c1801008248202460", - "0x128e61204134ce0804164d00804164101235820245135820104a02848d608", - "0x48a25d0402094050917410122884810082818010082c8881c082c09c1008", - "0x20104712820104312820107412838105812820104a13820104304048ba08", - "0x140a053b014ea2204020920804020920f04020922707020b022040209422", - "0x38100e02814ee08028480a602e848f01307848ee1204014240802814ee08", - "0x1dc106a041740a7035048ee0834020260534020ee08060201e0506020ee08", - "0x201805029dc101e041740a6b0f048ee080e02026050e020ee08029800a05", - "0x1dc100f041a80a22041dc1022041a00a25041dc106b040300a22041dc1070", - "0x780a27041dc10050e0140a77040142405028d80a77090944412380141e08", - "0x1dc10051281456083b820ce27090880a67041dc1067041ac0a67041dc1005", - "0xbc10770403c106a029841077040b41067028b41077040acc61213814c608", - "0xbc1e082e020ee08308205a052f020ee0809020c60518820ee08098205605", - "0x3862051a820ee081a8205e051a820ee08029840a053b8200a1202970bc31", - "0x1700a56041dc10052f0140a770401424052d0e024791e0d82477090d4260f", - "0x20a8081a814f4083b82024083181400083b820780815814a8083b820ac08", - "0x14c103c028d81077040d8106a0294c8c52071dc107b3d0001c36029ec1077", - "0x48ee083e02070053f820ee08028700a053b8200a12029f8107d3e020ee12", - "0x1ac0a053b82104082a0150682091dc1081041580a053b82100082d0150280", - "0x20a60543a182477042150812230150a083b820fe082901508083b8210608", - "0x20ee0844820f605029dc1088041e80a8944048ee08430200005029dc1087", - "0xac0a8d041dc1036041a80a8c041dc108b041f80a8b041dc108a041f00a8a", - "0x23d1c8d0782120083b8211808168151e083b8208c08318151c083b820a408", - "0x148102b029f41077040d8106a02a441077041f8106702814ee08028480a90", - "0x152893491f41e084a020ee08488205a0549820ee0823020c60549020ee08", - "0x258107704258106b02a58107704014fe054a820ee08028700a053b8200a12", - "0x19c0a98041dc10973c8484e053c820ee08028940a97041dc10964a8484405", - "0x2024083181536083b820b4081581534083b82070083501532083b8213008", - "0x38108002814ee08028480a9d4e26d340f04274107704264102d02a701077", - "0x880a9f041dc109f041ac0a9f041dc10053f8153c083b8200a1c02814ee08", - "0x288106702a8810770428142121381542083b8200a2502a8010770427d3c12", - "0x20ee0809020c60552020ee083002056053c020ee082e820d40551820ee08", - "0x481005090200a053b8200a0502a994aa43c03c10a6041dc10a3040b40aa5", - "0x20d40841014d4083b8201c08408140a770401424053017424a70983c2477", - "0x200a120287010a838020ee1234021060507820ee0807820d405340302477", - "0x9444123b820d60809814d6083b8203c08078143c083b8201808070140a77", - "0x19c105d028acce123b8204e08098144e083b8200a6002814ee0811020ba05", - "0x18c10770418c1068028b41077040ac100c0298c107704094100c02814ee08", - "0x200a1c02814ee0838020a805029dc1005090140aa9029dc242d31848e005", - "0xc41077040bcc212110145e083b8205e08358145e083b8200a1e029841077", - "0x20d4051a820ee082e020ce052e020ee08189782427029781077040144a05", - "0x1dc1035040b40a38041dc10120418c0a3c041dc1013040ac0a36041dc100f", - "0x1dc1056040bc0a56041dc1005308140a770401424052d0e0783607820b408", - "0x200a5e02814ee08028480a532304954522a048ee122b04c1e0e18814ac08", - "0x2001077040481063029fc107704148102b029e8107704000105c028001077", - "0x1ec1c770420902803f83d0c0541020ee0838020d60540820ee083d0206a05", - "0x14ee08028480a86042ad06083b848fc0843814a8083b820a80835014fc7c", - "0x210107a02a1508123b8210e08000150e083b8200a1c02814ee08418210805", - "0x228107704224107e02a24107704220107c02a20107704214107b02814ee08", - "0x205a0546820ee083e020c60546020ee083d820560545820ee082a020d405", - "0x1a80a8f041dc10860419c0a053b8200a1202a391a8c4583c108e041dc108a", - "0x211e0816814fa083b820f8083181522083b820f6081581520083b820a808", - "0x1dc10050e0140a77041c0105402814ee08028480a923ea45200f042481077", - "0x152a083b8212893090880a94041dc1094041ac0a94041dc10053f8152608", - "0x118106a029e410770425c106702a5c1077042552c12138152c083b8200a25", - "0x20ee083c8205a054d020ee0809020c6054c820ee082982056054c020ee08", - "0x14ee08060210005029dc101c0414c0a053b8200a1202a6d34994c03c109b", - "0x2753812110153a083b8213a08358153a083b8200a8502a701077040143805", - "0x20ee0850020ce0550020ee084f27c242702a7c1077040144a054f020ee08", - "0xb40a78041dc10120418c0aa3041dc1013040ac0aa2041dc100f041a80aa1", - "0x700a053b8201c08400140a77040142405521e146a20782148083b8214208", - "0x1dc10a652848440553020ee0853020d60553020ee08029fc0aa5041dc1005", - "0x155e083b8215c08338155c083b82158ad0909c0aad041dc1005128155808", - "0x2bc102d02ac8107704048106302ac4107704180102b02ac0107704174106a", - "0x2d0260f091dc2408028481005029dc10050281566b258ac01e0859820ee08", - "0x14d00c091dc106a042080a6a041dc100e042040a053b8200a1202980ba12", - "0x201c05029dc10050901438085a9c01077091a010830283c10770403c106a", - "0x2044082e8144a22091dc106b0404c0a6b041dc101e0403c0a1e041dc100c", - "0x300a053b820ce082e8145667091dc10270404c0a27041dc1005300140a77", - "0xb4c61238014c6083b820c608340145a083b820560806014c6083b8204a08", - "0x780a61041dc10050e0140a77041c0105402814ee08028480a055b014ee12", - "0x1dc10051281462083b8205e61090880a2f041dc102f041ac0a2f041dc1005", - "0xd810770403c106a028d41077041701067029701077040c4bc1213814bc08", - "0xd81e082d020ee081a8205a051c020ee0809020c6051e020ee08098205605", - "0x3862052b020ee082b0205e052b020ee08029840a053b8200a1202968703c", - "0x1700a00041dc10052f0140a770401424052991824b729150247709158260f", - "0x20f4081a81500083b820240831814fe083b820a40815814f4083b8200008", - "0x20d4053f1f0f60e3b8210481401fc1e8802a081077041c0106b02a041077", - "0x210608420140a77040142405430217083041dc247e0421c0a54041dc1054", - "0x1ec0a053b82108083d0150a84091dc1087040000a87041dc10050e0140a77", - "0x20a8083501514083b82112083f01512083b82110083e01510083b8210a08", - "0x238107704228102d02a341077041f0106302a301077041ec102b02a2c1077", - "0x20ee082a020d40547820ee0843020ce05029dc1005090151c8d4622c1e08", - "0x3c1092041dc108f040b40a7d041dc107c0418c0a91041dc107b040ac0a90", - "0x14fe0549820ee08028700a053b820e0082a0140a77040142405491f52290", - "0x20ee08028940a95041dc10944984844054a020ee084a020d6054a020ee08", - "0x1530083b8208c0835014f2083b8212e08338152e083b8212a960909c0a96", - "0x265300f0426c1077041e4102d02a68107704048106302a6410770414c102b", - "0x1dc10050e0140a7704030108002814ee080e020a605029dc100509015369a", - "0x153c083b8213a9c090880a9d041dc109d041ac0a9d041dc1005428153808", - "0x3c106a02a84107704280106702a801077042793e12138153e083b8200a25", - "0x20ee08508205a053c020ee0809020c60551820ee0809820560551020ee08", - "0x2941077040143805029dc100e042000a053b8200a1202a90f0a35103c10a4", - "0x144a0556020ee0853294242202a98107704298106b02a98107704014fe05", - "0x1dc105d041a80aaf041dc10ae0419c0aae041dc10ac568484e0556820ee08", - "0x2166083b8215e081681564083b82024083181562083b820c008158156008", - "0x200a0815814260f091dc100e042280a0e041dc1012042240ab3592c5600f", - "0x1dc1070351a01c8c029c010770404c108b029a81077040201063029a01077", - "0x1dc101c042380a053b8200a120287810b90e020ee12060211a0506180ba0e", - "0x9c1077040941090028941077041ac44124781444083b8201e082e014d608", - "0x19c1c0831820ee0813821220515820ee0830020c60533820ee082e8205605", - "0x174102b028b4107704078109202814ee0807820fa05029dc100509014c62b", - "0x24c0a31179841c0818820ee0816821220517820ee0830020c60530820ee08", - "0x201c08290141e083b8200a940283810770404810121101424083b8200a08", - "0x20109602820107704014100e0297426120417410770403c10950284c1077", - "0x2024083c81426083b8201c084b8140a7704014240507821740e09048ee12", - "0x200a9402814ee08028480a055d8200a990298010770404c1098029741077", - "0x1801077041a010980297410770403c1079029a0107704030109a028301077", - "0x7010bc38020ee1230021360535020ee0835021020535020ee082e820f605", - "0x20d6084e814d6083b8203c08498143c083b820e0084e0140a77040142405", - "0x200a120289c4a120409c107704088109e028941077041a81081028881077", - "0x21020515820ee08338213e0533820ee0802a500a053b8203808298140a77", - "0x2280a0f041dc1012042240a2d31848102d041dc102b042780a63041dc106a", - "0x174108b029c01077040201063029a8107704014102b0297426123b8201e08", - "0x1ac10bd0f020ee12340211a0534030c00e3b82038703503918050e020ee08", - "0x1dc102511049440512820ee0802a840a22041dc1005500140a77040142405", - "0x14c6083b82026082e01456083b820ce083c014ce083b8204e08518144e08", - "0xac10a40297010770418c1035029781077040301063028c4107704180102b", - "0x217c36041dc242f0421c0a2f308b41c77040d4b85e1883d4a051a820ee08", - "0x2158052d020ee08070e024a6028e0107704078108e02814ee08028480a3c", - "0x1dc102d040ac0a52041dc1056042240a053b820a80829814a856091dc1036", - "0x14fc083b820b40835814f8083b820a40845814f6083b820c20831814f408", - "0x200a1202a0010bf3f820ee12000215c050014c8c0e3b820fc7c3d9e81ead", - "0x20ee084120c24b002a0c107704204105c02a0902123b820fe08578140a77", - "0x2c80a85041dc10530418c0a84041dc1046040ac0a87041dc1086042c40a86", - "0xac0a89041dc1080042cc0a053b8200a1202a210a840702110083b8210e08", - "0x231168a0702118083b82112085901516083b820a6083181514083b8208c08", - "0x20ee081e0216605029dc100e041500a053b8203c08600140a77040142405", - "0x381090041dc108d042c80a8f041dc10610418c0a8e041dc102d040ac0a8d", - "0x1ac10b302814ee0809820fa05029dc100e041500a053b8200a1202a411e8e", - "0x20ee0848821640549020ee0806020c6053e820ee0830020560548820ee08", - "0x2010083181418083b8200a08158141e083b82024084481526923e8381093", - "0x20e06a340301ead029c0107704038106b029a810770403c108b029a01077", - "0x203808578140a770401424050f021821c041dc2460042b80a602e84c1c77", - "0x144e083b820d6082e0144a083b8200a9402814ee0811020a605111ac2477", - "0x20c60531820ee0809820560515820ee0833821620533820ee081289c24b0", - "0x216605029dc100509014c22d318381061041dc102b042c80a2d041dc105d", - "0x1dc102f042c80a5e041dc105d0418c0a31041dc1013040ac0a2f041dc101e", - "0x1dc100e0430c0a0e041dc1005610140a7704048107d02970bc3107020b808", - "0x3140a0f041dc100f043100a13041dc1013041a00a13041dc1005300141e08", - "0x201808638140a77040142405381a8d00e63030c05d071dc240f098200a0f", - "0x8810770407010c8029ac107704180106302878107704174102b028701077", - "0x20ee0834020560512820ee08380219405029dc1005090140ac9040153205", - "0x3300a67041dc10220432c0a22041dc1025043200a6b041dc106a0418c0a1e", - "0xac108e02814ee08028480a630433456083b8484e08468144e083b820ce08", - "0x20ee080f020560517820ee08308219e0530820ee08168219c0516820ee08", - "0x1dc100509014b85e18838105c041dc102f043400a5e041dc106b0418c0a31", - "0x3400a3c041dc106b0418c0a36041dc101e040ac0a35041dc1063043440a05", - "0x3c10770404c10d20284c10770403810a4028e078360702070083b8206a08", - "0x3010d4029a018123b8201e0869814c0083b8200a1c029741077040143805", - "0x881077041801052029ac1077041741052028781077041a010a402814ee08", - "0x942477041a8100002814ee080e020a6050e1c0d40e3b820446b0f039aa05", - "0x1e80a6315848ee0838020000533820ee0813820f605029dc1025041e80a27", - "0x1dc102d042040a67041dc1067042040a2d041dc1063041ec0a053b8205608", - "0x2500a053b8200a1202970bc310735c5e61091dc242d338200a0f6b0145a08", - "0x1dc102f0418c0a3c041dc1061040ac0a36041dc1035043600a35041dc1005", - "0x20b8086d8140a7704014240502b6810054c814b4083b8206c086c8147008", - "0x16810770415810d9028e01077041781063028f01077040c4102b029581077", - "0x14c10df23020ee122a021bc052a020ee0829021ba0529020ee082d021b805", - "0x1e810b1029e810770400024125801400083b8208c08700140a77040142405", - "0x20ee083d82164053f020ee081c020c6053e020ee081e02056053d820ee08", - "0x20010770414c10b302814ee0809020b405029dc100509014fe7e3e038107f", - "0x2041c0841820ee0840021640541020ee081c020c60540820ee081e0205605", - "0x2114052e820ee08029800a13041dc100f0430c0a0f041dc1005610150682", - "0x1dc1013043100a5d041dc105d041a00a053b82018083e8141860091dc1012", - "0x140a770401424050f070e00e711a8d0123b8481c132e8200a13708142608", - "0x20d408318144a083b820d0081581444083b820d6086c014d6083b8200a94", - "0x7810db02814ee08028480a05718200a990299c10770408810d90289c1077", - "0x20ee0815821b20513820ee080e020c60512820ee0838020560515820ee08", - "0x21c861041dc2463043780a63041dc102d043740a2d041dc1067043700a67", - "0x21cc052f020ee081898024e5028c410770418410e002814ee08028480a2f", - "0x1dc105c0439c0a36041dc10270418c0a35041dc1025040ac0a5c041dc105e", - "0x20ee0817821d005029dc1060041f40a053b8200a12028f06c35070207808", - "0x381054041dc10380439c0a56041dc10270418c0a5a041dc1025040ac0a38", - "0x20ee08040219c05029dc10050901424087502010770901410e902950ac5a", - "0x140a77040142405098201013041dc100f043400a0f041dc100e0433c0a0e", - "0x3010d00283010770418010d102980107704048ba1213814ba083b8200a25", - "0x141c083b8200a087581410080402010770401410a4029a0100834020ee08", - "0x1dc100f04048440507820ee0807820d60507820ee0802bb00a053b8200a12", - "0x14e0083b820240829014d4083b820260829014d0083b8201c08768142608", - "0x1480a1c041dc10054a0140a7704030105302830c05d071dc1070351a01ca9", - "0x88d61e0702044083b82038084a814d6083b820c008290143c083b820ba08", - "0x3c40a0e041dc1008043c00a053b8200a120284810ef04020ee1202821dc05", - "0x200a2502814ee08028480a130402026083b8201e08790141e083b8201c08", - "0x20ee0806021e40506020ee0830021e60530020ee08091742427029741077", - "0x20ee0809020a4052e820ee0807021ea0507020ee0802821e805340201068", - "0x1480a0c041dc10054a0140a770404c10530284c1e123b820c05d093d80a60", - "0x1c0d46807020e0083b82018084a814d4083b8201e0829014d0083b8201008", - "0x3e80a053b8201e087c8141e0e091dc1012043e00a1202848ee0802821ee05", - "0x20a6052e84c247704030c0127d81418083b820100829014c0083b8201c08", - "0x20ee0835021f405029dc1068043e40a6a34048ee0802821f005029dc105d", - "0x881077041c010fc02870e0123b820d61e093ec0a6b041dc1013041480a1e", - "0x20ee0809021fe0509020ee0802821fc0512888240812820ee080e021fa05", - "0x1480a0c041dc1013041ac0a053b8201e082a014260f091dc100e041580a0e", - "0x200a9402814ee0830020a605301742477041a0181223014d0083b8201008", - "0x14c0a0f33870e012040701077041a81095029c01077041741052029a81077", - "0x30c1c1204014a454298141e362a14c0a0f02838240802948a8530283c6c54", - "0x404240802968a853070bca853074001c1204014a454298141e362a14c0a0f", - "0x200a5e2a14c1c0c17950a60f81814b836090d8110204014100f0903c1812", - "0x200a612a14c1c1c2a14c1d050704810052f150a60e060bca85307c101c12", - "0x200a6b2a14c1c0c0e150a60f83838240802978a8530719c5e542983e0c12", - "0x42c2408028201e0f0703c1e67074280a670419c1109029841068044201c12", - "0x43810050403c240f1284a1a1204014100f078381e0f1383a18052e820c008", - "0x10f04014100f0903c4412" - ], - "sierra_program_debug_info": { - "type_names": [ - [ - 0, - "RangeCheck" - ], - [ - 1, - "Unit" - ], - [ - 2, - "Tuple" - ], - [ - 3, - "core::panics::Panic" - ], - [ - 4, - "Array" - ], - [ - 5, - "Tuple>" - ], - [ - 6, - "core::panics::PanicResult::<((),)>" - ], - [ - 7, - "core::result::Result::<(), core::array::Array::>" - ], - [ - 8, - "felt252" - ], - [ - 9, - "core::result::Result::>" - ], - [ - 10, - "StorageAddress" - ], - [ - 11, - "StorageBaseAddress" - ], - [ - 12, - "wallet::wallet::SimpleWallet::balance::ContractMemberState" - ], - [ - 13, - "Tuple" - ], - [ - 14, - "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::balance::ContractMemberState, ())>" - ], - [ - 15, - "u128" - ], - [ - 16, - "core::integer::u256" - ], - [ - 17, - "wallet::wallet::SimpleWallet::DummyEvent" - ], - [ - 18, - "wallet::wallet::SimpleWallet::Event" - ], - [ - 19, - "Box" - ], - [ - 20, - "core::option::Option::>" - ], - [ - 21, - "Tuple" - ], - [ - 22, - "core::panics::PanicResult::<(core::felt252,)>" - ], - [ - 23, - "wallet::wallet::SimpleWallet::ContractState" - ], - [ - 24, - "Tuple" - ], - [ - 25, - "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::ContractState, ())>" - ], - [ - 26, - "core::option::Option::" - ], - [ - 27, - "Snapshot>" - ], - [ - 28, - "core::array::Span::" - ], - [ - 29, - "Tuple>" - ], - [ - 30, - "Tuple" - ], - [ - 31, - "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::ContractState, core::felt252)>" - ], - [ - 32, - "BuiltinCosts" - ], - [ - 33, - "System" - ], - [ - 34, - "core::panics::PanicResult::<(core::array::Span::,)>" - ], - [ - 35, - "u32" - ], - [ - 36, - "GasBuiltin" - ] - ], - "libfunc_names": [ - [ - 0, - "revoke_ap_tracking" - ], - [ - 1, - "withdraw_gas" - ], - [ - 2, - "branch_align" - ], - [ - 3, - "struct_deconstruct>" - ], - [ - 4, - "array_len" - ], - [ - 5, - "snapshot_take" - ], - [ - 6, - "drop" - ], - [ - 7, - "u32_const<0>" - ], - [ - 8, - "rename" - ], - [ - 9, - "store_temp" - ], - [ - 10, - "store_temp" - ], - [ - 11, - "u32_eq" - ], - [ - 12, - "array_new" - ], - [ - 13, - "felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>" - ], - [ - 14, - "store_temp" - ], - [ - 15, - "array_append" - ], - [ - 16, - "struct_construct" - ], - [ - 17, - "struct_construct>>" - ], - [ - 18, - "enum_init,)>, 1>" - ], - [ - 19, - "store_temp" - ], - [ - 20, - "store_temp" - ], - [ - 21, - "store_temp,)>>" - ], - [ - 22, - "get_builtin_costs" - ], - [ - 23, - "store_temp" - ], - [ - 24, - "withdraw_gas_all" - ], - [ - 25, - "struct_construct" - ], - [ - 26, - "struct_construct" - ], - [ - 27, - "store_temp" - ], - [ - 28, - "function_call" - ], - [ - 29, - "enum_match>" - ], - [ - 30, - "struct_deconstruct>" - ], - [ - 31, - "drop" - ], - [ - 32, - "snapshot_take" - ], - [ - 33, - "drop" - ], - [ - 34, - "store_temp>" - ], - [ - 35, - "function_call" - ], - [ - 36, - "drop" - ], - [ - 37, - "snapshot_take>" - ], - [ - 38, - "drop>" - ], - [ - 39, - "struct_construct>" - ], - [ - 40, - "struct_construct>>" - ], - [ - 41, - "enum_init,)>, 0>" - ], - [ - 42, - "felt252_const<375233589013918064796019>" - ], - [ - 43, - "drop>" - ], - [ - 44, - "store_temp>" - ], - [ - 45, - "function_call" - ], - [ - 46, - "enum_match>" - ], - [ - 47, - "function_call" - ], - [ - 48, - "enum_match>" - ], - [ - 49, - "drop>" - ], - [ - 50, - "felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>" - ], - [ - 51, - "function_call" - ], - [ - 52, - "struct_deconstruct" - ], - [ - 53, - "snapshot_take" - ], - [ - 54, - "store_temp" - ], - [ - 55, - "function_call" - ], - [ - 56, - "enum_match>" - ], - [ - 57, - "struct_deconstruct>" - ], - [ - 58, - "struct_construct>" - ], - [ - 59, - "enum_init, 0>" - ], - [ - 60, - "store_temp>" - ], - [ - 61, - "drop" - ], - [ - 62, - "enum_init, 1>" - ], - [ - 63, - "rename" - ], - [ - 64, - "struct_construct" - ], - [ - 65, - "store_temp" - ], - [ - 66, - "array_snapshot_pop_front" - ], - [ - 67, - "enum_init>, 0>" - ], - [ - 68, - "store_temp>>" - ], - [ - 69, - "store_temp>>" - ], - [ - 70, - "jump" - ], - [ - 71, - "enum_init>, 1>" - ], - [ - 72, - "enum_match>>" - ], - [ - 73, - "unbox" - ], - [ - 74, - "enum_init, 0>" - ], - [ - 75, - "store_temp>" - ], - [ - 76, - "enum_init, 1>" - ], - [ - 77, - "u128_const<2>" - ], - [ - 78, - "u128_const<0>" - ], - [ - 79, - "struct_construct" - ], - [ - 80, - "struct_construct" - ], - [ - 81, - "enum_init" - ], - [ - 82, - "store_temp" - ], - [ - 83, - "function_call>>" - ], - [ - 84, - "felt252_add" - ], - [ - 85, - "struct_deconstruct>" - ], - [ - 86, - "function_call" - ], - [ - 87, - "enum_match>" - ], - [ - 88, - "struct_deconstruct>" - ], - [ - 89, - "struct_construct>" - ], - [ - 90, - "enum_init, 0>" - ], - [ - 91, - "store_temp>" - ], - [ - 92, - "enum_init, 1>" - ], - [ - 93, - "drop>" - ], - [ - 94, - "storage_base_address_const<916907772491729262376534102982219947830828984996257231353398618781993312401>" - ], - [ - 95, - "storage_address_from_base" - ], - [ - 96, - "store_temp" - ], - [ - 97, - "storage_read_syscall" - ], - [ - 98, - "enum_init>, 0>" - ], - [ - 99, - "store_temp>>" - ], - [ - 100, - "enum_init>, 1>" - ], - [ - 101, - "rename>>" - ], - [ - 102, - "function_call::unwrap_syscall>" - ], - [ - 103, - "struct_construct>" - ], - [ - 104, - "enum_init, 0>" - ], - [ - 105, - "store_temp>" - ], - [ - 106, - "enum_init, 1>" - ], - [ - 107, - "function_call::into>" - ], - [ - 108, - "snapshot_take" - ], - [ - 109, - "drop" - ], - [ - 110, - "function_call" - ], - [ - 111, - "emit_event_syscall" - ], - [ - 112, - "enum_init>, 0>" - ], - [ - 113, - "store_temp>>" - ], - [ - 114, - "enum_init>, 1>" - ], - [ - 115, - "rename>>" - ], - [ - 116, - "function_call::unwrap_syscall>" - ], - [ - 117, - "enum_match>" - ], - [ - 118, - "struct_deconstruct>" - ], - [ - 119, - "storage_write_syscall" - ], - [ - 120, - "struct_construct>" - ], - [ - 121, - "enum_init, 0>" - ], - [ - 122, - "store_temp>" - ], - [ - 123, - "enum_init, 1>" - ], - [ - 124, - "enum_match>>" - ], - [ - 125, - "enum_match" - ], - [ - 126, - "felt252_const<604044455298473900658797727502986337863043931241839670982572839358997980713>" - ], - [ - 127, - "store_temp" - ], - [ - 128, - "function_call" - ], - [ - 129, - "enum_match>>" - ], - [ - 130, - "struct_construct>" - ], - [ - 131, - "enum_init, 0>" - ], - [ - 132, - "store_temp>" - ], - [ - 133, - "enum_init, 1>" - ], - [ - 134, - "struct_deconstruct" - ], - [ - 135, - "store_temp" - ], - [ - 136, - "function_call" - ], - [ - 137, - "dup" - ], - [ - 138, - "struct_deconstruct" - ], - [ - 139, - "drop" - ], - [ - 140, - "store_temp" - ], - [ - 141, - "function_call" - ], - [ - 142, - "rename>" - ], - [ - 143, - "rename" - ], - [ - 144, - "rename" - ], - [ - 145, - "u128_to_felt252" - ] - ], - "user_func_names": [ - [ - 0, - "wallet::wallet::SimpleWallet::__wrapper_get_balance" - ], - [ - 1, - "wallet::wallet::SimpleWallet::__wrapper_increase_balance" - ], - [ - 2, - "wallet::wallet::SimpleWallet::__wrapper_constructor" - ], - [ - 3, - "wallet::wallet::SimpleWallet::SimpleWallet::get_balance" - ], - [ - 4, - "core::Felt252Serde::serialize" - ], - [ - 5, - "core::Felt252Serde::deserialize" - ], - [ - 6, - "wallet::wallet::SimpleWallet::SimpleWallet::increase_balance" - ], - [ - 7, - "wallet::wallet::SimpleWallet::constructor" - ], - [ - 8, - "wallet::wallet::SimpleWallet::balance::InternalContractMemberStateImpl::read" - ], - [ - 9, - "wallet::wallet::SimpleWallet::ContractStateEventEmitter::emit::>" - ], - [ - 10, - "wallet::wallet::SimpleWallet::balance::InternalContractMemberStateImpl::write" - ], - [ - 11, - "core::starknet::SyscallResultTraitImpl::::unwrap_syscall" - ], - [ - 12, - "core::traits::TIntoT::::into" - ], - [ - 13, - "wallet::wallet::SimpleWallet::EventIsEvent::append_keys_and_data" - ], - [ - 14, - "core::starknet::SyscallResultTraitImpl::<()>::unwrap_syscall" - ], - [ - 15, - "wallet::wallet::SimpleWallet::DummyEventIsEvent::append_keys_and_data" - ], - [ - 16, - "core::integer::u256Serde::serialize" - ], - [ - 17, - "core::integer::U128Serde::serialize" - ] - ] - }, - "contract_class_version": "0.1.0", - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320", - "function_idx": 1 - }, - { - "selector": "0x39e11d48192e4333233c7eb19d10ad67c362bb28580c604d67884c85da39695", - "function_idx": 0 - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [ - { - "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", - "function_idx": 2 - } - ] - }, - "abi": [ - { - "type": "impl", - "name": "SimpleWallet", - "interface_name": "wallet::wallet::ISimpleWallet" - }, - { - "type": "interface", - "name": "wallet::wallet::ISimpleWallet", - "items": [ - { - "type": "function", - "name": "get_balance", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "increase_balance", - "inputs": [ - { - "name": "amount", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", - "inputs": [ - { - "name": "initial_balance", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::integer::u256", - "members": [ - { - "name": "low", - "type": "core::integer::u128" - }, - { - "name": "high", - "type": "core::integer::u128" - } - ] - }, - { - "type": "event", - "name": "wallet::wallet::SimpleWallet::DummyEvent", - "kind": "struct", - "members": [ - { - "name": "value", - "type": "core::integer::u256", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "wallet::wallet::SimpleWallet::Event", - "kind": "enum", - "variants": [ - { - "name": "DummyEvent", - "type": "wallet::wallet::SimpleWallet::DummyEvent", - "kind": "nested" - } - ] - } - ] -} \ No newline at end of file diff --git a/cli/src/main.rs b/cli/src/main.rs index 177f70f55..c2dcbe052 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -202,7 +202,7 @@ fn invoke_parser( Some(Felt252::zero()), transaction_hash.unwrap(), )?; - let mut transactional_state = cached_state.create_transactional()?; + let mut transactional_state = cached_state.create_transactional(); let _tx_info = internal_invoke.apply(&mut transactional_state, &BlockContext::default(), 0)?; cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state)?)?; diff --git a/examples/contract_execution/main.rs b/examples/contract_execution/main.rs index 0bea3e760..cc7bb8a02 100644 --- a/examples/contract_execution/main.rs +++ b/examples/contract_execution/main.rs @@ -24,16 +24,7 @@ use starknet_in_rust::{ }; use std::{path::Path, sync::Arc}; -use tracing_subscriber::EnvFilter; - fn main() { - tracing::subscriber::set_global_default( - tracing_subscriber::FmtSubscriber::builder() - .with_env_filter(EnvFilter::from_default_env()) - .finish(), - ) - .unwrap(); - // replace this with the path to your compiled contract let contract_path = "starknet_programs/fibonacci.json"; diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index 266ad1074..f1ab212ff 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -96,7 +96,7 @@ fn run_contract( // Store the local cache changes into the shared cache. This updates the shared cache with all // the contracts used on this state. - contract_cache.extend(state.drain_private_contract_class_cache().unwrap()); + contract_cache.extend(state.drain_private_contract_class_cache()); invoke_tx_execution_info.call_info.unwrap().retdata } diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 319652bc3..8bac1f09e 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -176,7 +176,7 @@ fn main() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [Felt252::from_bytes_be(data_to_ascii(data).as_bytes())].to_vec(), - execution_resources: Some(ExecutionResources::default()), + execution_resources: ExecutionResources::default(), class_hash: Some(class_hash), storage_read_values: vec![Felt252::from_bytes_be(data_to_ascii(data).as_bytes())], accessed_storage_keys: expected_accessed_storage_keys, diff --git a/rpc_state_reader/Cargo.toml b/rpc_state_reader/Cargo.toml index 0cdbbf8ef..370ee93d4 100644 --- a/rpc_state_reader/Cargo.toml +++ b/rpc_state_reader/Cargo.toml @@ -21,7 +21,7 @@ flate2 = "1.0.25" serde_with = "3.0.0" dotenv = "0.15.0" cairo-vm = "0.8.5" -blockifier = "=0.2.0-rc0" +blockifier = "0.2.0-rc0" starknet_in_rust = { path = "../", version = "0.4.0" } [dev-dependencies] diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 094029c55..2ae84fab1 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -138,7 +138,7 @@ mod tests { ); assert_eq!( - tx_trace.validate_invocation.as_ref().unwrap().calldata, + tx_trace.validate_invocation.calldata, Some(vec![ stark_felt!("1"), stark_felt!("690c876e61beda61e994543af68038edac4e1cb1990ab06e52a2d27e56a1232"), @@ -157,16 +157,9 @@ mod tests { stark_felt!("38bd34c31a0a5c"), ]) ); - assert_eq!( - tx_trace.validate_invocation.as_ref().unwrap().retdata, - Some(vec![]) - ); + assert_eq!(tx_trace.validate_invocation.retdata, Some(vec![])); assert_eq_sorted!( - tx_trace - .validate_invocation - .as_ref() - .unwrap() - .execution_resources, + tx_trace.validate_invocation.execution_resources, ExecutionResources { n_steps: 790, n_memory_holes: 51, @@ -177,15 +170,7 @@ mod tests { ]), } ); - assert_eq!( - tx_trace - .validate_invocation - .as_ref() - .unwrap() - .internal_calls - .len(), - 1 - ); + assert_eq!(tx_trace.validate_invocation.internal_calls.len(), 1); assert_eq!( tx_trace.function_invocation.as_ref().unwrap().calldata, @@ -258,7 +243,7 @@ mod tests { ); assert_eq!( - tx_trace.fee_transfer_invocation.as_ref().unwrap().calldata, + tx_trace.fee_transfer_invocation.calldata, Some(vec![ stark_felt!("1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"), stark_felt!("2b0322a23ba4"), @@ -266,15 +251,11 @@ mod tests { ]) ); assert_eq!( - tx_trace.fee_transfer_invocation.as_ref().unwrap().retdata, + tx_trace.fee_transfer_invocation.retdata, Some(vec![1u128.into()]) ); assert_eq_sorted!( - tx_trace - .fee_transfer_invocation - .as_ref() - .unwrap() - .execution_resources, + tx_trace.fee_transfer_invocation.execution_resources, ExecutionResources { n_steps: 586, n_memory_holes: 42, @@ -284,15 +265,7 @@ mod tests { ]), } ); - assert_eq!( - tx_trace - .fee_transfer_invocation - .as_ref() - .unwrap() - .internal_calls - .len(), - 1 - ); + assert_eq!(tx_trace.fee_transfer_invocation.internal_calls.len(), 1); } #[test] diff --git a/rpc_state_reader/src/rpc_state.rs b/rpc_state_reader/src/rpc_state.rs index 60bfd21b2..3ff561339 100644 --- a/rpc_state_reader/src/rpc_state.rs +++ b/rpc_state_reader/src/rpc_state.rs @@ -11,7 +11,6 @@ use starknet_api::{ state::StorageKey, transaction::{Transaction as SNTransaction, TransactionHash}, }; -use starknet_in_rust::definitions::block_context::StarknetChainId; use std::{collections::HashMap, env, fmt::Display}; use thiserror::Error; @@ -25,16 +24,6 @@ pub enum RpcChain { TestNet2, } -impl From for StarknetChainId { - fn from(network: RpcChain) -> StarknetChainId { - match network { - RpcChain::MainNet => StarknetChainId::MainNet, - RpcChain::TestNet => StarknetChainId::TestNet, - RpcChain::TestNet2 => StarknetChainId::TestNet2, - } - } -} - impl fmt::Display for RpcChain { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -158,9 +147,9 @@ pub struct RpcResponse { #[derive(Debug, Deserialize, Clone, Eq, PartialEq)] pub struct TransactionTrace { - pub validate_invocation: Option, + pub validate_invocation: RpcCallInfo, pub function_invocation: Option, - pub fee_transfer_invocation: Option, + pub fee_transfer_invocation: RpcCallInfo, pub signature: Vec, pub revert_error: Option, } @@ -401,12 +390,12 @@ impl RpcState { } } - pub fn get_contract_class(&self, class_hash: &ClassHash) -> Option { + pub fn get_contract_class(&self, class_hash: &ClassHash) -> SNContractClass { self.rpc_call_result( "starknet_getClass", &json!([self.block.to_value().unwrap(), class_hash.0.to_string()]), ) - .ok() + .unwrap() } pub fn get_class_hash_at(&self, contract_address: &ContractAddress) -> ClassHash { @@ -418,7 +407,7 @@ impl RpcState { contract_address.0.key().clone().to_string() ]), ) - .unwrap_or_default(); + .unwrap(); ClassHash(hash) } @@ -431,8 +420,7 @@ impl RpcState { contract_address.0.key().clone().to_string() ]), ) - // When running deploy_account transactions, the nonce doesn't exist on the previous block so we return 0 - .unwrap_or_default() + .unwrap() } pub fn get_storage_at( @@ -451,7 +439,7 @@ impl RpcState { self.block.to_value().unwrap() ]), ) - .unwrap_or_default() + .unwrap() } /// Requests the given transaction to the Feeder Gateway API. diff --git a/rpc_state_reader/src/utils.rs b/rpc_state_reader/src/utils.rs index 1a5ecffb4..a56d9f3b7 100644 --- a/rpc_state_reader/src/utils.rs +++ b/rpc_state_reader/src/utils.rs @@ -11,7 +11,7 @@ use starknet_api::{ core::EntryPointSelector, deprecated_contract_class::{EntryPoint, EntryPointOffset, EntryPointType}, hash::{StarkFelt, StarkHash}, - transaction::{DeclareTransaction, InvokeTransaction, Transaction}, + transaction::{InvokeTransaction, Transaction}, }; #[derive(Debug, Deserialize)] @@ -82,24 +82,6 @@ pub fn deserialize_transaction_json( "unimplemented invoke version: {x}" ))), }, - "DEPLOY_ACCOUNT" => Ok(Transaction::DeployAccount(serde_json::from_value( - transaction, - )?)), - "DECLARE" => match tx_version.as_str() { - "0x0" => Ok(Transaction::Declare(DeclareTransaction::V0( - serde_json::from_value(transaction)?, - ))), - "0x1" => Ok(Transaction::Declare(DeclareTransaction::V1( - serde_json::from_value(transaction)?, - ))), - "0x2" => Ok(Transaction::Declare(DeclareTransaction::V2( - serde_json::from_value(transaction)?, - ))), - x => Err(serde::de::Error::custom(format!( - "unimplemented declare version: {x}" - ))), - }, - "L1_HANDLER" => Ok(Transaction::L1Handler(serde_json::from_value(transaction)?)), x => Err(serde::de::Error::custom(format!( "unimplemented transaction type deserialization: {x}" ))), diff --git a/rpc_state_reader/tests/blockifier_tests.rs b/rpc_state_reader/tests/blockifier_tests.rs index 584464929..a32139934 100644 --- a/rpc_state_reader/tests/blockifier_tests.rs +++ b/rpc_state_reader/tests/blockifier_tests.rs @@ -3,16 +3,11 @@ use blockifier::{ execution::{contract_class::ContractClass, entry_point::CallInfo}, state::{ cached_state::{CachedState, GlobalContractCache}, - errors::StateError, state_api::{StateReader, StateResult}, }, transaction::{ - account_transaction::AccountTransaction, - objects::TransactionExecutionInfo, - transactions::{ - DeclareTransaction, DeployAccountTransaction, ExecutableTransaction, - L1HandlerTransaction, - }, + account_transaction::AccountTransaction, objects::TransactionExecutionInfo, + transactions::ExecutableTransaction, }, }; use blockifier::{ @@ -32,10 +27,7 @@ use starknet::core::types::ContractClass as SNContractClass; use starknet_api::{ block::BlockNumber, contract_address, - core::{ - calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, - PatriciaKey, - }, + core::{ClassHash, CompiledClassHash, ContractAddress, Nonce, PatriciaKey}, hash::{StarkFelt, StarkHash}, patricia_key, stark_felt, state::StorageKey, @@ -70,7 +62,7 @@ impl StateReader for RpcStateReader { class_hash: &ClassHash, ) -> StateResult { Ok(match self.0.get_contract_class(class_hash) { - Some(SNContractClass::Legacy(compressed_legacy_cc)) => { + SNContractClass::Legacy(compressed_legacy_cc) => { let as_str = utils::decode_reader(compressed_legacy_cc.program).unwrap(); let program = Program::from_bytes(as_str.as_bytes(), None).unwrap(); let entry_points_by_type = utils::map_entry_points_by_type_legacy( @@ -82,7 +74,7 @@ impl StateReader for RpcStateReader { }); BlockifierContractClass::V0(ContractClassV0(inner)) } - Some(SNContractClass::Sierra(flattened_sierra_cc)) => { + SNContractClass::Sierra(flattened_sierra_cc) => { let middle_sierra: utils::MiddleSierraContractClass = { let v = serde_json::to_value(flattened_sierra_cc).unwrap(); serde_json::from_value(v).unwrap() @@ -97,7 +89,6 @@ impl StateReader for RpcStateReader { let casm_cc = CasmContractClass::from_contract_class(sierra_cc, false).unwrap(); BlockifierContractClass::V1(casm_cc.try_into().unwrap()) } - None => return Err(StateError::UndeclaredClassHash(*class_hash)), }) } @@ -185,46 +176,6 @@ pub fn execute_tx( let invoke = InvokeTransaction { tx, tx_hash }; AccountTransaction::Invoke(invoke) } - SNTransaction::DeployAccount(tx) => { - let contract_address = calculate_contract_address( - tx.contract_address_salt, - tx.class_hash, - &tx.constructor_calldata, - ContractAddress::default(), - ) - .unwrap(); - AccountTransaction::DeployAccount(DeployAccountTransaction { - tx, - tx_hash, - contract_address, - }) - } - SNTransaction::Declare(tx) => { - // Fetch the contract_class from the next block (as we don't have it in the previous one) - let mut next_block_state_reader = - RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); - let contract_class = next_block_state_reader - .get_compiled_contract_class(&tx.class_hash()) - .unwrap(); - - let declare = DeclareTransaction::new(tx, tx_hash, contract_class).unwrap(); - AccountTransaction::Declare(declare) - } - SNTransaction::L1Handler(tx) => { - // As L1Hanlder is not an account transaction we execute it here and return the result - let blockifier_tx = L1HandlerTransaction { - tx, - tx_hash, - paid_fee_on_l1: starknet_api::transaction::Fee(u128::MAX), - }; - return ( - blockifier_tx - .execute(&mut state, &block_context, true, true) - .unwrap(), - trace, - receipt, - ); - } _ => unimplemented!(), }; @@ -335,46 +286,6 @@ fn blockifier_test_recent_tx() { 186551, // real block 186552 RpcChain::MainNet )] -#[test_case( - "0x1cbc74e101a1533082a021ce53235cfd744899b0ff948d1949a64646e0f15c2", - 885298, // real block 885299 - RpcChain::TestNet -)] -#[test_case( - "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", - 281513, // real block 281514 - RpcChain::MainNet -)] -#[test_case( - "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", - 351268, // real block 351269 - RpcChain::MainNet -)] -#[test_case( - "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", - 351225, // real block 351226 - RpcChain::MainNet -)] -// DeployAccount for different account providers (as of October 2023): -// All of them were deployed on testnet using starkli -// OpenZeppelin (v0.7.0) -#[test_case( - "0x0012696c03a0f0301af190288d9824583be813b71882308e4c5d686bf5967ec5", - 889866, // real block 889867 - RpcChain::TestNet -)] -// Braavos (v3.21.10) -#[test_case( - "0x04dc838fd4ed265ab2ea5fbab08e67b398e3caaedf75c548113c6b2f995fc9db", - 889858, // real block 889859 - RpcChain::TestNet -)] -// Argent X (v5.7.0) -#[test_case( - "0x01583c47a929f81f6a8c74d31708a7f161603893435d51b6897017fdcdaafee4", - 889897, // real block 889898 - RpcChain::TestNet -)] fn blockifier_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) { let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -446,38 +357,3 @@ fn blockifier_test_case_reverted_tx(hash: &str, block_number: u64, chain: RpcCha ); } } - -#[test_case( - // Declare tx - "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", - 347899, // real block 347900 - RpcChain::MainNet -)] -#[test_case( - // Declare tx - "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", - 271887, // real block 271888 - RpcChain::MainNet -)] -fn blockifier_test_case_declare_tx(hash: &str, block_number: u64, chain: RpcChain) { - let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); - let TransactionExecutionInfo { - execute_call_info, - actual_fee, - .. - } = tx_info; - - assert!(execute_call_info.is_none()); - - let actual_fee = actual_fee.0; - if receipt.actual_fee != actual_fee { - let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; - - if diff >= 5 { - assert_eq!( - actual_fee, receipt.actual_fee, - "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", - ); - } - } -} diff --git a/rpc_state_reader/tests/sir_tests.rs b/rpc_state_reader/tests/sir_tests.rs index 44d480490..8e49d1aaa 100644 --- a/rpc_state_reader/tests/sir_tests.rs +++ b/rpc_state_reader/tests/sir_tests.rs @@ -8,10 +8,10 @@ use starknet_api::{ hash::{StarkFelt, StarkHash}, stark_felt, state::StorageKey, - transaction::{Transaction as SNTransaction, TransactionHash, TransactionVersion}, + transaction::{Transaction as SNTransaction, TransactionHash}, }; use starknet_in_rust::{ - core::{contract_address::compute_casm_class_hash, errors::state_errors::StateError}, + core::errors::state_errors::StateError, definitions::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, constants::{ @@ -26,7 +26,7 @@ use starknet_in_rust::{ cached_state::CachedState, contract_class_cache::PermanentContractClassCache, state_api::StateReader, state_cache::StorageEntry, BlockInfo, }, - transaction::{Declare, DeclareV2, DeployAccount, InvokeFunction, L1Handler}, + transaction::{InvokeFunction, Transaction}, utils::{Address, ClassHash}, }; @@ -34,15 +34,12 @@ use test_case::test_case; use rpc_state_reader::rpc_state::*; -#[derive(Debug)] pub struct RpcStateReader(RpcState); impl StateReader for RpcStateReader { fn get_contract_class(&self, class_hash: &ClassHash) -> Result { let hash = SNClassHash(StarkHash::new(*class_hash).unwrap()); - Ok(CompiledClass::from( - self.0.get_contract_class(&hash).unwrap(), - )) + Ok(CompiledClass::from(self.0.get_contract_class(&hash))) } fn get_class_hash_at(&self, contract_address: &Address) -> Result { @@ -87,12 +84,10 @@ impl StateReader for RpcStateReader { } #[allow(unused)] -pub fn execute_tx_configurable( +pub fn execute_tx( tx_hash: &str, network: RpcChain, block_number: BlockNumber, - skip_validate: bool, - skip_nonce_check: bool, ) -> ( TransactionExecutionInfo, TransactionTrace, @@ -140,79 +135,9 @@ pub fn execute_tx_configurable( // Get transaction before giving ownership of the reader let tx_hash = TransactionHash(stark_felt!(tx_hash)); let tx = match rpc_reader.0.get_transaction(&tx_hash) { - SNTransaction::Invoke(tx) => InvokeFunction::from_invoke_transaction(tx, chain_id) - .unwrap() - .create_for_simulation(skip_validate, false, false, false, skip_nonce_check), - SNTransaction::DeployAccount(tx) => { - DeployAccount::from_sn_api_transaction(tx, chain_id.to_felt()) - .unwrap() - .create_for_simulation(skip_validate, false, false, false) - } - SNTransaction::Declare(tx) => { - // Fetch the contract_class from the next block (as we don't have it in the previous one) - let next_block_state_reader = - RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); - let contract_class = next_block_state_reader - .get_contract_class(tx.class_hash().0.bytes().try_into().unwrap()) - .unwrap(); - - if tx.version() != TransactionVersion(2_u8.into()) { - let contract_class = match contract_class { - CompiledClass::Deprecated(cc) => cc.as_ref().clone(), - _ => unreachable!(), - }; - - let declare = Declare::new_with_tx_and_class_hash( - contract_class, - Address(Felt252::from_bytes_be(tx.sender_address().0.key().bytes())), - tx.max_fee().0, - Felt252::from_bytes_be(tx.version().0.bytes()), - tx.signature() - .0 - .iter() - .map(|f| Felt252::from_bytes_be(f.bytes())) - .collect(), - Felt252::from_bytes_be(tx.nonce().0.bytes()), - Felt252::from_bytes_be(tx_hash.0.bytes()), - tx.class_hash().0.bytes().try_into().unwrap(), - ) - .unwrap(); - declare.create_for_simulation(skip_validate, false, false, false) - } else { - let contract_class = match contract_class { - CompiledClass::Casm(cc) => cc.as_ref().clone(), - _ => unreachable!(), - }; - - let compiled_class_hash = compute_casm_class_hash(&contract_class).unwrap(); - - let declare = DeclareV2::new_with_sierra_class_hash_and_tx_hash( - None, - Felt252::from_bytes_be(tx.class_hash().0.bytes()), - Some(contract_class), - compiled_class_hash, - Address(Felt252::from_bytes_be(tx.sender_address().0.key().bytes())), - tx.max_fee().0, - Felt252::from_bytes_be(tx.version().0.bytes()), - tx.signature() - .0 - .iter() - .map(|f| Felt252::from_bytes_be(f.bytes())) - .collect(), - Felt252::from_bytes_be(tx.nonce().0.bytes()), - Felt252::from_bytes_be(tx_hash.0.bytes()), - ) - .unwrap(); - declare.create_for_simulation(skip_validate, false, false, false) - } - } - SNTransaction::L1Handler(tx) => L1Handler::from_sn_api_tx( - tx, - Felt252::from_bytes_be(tx_hash.0.bytes()), - Some(Felt252::from(u128::MAX)), - ) - .unwrap() - .create_for_simulation(skip_validate, false), + SNTransaction::Invoke(tx) => Transaction::InvokeFunction( + InvokeFunction::from_invoke_transaction(tx, chain_id).unwrap(), + ), _ => unimplemented!(), }; @@ -241,30 +166,6 @@ pub fn execute_tx_configurable( ) } -pub fn execute_tx( - tx_hash: &str, - network: RpcChain, - block_number: BlockNumber, -) -> ( - TransactionExecutionInfo, - TransactionTrace, - RpcTransactionReceipt, -) { - execute_tx_configurable(tx_hash, network, block_number, false, false) -} - -pub fn execute_tx_without_validate( - tx_hash: &str, - network: RpcChain, - block_number: BlockNumber, -) -> ( - TransactionExecutionInfo, - TransactionTrace, - RpcTransactionReceipt, -) { - execute_tx_configurable(tx_hash, network, block_number, true, true) -} - #[test] fn test_get_transaction_try_from() { let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); @@ -342,51 +243,6 @@ fn test_get_gas_price() { 186551, // real block 186552 RpcChain::MainNet )] -#[test_case( - "0x176a92e8df0128d47f24eebc17174363457a956fa233cc6a7f8561bfbd5023a", - 317092, // real block 317093 - RpcChain::MainNet -)] -#[test_case( - "0x1cbc74e101a1533082a021ce53235cfd744899b0ff948d1949a64646e0f15c2", - 885298, // real block 885299 - RpcChain::TestNet -)] -#[test_case( - "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", - 281513, // real block 281514 - RpcChain::MainNet -)] -#[test_case( - "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", - 351268, // real block 351269 - RpcChain::MainNet -)] -#[test_case( - "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", - 351225, // real block 351226 - RpcChain::MainNet -)] -// DeployAccount for different account providers (as of October 2023): -// All of them were deployed on testnet using starkli -// OpenZeppelin (v0.7.0) -#[test_case( - "0x0012696c03a0f0301af190288d9824583be813b71882308e4c5d686bf5967ec5", - 889866, // real block 889867 - RpcChain::TestNet -)] -// Braavos (v3.21.10) -#[test_case( - "0x04dc838fd4ed265ab2ea5fbab08e67b398e3caaedf75c548113c6b2f995fc9db", - 889858, // real block 889859 - RpcChain::TestNet -)] -// Argent X (v5.7.0) -#[test_case( - "0x01583c47a929f81f6a8c74d31708a7f161603893435d51b6897017fdcdaafee4", - 889897, // real block 889898 - RpcChain::TestNet -)] fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) { let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -404,14 +260,12 @@ fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) // check Cairo VM execution resources assert_eq_sorted!( - execution_resources.as_ref(), - Some( - &trace - .function_invocation - .as_ref() - .unwrap() - .execution_resources - ), + execution_resources, + trace + .function_invocation + .as_ref() + .unwrap() + .execution_resources, "execution resources mismatch" ); @@ -502,52 +356,3 @@ fn starknet_in_rust_test_case_reverted_tx(hash: &str, block_number: u64, chain: ); } } - -#[test_case( - "0x038c307a0a324dc92778820f2c6317f40157c06b12a7e537f7a16b2c015f64e7", - 274333-1, - RpcChain::MainNet -)] -fn test_validate_fee(hash: &str, block_number: u64, chain: RpcChain) { - let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); - let (tx_info_without_fee, _trace, _receipt) = - execute_tx_without_validate(hash, chain, BlockNumber(block_number)); - - assert_eq!(tx_info.actual_fee, receipt.actual_fee); - assert!(tx_info_without_fee.actual_fee < tx_info.actual_fee); -} - -#[test_case( - // Declare tx - "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", - 347899, // real block 347900 - RpcChain::MainNet -)] -#[test_case( - // Declare tx - "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", - 271887, // real block 271888 - RpcChain::MainNet -)] -fn starknet_in_rust_test_case_declare_tx(hash: &str, block_number: u64, chain: RpcChain) { - let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); - let TransactionExecutionInfo { - call_info, - actual_fee, - .. - } = tx_info; - - assert!(call_info.is_none()); - - let actual_fee = actual_fee; - if receipt.actual_fee != actual_fee { - let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; - - if diff >= 5 { - assert_eq!( - actual_fee, receipt.actual_fee, - "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", - ); - } - } -} diff --git a/rust-toolchain b/rust-toolchain index baa36b056..2d24a1e07 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.72.1" +channel = "1.70.0" components = ["rustfmt", "clippy"] profile = "minimal" diff --git a/src/core/contract_address/casm_contract_address.rs b/src/core/contract_address/casm_contract_address.rs index 23dc701e8..537146e23 100644 --- a/src/core/contract_address/casm_contract_address.rs +++ b/src/core/contract_address/casm_contract_address.rs @@ -112,7 +112,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm").unwrap(); + file = File::open("starknet_programs/cairo2/contract_a.casm").unwrap(); expected_result = felt_str!( "321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f", 16 @@ -144,7 +144,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm").unwrap(); + file = File::open("starknet_programs/cairo2/deploy.casm").unwrap(); expected_result = felt_str!( "53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0", 16 @@ -177,7 +177,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm").unwrap(); + file = File::open("starknet_programs/cairo2/fibonacci.casm").unwrap(); expected_result = felt_str!( "6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89", 16 @@ -210,7 +210,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm").unwrap(); + file = File::open("starknet_programs/cairo2/factorial.casm").unwrap(); expected_result = felt_str!( "7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641", 16 @@ -243,7 +243,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm").unwrap(); + file = File::open("starknet_programs/cairo2/emit_event.casm").unwrap(); expected_result = felt_str!( "3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2", 16 @@ -271,7 +271,7 @@ mod tests { #[test] fn test_declare_tx_class_hash() { - let file = File::open("starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm").unwrap(); + let file = File::open("starknet_programs/cairo2/events.casm").unwrap(); let reader = BufReader::new(file); let contract_class: CasmContractClass = serde_json::from_reader(reader).unwrap(); diff --git a/src/core/contract_address/deprecated_contract_address.rs b/src/core/contract_address/deprecated_contract_address.rs index 07e7e2911..325902d45 100644 --- a/src/core/contract_address/deprecated_contract_address.rs +++ b/src/core/contract_address/deprecated_contract_address.rs @@ -158,7 +158,7 @@ impl serde_json::ser::Formatter for PythonDefaultFormatter { } else { let buf = c.encode_utf16(&mut buf); for i in buf { - write!(writer, r"\u{:04x}", i)?; + write!(writer, r"\u{:4x}", i)?; } } } diff --git a/src/core/contract_address/sierra_contract_address.rs b/src/core/contract_address/sierra_contract_address.rs index a4df995c2..1bbcfb1e9 100644 --- a/src/core/contract_address/sierra_contract_address.rs +++ b/src/core/contract_address/sierra_contract_address.rs @@ -4,10 +4,7 @@ use cairo_lang_starknet::{ contract_class::{ContractClass as SierraContractClass, ContractEntryPoint}, }; use cairo_vm::felt::Felt252; -use serde::Serialize; -use serde_json::ser::Formatter; use starknet_crypto::{poseidon_hash_many, FieldElement, PoseidonHasher}; -use std::io::{self, Cursor}; const CONTRACT_CLASS_VERSION: &[u8] = b"CONTRACT_CLASS_V0.1.0"; @@ -63,22 +60,14 @@ pub fn compute_sierra_class_hash( hasher.update(constructors); // Hash abi - let abi = { - let mut buf = Cursor::new(Vec::new()); - let mut fmt = serde_json::Serializer::with_formatter(&mut buf, PythonJsonFormatter); - - contract_class + let abi = serde_json_pythonic::to_string_pythonic( + &contract_class .abi .as_ref() .ok_or(ContractAddressError::MissingAbi)? - .items - .serialize(&mut fmt) - .map_err(|_| ContractAddressError::MissingAbi)?; - - // Note: The following unwrap should never be triggered as long as serde_json generates - // UTF-8 encoded data, which in practice means it should never panic. - String::from_utf8(buf.into_inner()).unwrap() - }; + .items, + ) + .map_err(|_| ContractAddressError::MissingAbi)?; let abi_hash = FieldElement::from_byte_slice_be(&starknet_keccak(abi.as_bytes()).to_bytes_be()) .map_err(|_err| { @@ -137,8 +126,7 @@ mod tests { /// Test the correctness of the compute_sierra_class_hash function for a specific testnet contract. #[test] fn test_declare_tx_from_testnet() { - let file = File::open("starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra").unwrap(); - // 0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3 + let file = File::open("starknet_programs/cairo2/events.sierra").unwrap(); let reader = BufReader::new(file); let sierra_contract_class: SierraContractClass = serde_json::from_reader(reader).unwrap(); @@ -154,56 +142,3 @@ mod tests { ) } } - -struct PythonJsonFormatter; - -impl Formatter for PythonJsonFormatter { - fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> - where - W: ?Sized + io::Write, - { - if first { - Ok(()) - } else { - writer.write_all(b", ") - } - } - - fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> - where - W: ?Sized + io::Write, - { - if first { - Ok(()) - } else { - writer.write_all(b", ") - } - } - - fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> - where - W: ?Sized + io::Write, - { - writer.write_all(b": ") - } - - fn write_string_fragment(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> - where - W: ?Sized + io::Write, - { - let mut buf = [0, 0]; - - for c in fragment.chars() { - if c.is_ascii() { - writer.write_all(&[c as u8])?; - } else { - let buf = c.encode_utf16(&mut buf); - for i in buf { - write!(writer, r"\u{i:04x}")?; - } - } - } - - Ok(()) - } -} diff --git a/src/core/errors/state_errors.rs b/src/core/errors/state_errors.rs index ba09e3e51..7d6b3aa89 100644 --- a/src/core/errors/state_errors.rs +++ b/src/core/errors/state_errors.rs @@ -48,6 +48,4 @@ pub enum StateError { CustomError(String), #[error(transparent)] ByteArray(#[from] FromByteArrayError), - #[error("Failed to read contract class cache")] - FailedToReadContractClassCache, } diff --git a/src/definitions/constants.rs b/src/definitions/constants.rs index 4087af325..77bf941c9 100644 --- a/src/definitions/constants.rs +++ b/src/definitions/constants.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; pub(crate) const L2_TO_L1_MSG_HEADER_SIZE: usize = 3; pub(crate) const L1_TO_L2_MSG_HEADER_SIZE: usize = 5; -pub(crate) const CLASS_UPDATE_SIZE: usize = 1; +pub(crate) const DEPLOYMENT_INFO_SIZE: usize = 2; pub(crate) const CONSUMED_MSG_TO_L2_N_TOPICS: usize = 3; pub(crate) const LOG_MSG_TO_L1_N_TOPICS: usize = 2; pub(crate) const N_DEFAULT_TOPICS: usize = 1; // Events have one default topic. @@ -37,9 +37,9 @@ lazy_static! { 0.into(), 1.into(), 2.into(), - &Into::::into(0) | &QUERY_VERSION_BASE.clone(), - &Into::::into(1) | &QUERY_VERSION_BASE.clone(), - &Into::::into(2) | &QUERY_VERSION_BASE.clone(), + &0.into() | &QUERY_VERSION_BASE.clone(), + &1.into() | &QUERY_VERSION_BASE.clone(), + &2.into() | &QUERY_VERSION_BASE.clone(), ]; } diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index c13994ca9..30c86cc91 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -13,7 +13,7 @@ use crate::{ contract_class_cache::ContractClassCache, contract_storage_state::ContractStorageState, state_api::{State, StateReader}, - ExecutionResourcesManager, StateDiff, + ExecutionResourcesManager, }, syscalls::{ business_logic_syscall_handler::BusinessLogicSyscallHandler, @@ -41,16 +41,6 @@ use cairo_vm::{ }; use std::sync::Arc; -#[cfg(feature = "cairo-native")] -use { - crate::syscalls::native_syscall_handler::NativeSyscallHandler, - cairo_native::{ - context::NativeContext, execution_result::NativeExecutionResult, executor::NativeExecutor, - metadata::syscall_handler::SyscallHandlerMeta, utils::felt252_bigint, - }, - serde_json::Value, -}; - #[derive(Debug, Default)] pub struct ExecutionResult { pub call_info: Option, @@ -156,45 +146,6 @@ impl ExecutionEntryPoint { return Err(e); } - let n_reverted_steps = - (max_steps as usize) - resources_manager.cairo_usage.n_steps; - Ok(ExecutionResult { - call_info: None, - revert_error: Some(e.to_string()), - n_reverted_steps, - }) - } - } - } - CompiledClass::Sierra(sierra_contract_class) => { - let mut transactional_state = state.create_transactional()?; - - match self.native_execute( - &mut transactional_state, - sierra_contract_class, - tx_execution_context, - block_context, - ) { - Ok(call_info) => { - state.apply_state_update(&StateDiff::from_cached_state( - transactional_state, - )?)?; - - Ok(ExecutionResult { - call_info: Some(call_info), - revert_error: None, - n_reverted_steps: 0, - }) - } - Err(e) => { - if !support_reverted { - state.apply_state_update(&StateDiff::from_cached_state( - transactional_state, - )?)?; - - return Err(e); - } - let n_reverted_steps = (max_steps as usize) - resources_manager.cairo_usage.n_steps; Ok(ExecutionResult { @@ -223,15 +174,15 @@ impl ExecutionEntryPoint { let mut default_entry_point = None; let entry_point = entry_points .iter() - .filter(|x| { + .filter_map(|x| { if x.selector() == &*DEFAULT_ENTRY_POINT_SELECTOR { - default_entry_point = Some(*x); + default_entry_point = Some(x); } - x.selector() == &self.entry_point_selector + (x.selector() == &self.entry_point_selector).then_some(x) }) - .try_fold(None, |acc, x| match acc { - None => Ok(Some(x)), + .fold(Ok(None), |acc, x| match acc { + Ok(None) => Ok(Some(x)), _ => Err(TransactionError::NonUniqueEntryPoint), })?; @@ -255,15 +206,15 @@ impl ExecutionEntryPoint { let mut default_entry_point = None; let entry_point = entry_points .iter() - .filter(|x| { + .filter_map(|x| { if x.selector == DEFAULT_ENTRY_POINT_SELECTOR.to_biguint() { - default_entry_point = Some(*x); + default_entry_point = Some(x); } - x.selector == self.entry_point_selector.to_biguint() + (x.selector == self.entry_point_selector.to_biguint()).then_some(x) }) - .try_fold(None, |acc, x| match acc { - None => Ok(Some(x)), + .fold(Ok(None), |acc, x| match acc { + Ok(None) => Ok(Some(x)), _ => Err(TransactionError::NonUniqueEntryPoint), })?; entry_point @@ -294,7 +245,7 @@ impl ExecutionEntryPoint { entry_point_type: Some(self.entry_point_type), calldata: self.calldata.clone(), retdata, - execution_resources: Some(execution_resources.filter_unused_builtins()), + execution_resources: execution_resources.filter_unused_builtins(), events, l2_to_l1_messages, storage_read_values: starknet_storage_state.read_values, @@ -331,7 +282,7 @@ impl ExecutionEntryPoint { .iter() .map(|n| n.get_int_ref().cloned().unwrap_or_default()) .collect(), - execution_resources: Some(execution_resources.filter_unused_builtins()), + execution_resources: execution_resources.filter_unused_builtins(), events, l2_to_l1_messages, storage_read_values: starknet_storage_state.read_values, @@ -618,183 +569,4 @@ impl ExecutionEntryPoint { call_result, ) } - - #[cfg(not(feature = "cairo-native"))] - #[inline(always)] - fn native_execute( - &self, - _state: &mut CachedState, - _contract_class: Arc, - _tx_execution_context: &mut TransactionExecutionContext, - _block_context: &BlockContext, - ) -> Result { - Err(TransactionError::SierraCompileError( - "This version of SiR was compiled without the Cairo Native feature".to_string(), - )) - } - - #[cfg(feature = "cairo-native")] - #[inline(always)] - fn native_execute( - &self, - state: &mut CachedState, - contract_class: Arc, - tx_execution_context: &TransactionExecutionContext, - block_context: &BlockContext, - ) -> Result { - use cairo_lang_sierra::{ - extensions::core::{CoreLibfunc, CoreType, CoreTypeConcrete}, - program_registry::ProgramRegistry, - }; - use serde_json::json; - - use crate::syscalls::business_logic_syscall_handler::SYSCALL_BASE; - - let entry_point = match self.entry_point_type { - EntryPointType::External => contract_class - .entry_points_by_type - .external - .iter() - .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) - .unwrap(), - EntryPointType::Constructor => contract_class - .entry_points_by_type - .constructor - .iter() - .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) - .unwrap(), - EntryPointType::L1Handler => contract_class - .entry_points_by_type - .l1_handler - .iter() - .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) - .unwrap(), - }; - - let sierra_program = contract_class.extract_sierra_program().unwrap(); - let program_registry: ProgramRegistry = - ProgramRegistry::new(&sierra_program).unwrap(); - - let native_context = NativeContext::new(); - let mut native_program = native_context.compile(&sierra_program).unwrap(); - let contract_storage_state = - ContractStorageState::new(state, self.contract_address.clone()); - - let syscall_handler = NativeSyscallHandler { - starknet_storage_state: contract_storage_state, - events: Vec::new(), - l2_to_l1_messages: Vec::new(), - contract_address: self.contract_address.clone(), - internal_calls: Vec::new(), - caller_address: self.caller_address.clone(), - entry_point_selector: self.entry_point_selector.clone(), - tx_execution_context: tx_execution_context.clone(), - block_context: block_context.clone(), - resources_manager: Default::default(), - }; - - native_program - .insert_metadata(SyscallHandlerMeta::new(&syscall_handler)) - .unwrap(); - - let syscall_addr = native_program - .get_metadata::() - .unwrap() - .as_ptr() - .as_ptr() as *const () as usize; - - let entry_point_fn = &sierra_program - .funcs - .iter() - .find(|x| x.id.id == (entry_point.function_idx as u64)) - .unwrap(); - let ret_types: Vec<&CoreTypeConcrete> = entry_point_fn - .signature - .ret_types - .iter() - .map(|x| program_registry.get_type(x).unwrap()) - .collect(); - let entry_point_id = &entry_point_fn.id; - - let required_init_gas = native_program.get_required_init_gas(entry_point_id); - - let calldata: Vec<_> = self - .calldata - .iter() - .map(|felt| felt252_bigint(felt.to_bigint())) - .collect(); - - /* - Below we construct `params`, the Serde value that MLIR expects. It consists of the following: - - - One `null` value for each builtin that is going to be used. - - The maximum amout of gas allowed by the call. - - `syscall_addr`, the address of the syscall handler. - - `calldata`, an array of Felt arguments to the method being called. - */ - - let wrapped_calldata = vec![calldata]; - let params: Vec = sierra_program.funcs[entry_point_id.id as usize] - .params - .iter() - .map(|param| { - match param.ty.debug_name.as_ref().unwrap().as_str() { - "GasBuiltin" => { - json!(self.initial_gas) - } - "Pedersen" | "SegmentArena" | "RangeCheck" | "Bitwise" | "Poseidon" => { - json!(null) - } - "System" => { - json!(syscall_addr) - } - // calldata - "core::array::Span::" => json!(wrapped_calldata), - x => { - unimplemented!("unhandled param type: {:?}", x); - } - } - }) - .collect(); - - let mut writer: Vec = Vec::new(); - let returns = &mut serde_json::Serializer::new(&mut writer); - - let native_executor = NativeExecutor::new(native_program); - - native_executor - .execute(entry_point_id, json!(params), returns, required_init_gas) - .map_err(|e| TransactionError::CustomError(format!("cairo-native error: {:?}", e)))?; - - let value = NativeExecutionResult::deserialize_from_ret_types( - &mut serde_json::Deserializer::from_slice(&writer), - &ret_types, - ) - .expect("failed to serialize starknet execution result"); - - Ok(CallInfo { - caller_address: self.caller_address.clone(), - call_type: Some(self.call_type.clone()), - contract_address: self.contract_address.clone(), - code_address: self.code_address.clone(), - class_hash: Some( - self.get_code_class_hash(syscall_handler.starknet_storage_state.state)?, - ), - entry_point_selector: Some(self.entry_point_selector.clone()), - entry_point_type: Some(self.entry_point_type), - calldata: self.calldata.clone(), - retdata: value.return_values, - execution_resources: None, - events: syscall_handler.events, - storage_read_values: syscall_handler.starknet_storage_state.read_values, - accessed_storage_keys: syscall_handler.starknet_storage_state.accessed_keys, - failure_flag: value.failure_flag, - l2_to_l1_messages: syscall_handler.l2_to_l1_messages, - internal_calls: syscall_handler.internal_calls, - gas_consumed: self - .initial_gas - .saturating_sub(SYSCALL_BASE) - .saturating_sub(value.remaining_gas), - }) - } } diff --git a/src/execution/gas_usage.rs b/src/execution/gas_usage.rs index 85e26a90a..f0d254dc7 100644 --- a/src/execution/gas_usage.rs +++ b/src/execution/gas_usage.rs @@ -1,7 +1,6 @@ use crate::definitions::constants::*; use crate::execution::L2toL1MessageInfo; use crate::services::eth_definitions::eth_gas_constants::*; -use crate::state::state_api::StateChangesCount; /// Estimates L1 gas usage by Starknet's update state and the verifier /// @@ -20,13 +19,16 @@ use crate::state::state_api::StateChangesCount; /// The estimation of L1 gas usage as a `usize` value. pub fn calculate_tx_gas_usage( l2_to_l1_messages: Vec, - state_changes: &StateChangesCount, + n_modified_contracts: usize, + n_storage_changes: usize, l1_handler_payload_size: Option, + n_deployments: usize, ) -> usize { let residual_message_segment_length = get_message_segment_lenght(&l2_to_l1_messages, l1_handler_payload_size); - let residual_onchain_data_segment_length = get_onchain_data_segment_length(state_changes); + let residual_onchain_data_segment_length = + get_onchain_data_segment_length(n_modified_contracts, n_storage_changes, n_deployments); let n_l2_to_l1_messages = l2_to_l1_messages.len(); let n_l1_to_l2_messages = match l1_handler_payload_size { @@ -93,18 +95,22 @@ pub fn get_message_segment_lenght( } /// Calculates the amount of `felt252` added to the output message's segment by the given operations. -pub const fn get_onchain_data_segment_length(state_changes: &StateChangesCount) -> usize { - // For each newly modified contract: - // contract address (1 word). - // + 1 word with the following info: A flag indicating whether the class hash was updated, the - // number of entry updates, and the new nonce. - state_changes.n_modified_contracts * 2 - // For each class updated (through a deploy or a class replacement). - + state_changes.n_class_hash_updates * CLASS_UPDATE_SIZE - // For each modified storage cell: key, new value. - + state_changes.n_storage_updates * 2 - // For each compiled class updated (through declare): class_hash, compiled_class_hash - + state_changes.n_compiled_class_hash_updates * 2 +/// +/// # Parameters: +/// +/// - `n_modified_contracts`: The number of contracts modified by the transaction. +/// - `n_storage_changes`: The number of storage changes made by the transaction. +/// - `n_deployments`: The number of contracts deployed by the transaction. +/// +/// # Returns: +/// +/// The on-chain data segment length +pub const fn get_onchain_data_segment_length( + n_modified_contracts: usize, + n_storage_changes: usize, + n_deployments: usize, +) -> usize { + n_modified_contracts * 2 + n_storage_changes * 2 + n_deployments * DEPLOYMENT_INFO_SIZE } /// Calculates the cost of ConsumedMessageToL2 event emissions caused by an L1 handler with the given @@ -255,17 +261,8 @@ mod test { let message2 = L2toL1MessageInfo::new(ord_ev2, Address(1235.into())); assert_eq!( - calculate_tx_gas_usage( - vec![message1, message2], - &StateChangesCount { - n_storage_updates: 2, - n_class_hash_updates: 1, - n_compiled_class_hash_updates: 0, - n_modified_contracts: 2 - }, - Some(2) - ), - 76439 + calculate_tx_gas_usage(vec![message1, message2], 2, 2, Some(2), 1), + 77051 ) } } diff --git a/src/execution/mod.rs b/src/execution/mod.rs index 5c9774517..9fed18a67 100644 --- a/src/execution/mod.rs +++ b/src/execution/mod.rs @@ -43,7 +43,7 @@ pub struct CallInfo { pub entry_point_type: Option, pub calldata: Vec, pub retdata: Vec, - pub execution_resources: Option, + pub execution_resources: ExecutionResources, pub events: Vec, pub l2_to_l1_messages: Vec, pub storage_read_values: Vec, @@ -73,11 +73,11 @@ impl CallInfo { entry_point_type, calldata: Vec::new(), retdata: Vec::new(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 0, builtin_instance_counter: HashMap::new(), n_memory_holes: 0, - }), + }, events: Vec::new(), l2_to_l1_messages: Vec::new(), storage_read_values: Vec::new(), @@ -238,11 +238,11 @@ impl Default for CallInfo { l2_to_l1_messages: Vec::new(), accessed_storage_keys: HashSet::new(), calldata: Vec::new(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 0, n_memory_holes: 0, builtin_instance_counter: HashMap::new(), - }), + }, events: Vec::new(), gas_consumed: 0, failure_flag: false, @@ -291,7 +291,7 @@ impl<'de> Deserialize<'de> for CallInfo { } Ok(CallInfo { - execution_resources: Some(execution_resources), + execution_resources, retdata, calldata, internal_calls, @@ -370,7 +370,6 @@ pub struct TransactionExecutionContext { pub(crate) nonce: Felt252, pub(crate) n_sent_messages: usize, pub(crate) _n_steps: u64, - // pub(crate) use_cairo_native: bool, } impl TransactionExecutionContext { diff --git a/src/lib.rs b/src/lib.rs index 205b218a3..b14dfc402 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -436,10 +436,9 @@ mod test { let block_context = BlockContext::default(); let Transaction::InvokeFunction(simul_invoke) = - invoke.create_for_simulation(true, false, false, false, false) - else { - unreachable!() - }; + invoke.create_for_simulation(true, false, false, false, false) else { + unreachable!() + }; let call_info = simul_invoke .run_validate_entrypoint( @@ -712,7 +711,7 @@ mod test { simulate_transaction( &[&internal_deploy], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -753,7 +752,7 @@ mod test { simulate_transaction( &[&declare_tx], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -821,7 +820,7 @@ mod test { simulate_transaction( &[&invoke_tx], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -868,7 +867,7 @@ mod test { simulate_transaction( &[&deploy_account_tx], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -897,7 +896,7 @@ mod test { nonce: 0.into(), hash_value: 0.into(), compiled_class_hash: TEST_FIB_COMPILED_CONTRACT_CLASS_HASH.clone(), - sierra_contract_class: Some(sierra_contract_class), + sierra_contract_class, sierra_class_hash, casm_class: Default::default(), skip_execute: false, @@ -913,7 +912,7 @@ mod test { simulate_transaction( &[&declare_tx], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -982,7 +981,7 @@ mod test { simulate_transaction( &[&l1_handler_tx], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -1043,7 +1042,7 @@ mod test { simulate_transaction( &[&deploy, &invoke_tx], - state.clone_for_testing(), + state.clone(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -1057,7 +1056,7 @@ mod test { assert_eq!( estimate_fee(&[deploy, invoke_tx], state, block_context,).unwrap(), - [(0, 1836), (0, 2448)] + [(0, 2448), (0, 2448)] ); } @@ -1082,119 +1081,4 @@ mod test { ) ); } - - #[test] - fn test_simulate_declare_v1_compare_fees() { - // accounts contract class must be stored before running declaration of fibonacci - let contract_class = ContractClass::from_path("starknet_programs/Account.json").unwrap(); - - // Instantiate CachedState - let contract_class_cache = PermanentContractClassCache::default(); - - // ------------ contract data -------------------- - let hash = compute_deprecated_class_hash(&contract_class).unwrap(); - let class_hash = hash.to_be_bytes(); - - contract_class_cache.set_contract_class( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - ); - - // store sender_address - let sender_address = Address(1.into()); - // this is not conceptually correct as the sender address would be an - // Account contract (not the contract that we are currently declaring) - // but for testing reasons its ok - - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(sender_address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(sender_address.clone(), Felt252::new(1)); - - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - // Insert pubkey storage var to pass validation - let storage_entry = &( - sender_address, - felt_str!( - "1672321442399497129215646424919402195095307045612040218489019266998007191460" - ) - .to_be_bytes(), - ); - state.set_storage_at( - storage_entry, - felt_str!( - "1735102664668487605176656616876767369909409133946409161569774794110049207117" - ), - ); - - //* --------------------------------------- - //* Test declare with previous data - //* --------------------------------------- - - let fib_contract_class = - ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - - let chain_id = StarknetChainId::TestNet.to_felt(); - - // declare tx - // Signature & tx hash values are hand-picked for account validations to pass - let mut declare = Declare::new( - fib_contract_class, - chain_id, - Address(Felt252::one()), - 60000, - 1.into(), - vec![ - felt_str!( - "3086480810278599376317923499561306189851900463386393948998357832163236918254" - ), - felt_str!( - "598673427589502599949712887611119751108407514580626464031881322743364689811" - ), - ], - Felt252::one(), - ) - .unwrap(); - declare.hash_value = felt_str!("2718"); - - let mut block_context = BlockContext::default(); - block_context.starknet_os_config_mut().gas_price = 12; - - let declare_tx = Transaction::Declare(declare); - - let without_validate_fee = simulate_transaction( - &[&declare_tx], - state.clone_for_testing(), - state.clone_for_testing().contract_class_cache().clone(), - &block_context, - 100_000_000, - true, - false, - true, - false, - false, - ) - .unwrap()[0] - .actual_fee; - - let with_validate_fee = simulate_transaction( - &[&declare_tx], - state.clone_for_testing(), - state.contract_class_cache().clone(), - &block_context, - 100_000_000, - false, - false, - true, - false, - false, - ) - .unwrap()[0] - .actual_fee; - - assert!(with_validate_fee > without_validate_fee) - } } diff --git a/src/services/api/contract_classes/compiled_class.rs b/src/services/api/contract_classes/compiled_class.rs index 26b56281f..035a96fbb 100644 --- a/src/services/api/contract_classes/compiled_class.rs +++ b/src/services/api/contract_classes/compiled_class.rs @@ -24,7 +24,6 @@ use starknet::core::types::ContractClass::{Legacy, Sierra}; pub enum CompiledClass { Deprecated(Arc), Casm(Arc), - Sierra(Arc), } impl TryInto for CompiledClass { @@ -130,7 +129,7 @@ impl From for CompiledClass { ) }) .collect::>(); - entry_points_by_type.insert(EntryPointType::L1Handler, l1_handler_entries); + entry_points_by_type.insert(EntryPointType::Constructor, l1_handler_entries); let v = serde_json::to_value(&_deprecated_contract_class.abi).unwrap(); let abi: Option = serde_json::from_value(v).unwrap(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 1f8394bbb..c453e1a96 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -1,6 +1,6 @@ use super::{ contract_class_cache::ContractClassCache, - state_api::{State, StateChangesCount, StateReader}, + state_api::{State, StateReader}, state_cache::{StateCache, StorageEntry}, }; use crate::{ @@ -12,19 +12,19 @@ use crate::{ to_cache_state_storage_mapping, Address, ClassHash, }, }; -use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; use getset::{Getters, MutGetters}; use num_traits::Zero; use std::{ + cell::RefCell, collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, + sync::Arc, }; pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; /// Represents a cached state of contract classes with optional caches. -#[derive(Default, Debug, Getters, MutGetters)] +#[derive(Default, Clone, Debug, Getters, MutGetters)] pub struct CachedState { pub state_reader: Arc, #[getset(get = "pub", get_mut = "pub")] @@ -32,7 +32,7 @@ pub struct CachedState { #[getset(get = "pub", get_mut = "pub")] pub(crate) contract_class_cache: Arc, - pub(crate) contract_class_cache_private: RwLock>, + pub(crate) contract_class_cache_private: RefCell>, #[cfg(feature = "metrics")] cache_hits: usize, @@ -73,7 +73,7 @@ impl CachedState { cache: StateCache::default(), state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RwLock::new(HashMap::new()), + contract_class_cache_private: RefCell::new(HashMap::new()), #[cfg(feature = "metrics")] cache_hits: 0, @@ -92,7 +92,7 @@ impl CachedState { cache, state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RwLock::new(HashMap::new()), + contract_class_cache_private: RefCell::new(HashMap::new()), #[cfg(feature = "metrics")] cache_hits: 0, @@ -101,51 +101,28 @@ impl CachedState { } } - /// Clones a CachedState for testing purposes. - pub fn clone_for_testing(&self) -> Self { - Self { - state_reader: self.state_reader.clone(), - cache: self.cache.clone(), - contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RwLock::new( - self.contract_class_cache_private.read().unwrap().clone(), - ), - #[cfg(feature = "metrics")] - cache_hits: self.cache_hits, - #[cfg(feature = "metrics")] - cache_misses: self.cache_misses, - } - } - pub fn drain_private_contract_class_cache( &self, - ) -> Result, StateError> { - Ok(self - .contract_class_cache_private - .read() - .map_err(|_| StateError::FailedToReadContractClassCache)? - .clone() - .into_iter()) + ) -> impl Iterator { + self.contract_class_cache_private.take().into_iter() } /// Creates a copy of this state with an empty cache for saving changes and applying them /// later. - pub fn create_transactional(&self) -> Result, StateError> { - Ok(CachedState { - state_reader: self.state_reader.clone(), + pub fn create_transactional(&self) -> TransactionalCachedState { + let state_reader = Arc::new(TransactionalCachedStateReader::new(self)); + CachedState { + state_reader, cache: self.cache.clone(), contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RwLock::new( - self.contract_class_cache_private - .read() - .map_err(|_| StateError::FailedToReadContractClassCache)? - .clone(), + contract_class_cache_private: RefCell::new( + self.contract_class_cache_private.borrow().clone(), ), #[cfg(feature = "metrics")] cache_hits: 0, #[cfg(feature = "metrics")] cache_misses: 0, - }) + } } } @@ -200,10 +177,7 @@ impl StateReader for CachedState { } // I: FETCHING FROM CACHE - let mut private_cache = self - .contract_class_cache_private - .write() - .map_err(|_| StateError::FailedToReadContractClassCache)?; + let mut private_cache = self.contract_class_cache_private.borrow_mut(); if let Some(compiled_class) = private_cache.get(class_hash) { return Ok(compiled_class.clone()); } else if let Some(compiled_class) = @@ -247,7 +221,6 @@ impl State for CachedState { // have a mutable reference to the `RefCell` available. self.contract_class_cache_private .get_mut() - .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, contract_class.clone()); Ok(()) @@ -321,7 +294,7 @@ impl State for CachedState { let compiled_class_hash = compiled_class_hash.to_be_bytes(); self.cache - .compiled_class_hash_writes + .class_hash_to_compiled_class_hash .insert(class_hash, compiled_class_hash); Ok(()) } @@ -338,10 +311,10 @@ impl State for CachedState { Ok(()) } - fn count_actual_state_changes( + fn count_actual_storage_changes( &mut self, fee_token_and_sender_address: Option<(&Address, &Address)>, - ) -> Result { + ) -> Result<(usize, usize), StateError> { self.update_initial_values_of_write_only_accesses()?; let mut storage_updates = subtract_mappings( @@ -351,16 +324,9 @@ impl State for CachedState { let storage_unique_updates = storage_updates.keys().map(|k| k.0.clone()); - let class_hash_updates: Vec<&Address> = subtract_mappings_keys( + let class_hash_updates = subtract_mappings_keys( &self.cache.class_hash_writes, &self.cache.class_hash_initial_values, - ) - .collect(); - let n_class_hash_updates = class_hash_updates.len(); - - let compiled_class_hash_updates = subtract_mappings_keys( - &self.cache.compiled_class_hash_writes, - &self.cache.compiled_class_hash_initial_values, ); let nonce_updates = @@ -368,7 +334,7 @@ impl State for CachedState { let mut modified_contracts: HashSet
= HashSet::new(); modified_contracts.extend(storage_unique_updates); - modified_contracts.extend(class_hash_updates.into_iter().cloned()); + modified_contracts.extend(class_hash_updates.cloned()); modified_contracts.extend(nonce_updates.cloned()); // Add fee transfer storage update before actually charging it, as it needs to be included in the @@ -382,12 +348,7 @@ impl State for CachedState { modified_contracts.remove(fee_token_address); } - Ok(StateChangesCount { - n_storage_updates: storage_updates.len(), - n_class_hash_updates, - n_compiled_class_hash_updates: compiled_class_hash_updates.count(), - n_modified_contracts: modified_contracts.len(), - }) + Ok((modified_contracts.len(), storage_updates.len())) } /// Returns the class hash for a given contract address. @@ -485,7 +446,6 @@ impl State for CachedState { if let Some(compiled_class) = self .contract_class_cache_private .get_mut() - .map_err(|_| StateError::FailedToReadContractClassCache)? .get(class_hash) .cloned() { @@ -497,7 +457,6 @@ impl State for CachedState { self.add_hit(); self.contract_class_cache_private .get_mut() - .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, compiled_class.clone()); return Ok(compiled_class); } @@ -506,14 +465,14 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - let write_guard = self - .contract_class_cache_private - .get_mut() - .map_err(|_| StateError::FailedToReadContractClassCache)?; - // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when // we have a mutable reference to the `RefCell` available. - if let Some(casm_class) = write_guard.get(compiled_class_hash).cloned() { + if let Some(casm_class) = self + .contract_class_cache_private + .get_mut() + .get(compiled_class_hash) + .cloned() + { self.add_hit(); return Ok(casm_class); } else if let Some(casm_class) = self @@ -523,21 +482,11 @@ impl State for CachedState { self.add_hit(); self.contract_class_cache_private .get_mut() - .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, casm_class.clone()); return Ok(casm_class); } } - // if let Some(sierra_compiled_class) = self - // .sierra_programs - // .as_ref() - // .and_then(|x| x.get(class_hash)) - // { - // return Ok(CompiledClass::Sierra(Arc::new( - // sierra_compiled_class.clone(), - // ))); - // } // II: FETCHING FROM STATE_READER let contract = self.state_reader.get_contract_class(class_hash)?; match contract { @@ -552,34 +501,137 @@ impl State for CachedState { CompiledClass::Deprecated(ref contract) => { self.set_contract_class(class_hash, &CompiledClass::Deprecated(contract.clone()))? } - CompiledClass::Sierra(ref sierra_compiled_class) => self.set_contract_class( - class_hash, - &CompiledClass::Sierra(sierra_compiled_class.clone()), - )?, } Ok(contract) } +} - fn set_sierra_program( - &mut self, - compiled_class_hash: &Felt252, - _sierra_program: Vec, - ) -> Result<(), StateError> { - let _compiled_class_hash = compiled_class_hash.to_be_bytes(); +/// A CachedState which has access to another, "parent" state, used for executing transactions +/// without commiting changes to the parent. +pub type TransactionalCachedState<'a, T, C> = + CachedState, C>; + +/// State reader used for transactional states which allows to check the parent state's cache and +/// state reader if a transactional cache miss happens. +/// +/// In practice this will act as a way to access the parent state's cache and other fields, +/// without referencing the whole parent state, so there's no need to adapt state-modifying +/// functions in the case that a transactional state is needed. +#[derive(Debug, MutGetters, Getters, PartialEq, Clone)] +pub struct TransactionalCachedStateReader<'a, T: StateReader, C: ContractClassCache> { + /// The parent state's state_reader + #[get(get = "pub")] + pub(crate) state_reader: Arc, + /// The parent state's cache + #[get(get = "pub")] + pub(crate) cache: &'a StateCache, + + /// The parent state's contract_classes + #[get(get = "pub")] + pub(crate) contract_class_cache: Arc, + pub(crate) contract_class_cache_private: &'a RefCell>, +} - // TODO implement - // self.sierra_programs - // .as_mut() - // .ok_or(StateError::MissingSierraProgramsCache)? - // .insert(compiled_class_hash, sierra_program); - Ok(()) +impl<'a, T: StateReader, C: ContractClassCache> TransactionalCachedStateReader<'a, T, C> { + fn new(state: &'a CachedState) -> Self { + Self { + state_reader: state.state_reader.clone(), + cache: &state.cache, + contract_class_cache: state.contract_class_cache.clone(), + contract_class_cache_private: &state.contract_class_cache_private, + } } +} - fn get_sierra_program( - &mut self, - _class_hash: &ClassHash, - ) -> Result, StateError> { - todo!() +impl<'a, T: StateReader, C: ContractClassCache> StateReader + for TransactionalCachedStateReader<'a, T, C> +{ + /// Returns the class hash for a given contract address. + /// Returns zero as default value if missing + fn get_class_hash_at(&self, contract_address: &Address) -> Result { + self.cache + .get_class_hash(contract_address) + .map(|a| Ok(*a)) + .unwrap_or_else(|| self.state_reader.get_class_hash_at(contract_address)) + } + + /// Returns the nonce for a given contract address. + fn get_nonce_at(&self, contract_address: &Address) -> Result { + if self.cache.get_nonce(contract_address).is_none() { + return self.state_reader.get_nonce_at(contract_address); + } + self.cache + .get_nonce(contract_address) + .ok_or_else(|| StateError::NoneNonce(contract_address.clone())) + .cloned() + } + + /// Returns storage data for a given storage entry. + /// Returns zero as default value if missing + fn get_storage_at(&self, storage_entry: &StorageEntry) -> Result { + self.cache + .get_storage(storage_entry) + .map(|v| Ok(v.clone())) + .unwrap_or_else(|| self.state_reader.get_storage_at(storage_entry)) + } + + // TODO: check if that the proper way to store it (converting hash to address) + /// Returned the compiled class hash for a given class hash. + fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Result { + if self + .cache + .class_hash_to_compiled_class_hash + .get(class_hash) + .is_none() + { + return self.state_reader.get_compiled_class_hash(class_hash); + } + self.cache + .class_hash_to_compiled_class_hash + .get(class_hash) + .ok_or_else(|| StateError::NoneCompiledClass(*class_hash)) + .cloned() + } + + /// Returns the contract class for a given class hash. + fn get_contract_class(&self, class_hash: &ClassHash) -> Result { + // This method can receive both compiled_class_hash & class_hash and return both casm and deprecated contract classes + //, which can be on the cache or on the state_reader, different cases will be described below: + if class_hash == UNINITIALIZED_CLASS_HASH { + return Err(StateError::UninitiaizedClassHash); + } + + // I: FETCHING FROM CACHE + let mut private_cache = self.contract_class_cache_private.borrow_mut(); + if let Some(compiled_class) = private_cache.get(class_hash) { + return Ok(compiled_class.clone()); + } else if let Some(compiled_class) = + self.contract_class_cache().get_contract_class(*class_hash) + { + private_cache.insert(*class_hash, compiled_class.clone()); + return Ok(compiled_class); + } + + // I: CASM CONTRACT CLASS : CLASS_HASH + if let Some(compiled_class_hash) = + self.cache.class_hash_to_compiled_class_hash.get(class_hash) + { + if let Some(casm_class) = private_cache.get(compiled_class_hash) { + return Ok(casm_class.clone()); + } else if let Some(casm_class) = self + .contract_class_cache() + .get_contract_class(*compiled_class_hash) + { + private_cache.insert(*class_hash, casm_class.clone()); + return Ok(casm_class); + } + } + + // II: FETCHING FROM STATE_READER + let contract_class = self.state_reader.get_contract_class(class_hash)?; + private_cache.insert(*class_hash, contract_class.clone()); + + Ok(contract_class) } } @@ -927,7 +979,7 @@ mod tests { /// This test calculate the number of actual storage changes. #[test] - fn count_actual_state_changes_test() { + fn count_actual_storage_changes_test() { let state_reader = InMemoryStateReader::default(); let mut cached_state = CachedState::new( Arc::new(state_reader), @@ -951,15 +1003,14 @@ mod tests { let fee_token_address = Address(123.into()); let sender_address = Address(321.into()); - let expected_changes = StateChangesCount { - n_storage_updates: 3 + 1, // + 1 fee transfer balance update, - n_class_hash_updates: 0, - n_compiled_class_hash_updates: 0, - n_modified_contracts: 2, - }; + let expected_changes = { + let n_storage_updates = 3 + 1; // + 1 fee transfer balance update + let n_modified_contracts = 2; + (n_modified_contracts, n_storage_updates) + }; let changes = cached_state - .count_actual_state_changes(Some((&fee_token_address, &sender_address))) + .count_actual_storage_changes(Some((&fee_token_address, &sender_address))) .unwrap(); assert_eq!(changes, expected_changes); diff --git a/src/state/mod.rs b/src/state/mod.rs index ef6efc242..0c15b6aad 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -3,10 +3,10 @@ use self::{ }; use crate::{ core::errors::state_errors::StateError, + services::api::contract_classes::compiled_class::CompiledClass, transaction::error::TransactionError, utils::{ - get_keys, to_cache_state_storage_mapping, to_state_diff_storage_mapping, Address, - ClassHash, CompiledClassHash, + get_keys, to_cache_state_storage_mapping, to_state_diff_storage_mapping, Address, ClassHash, }, }; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; @@ -106,7 +106,7 @@ impl ExecutionResourcesManager { pub struct StateDiff { pub(crate) address_to_class_hash: HashMap, pub(crate) address_to_nonce: HashMap, - pub(crate) class_hash_to_compiled_class: HashMap, + pub(crate) class_hash_to_compiled_class: HashMap, pub(crate) storage_updates: HashMap>, } @@ -114,7 +114,7 @@ impl StateDiff { pub const fn new( address_to_class_hash: HashMap, address_to_nonce: HashMap, - class_hash_to_compiled_class: HashMap, + class_hash_to_compiled_class: HashMap, storage_updates: HashMap>, ) -> Self { StateDiff { @@ -133,7 +133,7 @@ impl StateDiff { let state_cache = cached_state.cache().to_owned(); let substracted_maps = state_cache.storage_writes; - let storage_updates = to_state_diff_storage_mapping(&substracted_maps); + let storage_updates = to_state_diff_storage_mapping(substracted_maps); let address_to_nonce = state_cache.nonce_writes; let class_hash_to_compiled_class = state_cache.compiled_class_hash_writes; @@ -330,7 +330,7 @@ mod test { Arc::new(PermanentContractClassCache::default()), ); - let diff = StateDiff::from_cached_state(cached_state_original.clone_for_testing()).unwrap(); + let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); let cached_state = diff .to_cached_state::<_, PermanentContractClassCache>( diff --git a/src/state/state_api.rs b/src/state/state_api.rs index 4abe12354..ff468671a 100644 --- a/src/state/state_api.rs +++ b/src/state/state_api.rs @@ -5,7 +5,6 @@ use crate::{ state::StateDiff, utils::{Address, ClassHash, CompiledClassHash}, }; -use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; pub trait StateReader { @@ -26,14 +25,6 @@ pub trait StateReader { ) -> Result; } -#[derive(Debug, Clone, Eq, PartialEq)] -pub struct StateChangesCount { - pub n_storage_updates: usize, - pub n_class_hash_updates: usize, - pub n_compiled_class_hash_updates: usize, - pub n_modified_contracts: usize, -} - pub trait State { fn set_contract_class( &mut self, @@ -62,20 +53,13 @@ pub trait State { class_hash: &Felt252, compiled_class_hash: &Felt252, ) -> Result<(), StateError>; - - fn set_sierra_program( - &mut self, - compiled_class_hash: &Felt252, - sierra_program: Vec, - ) -> Result<(), StateError>; - fn apply_state_update(&mut self, sate_updates: &StateDiff) -> Result<(), StateError>; - /// Counts the amount of state changes - fn count_actual_state_changes( + /// Counts the amount of modified contracts and the updates to the storage + fn count_actual_storage_changes( &mut self, fee_token_and_sender_address: Option<(&Address, &Address)>, - ) -> Result; + ) -> Result<(usize, usize), StateError>; /// Returns the class hash of the contract class at the given address. /// Returns zero by default if the value is not present @@ -91,9 +75,4 @@ pub trait State { fn get_compiled_class_hash(&mut self, class_hash: &ClassHash) -> Result; fn get_contract_class(&mut self, class_hash: &ClassHash) -> Result; - - fn get_sierra_program( - &mut self, - class_hash: &ClassHash, - ) -> Result, StateError>; } diff --git a/src/state/state_cache.rs b/src/state/state_cache.rs index 23a77400c..6238c258d 100644 --- a/src/state/state_cache.rs +++ b/src/state/state_cache.rs @@ -1,5 +1,6 @@ use crate::{ core::errors::state_errors::StateError, + services::api::contract_classes::compiled_class::CompiledClass, utils::{Address, ClassHash, CompiledClassHash}, }; use cairo_vm::felt::Felt252; @@ -17,7 +18,7 @@ pub struct StateCache { #[get_mut = "pub"] pub(crate) class_hash_initial_values: HashMap, #[get_mut = "pub"] - pub(crate) compiled_class_hash_initial_values: HashMap, + pub(crate) compiled_class_hash_initial_values: HashMap, #[getset(get = "pub", get_mut = "pub")] pub(crate) nonce_initial_values: HashMap, #[getset(get = "pub", get_mut = "pub")] @@ -27,7 +28,7 @@ pub struct StateCache { #[get_mut = "pub"] pub(crate) class_hash_writes: HashMap, #[get_mut = "pub"] - pub(crate) compiled_class_hash_writes: HashMap, + pub(crate) compiled_class_hash_writes: HashMap, #[get_mut = "pub"] pub(crate) nonce_writes: HashMap, #[getset(get = "pub", get_mut = "pub")] @@ -42,11 +43,11 @@ impl StateCache { /// Create a new StateCache with given initial and written values for testing pub const fn new( class_hash_initial_values: HashMap, - compiled_class_hash_initial_values: HashMap, + compiled_class_hash_initial_values: HashMap, nonce_initial_values: HashMap, storage_initial_values: HashMap, class_hash_writes: HashMap, - compiled_class_hash_writes: HashMap, + compiled_class_hash_writes: HashMap, nonce_writes: HashMap, storage_writes: HashMap, class_hash_to_compiled_class_hash: HashMap, @@ -83,11 +84,11 @@ impl StateCache { #[allow(clippy::too_many_arguments)] pub const fn new_for_testing( class_hash_initial_values: HashMap, - compiled_class_hash_initial_values: HashMap, + compiled_class_hash_initial_values: HashMap, nonce_initial_values: HashMap, storage_initial_values: HashMap, class_hash_writes: HashMap, - compiled_class_hash_writes: HashMap, + compiled_class_hash_writes: HashMap, nonce_writes: HashMap, storage_writes: HashMap<(Address, [u8; 32]), Felt252>, class_hash_to_compiled_class_hash: HashMap, @@ -115,10 +116,7 @@ impl StateCache { /// Get the compiled hash for a given class hash #[allow(dead_code)] - pub(crate) fn get_compiled_class_hash( - &self, - class_hash: &ClassHash, - ) -> Option<&CompiledClassHash> { + pub(crate) fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Option<&CompiledClass> { if self.compiled_class_hash_writes.contains_key(class_hash) { return self.compiled_class_hash_writes.get(class_hash); } @@ -145,7 +143,7 @@ impl StateCache { pub(crate) fn update_writes( &mut self, address_to_class_hash: &HashMap, - class_hash_to_compiled_class_hash: &HashMap, + class_hash_to_compiled_class_hash: &HashMap, address_to_nonce: &HashMap, storage_updates: &HashMap, ) { @@ -160,7 +158,7 @@ impl StateCache { pub fn set_initial_values( &mut self, address_to_class_hash: &HashMap, - class_hash_to_compiled_class: &HashMap, + class_hash_to_compiled_class: &HashMap, address_to_nonce: &HashMap, storage_updates: &HashMap, ) -> Result<(), StateError> { @@ -203,7 +201,8 @@ impl StateCache { } for (k, v) in self.compiled_class_hash_writes.iter() { - self.compiled_class_hash_initial_values.insert(*k, *v); + self.compiled_class_hash_initial_values + .insert(*k, v.clone()); } for (k, v) in self.storage_writes.iter() { @@ -220,11 +219,9 @@ impl StateCache { /// Unit tests for StateCache #[cfg(test)] mod tests { + use std::sync::Arc; - use crate::{ - core::contract_address::compute_deprecated_class_hash, - services::api::contract_classes::deprecated_contract_class::ContractClass, - }; + use crate::services::api::contract_classes::deprecated_contract_class::ContractClass; use super::*; @@ -235,9 +232,7 @@ mod tests { let contract_class = ContractClass::from_path("starknet_programs/raw_contract_classes/class_with_abi.json") .unwrap(); - let compiled_class = compute_deprecated_class_hash(&contract_class) - .unwrap() - .to_be_bytes(); + let compiled_class = CompiledClass::Deprecated(Arc::new(contract_class)); let class_hash_to_compiled_class_hash = HashMap::from([([8; 32], compiled_class)]); let address_to_nonce = HashMap::from([(Address(9.into()), 12.into())]); let storage_updates = HashMap::from([((Address(4.into()), [1; 32]), 18.into())]); diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index 42925bf16..5deb7b2ee 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -58,10 +58,9 @@ use crate::services::api::contract_classes::deprecated_contract_class::EntryPoin use crate::state::contract_class_cache::ContractClassCache; use num_traits::{One, ToPrimitive, Zero}; -pub(crate) const STEP: u128 = 100; -pub(crate) const SYSCALL_BASE: u128 = 100 * STEP; -pub(crate) const KECCAK_ROUND_COST: u128 = 180000; - +const STEP: u128 = 100; +const SYSCALL_BASE: u128 = 100 * STEP; +const KECCAK_ROUND_COST: u128 = 180000; lazy_static! { /// Felt->syscall map that was extracted from new_syscalls.json (Cairo 1.0 syscalls) static ref SELECTOR_TO_SYSCALL: HashMap = { @@ -93,7 +92,7 @@ lazy_static! { // Taken from starkware/starknet/constants.py in cairo-lang // See further documentation on cairo_programs/constants.cairo /// Maps syscall name to gas costs - pub(crate) static ref SYSCALL_GAS_COST: HashMap<&'static str, u128> = { + static ref SYSCALL_GAS_COST: HashMap<&'static str, u128> = { let mut map = HashMap::new(); map.insert("initial", 100_000_000 * STEP); @@ -135,7 +134,6 @@ pub struct BusinessLogicSyscallHandler<'a, S: StateReader, C: ContractClassCache pub(crate) support_reverted: bool, pub(crate) entry_point_selector: Felt252, pub(crate) selector_to_syscall: &'a HashMap, - pub(crate) execution_info_ptr: Option, } // TODO: execution entry point may no be a parameter field, but there is no way to generate a default for now @@ -174,7 +172,6 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, support_reverted, entry_point_selector, selector_to_syscall: &SELECTOR_TO_SYSCALL, - execution_info_ptr: None, } } @@ -232,7 +229,6 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, support_reverted: false, entry_point_selector, selector_to_syscall: &SELECTOR_TO_SYSCALL, - execution_info_ptr: None, } } @@ -316,7 +312,6 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(_) => todo!(), } } @@ -325,7 +320,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, contract_address: &Address, class_hash_bytes: ClassHash, constructor_calldata: Vec, - remaining_gas: u128, + remainig_gas: u128, ) -> Result { let compiled_class = if let Ok(compiled_class) = self .starknet_storage_state @@ -364,7 +359,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, EntryPointType::Constructor, Some(CallType::Call), None, - remaining_gas, + remainig_gas, ); let ExecutionResult { @@ -539,10 +534,10 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, /// them as accessed. pub(crate) fn validate_read_only_segments( &self, - vm: &mut VirtualMachine, + runner: &mut VirtualMachine, ) -> Result<(), TransactionError> { for (segment_ptr, segment_size) in self.read_only_segments.clone() { - let used_size = vm + let used_size = runner .get_segment_used_size(segment_ptr.segment_index as usize) .ok_or(TransactionError::InvalidSegmentSize)?; @@ -554,7 +549,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, if seg_size != used_size.into() { return Err(TransactionError::OutOfBound); } - vm.mark_address_range_as_accessed(segment_ptr, used_size)?; + runner.mark_address_range_as_accessed(segment_ptr, used_size)?; } Ok(()) } @@ -631,69 +626,63 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, }) } - // Returns the pointer to the segment with the execution info if it was already written. - // If it wasn't, it writes the execution info into memory and returns its start address. - fn get_or_allocate_execution_info( - &mut self, - vm: &mut VirtualMachine, - ) -> Result { - if let Some(ptr) = self.execution_info_ptr { - return Ok(ptr); - } - - // Allocate block_info - let block_info = &self.block_context.block_info; - let block_info_data = vec![ - MaybeRelocatable::from(Felt252::from(block_info.block_number)), - MaybeRelocatable::from(Felt252::from(block_info.block_timestamp)), - MaybeRelocatable::from(&block_info.sequencer_address.0), - ]; - let block_info_ptr = self.allocate_segment(vm, block_info_data)?; - - // Allocate signature - let signature: Vec = self - .tx_execution_context - .signature - .iter() - .map(MaybeRelocatable::from) - .collect(); - let signature_start_ptr = self.allocate_segment(vm, signature)?; - let signature_end_ptr = (signature_start_ptr + self.tx_execution_context.signature.len())?; - - // Allocate tx info - let tx_info = &self.tx_execution_context; - let tx_info_data = vec![ - MaybeRelocatable::from(&tx_info.version), - MaybeRelocatable::from(&tx_info.account_contract_address.0), - MaybeRelocatable::from(Felt252::from(tx_info.max_fee)), - signature_start_ptr.into(), - signature_end_ptr.into(), - MaybeRelocatable::from(&tx_info.transaction_hash), - MaybeRelocatable::from(&self.block_context.starknet_os_config.chain_id), - MaybeRelocatable::from(&tx_info.nonce), - ]; - let tx_info_ptr = self.allocate_segment(vm, tx_info_data)?; - - // Allocate execution_info - let execution_info = vec![ - block_info_ptr.into(), - tx_info_ptr.into(), - MaybeRelocatable::from(&self.caller_address.0), - MaybeRelocatable::from(&self.contract_address.0), - MaybeRelocatable::from(&self.entry_point_selector), - ]; - let execution_info_ptr = self.allocate_segment(vm, execution_info)?; - - self.execution_info_ptr = Some(execution_info_ptr); - Ok(execution_info_ptr) - } - fn get_execution_info( - &mut self, + &self, vm: &mut VirtualMachine, remaining_gas: u128, ) -> Result { - let exec_info_ptr = self.get_or_allocate_execution_info(vm)?; + let tx_info = &self.tx_execution_context; + let block_info = &self.block_context.block_info; + + let mut res_segment = vm.add_memory_segment(); + + let signature_start = res_segment; + for s in tx_info.signature.iter() { + vm.insert_value(res_segment, s)?; + res_segment = (res_segment + 1)?; + } + let signature_end = res_segment; + + let tx_info_ptr = res_segment; + vm.insert_value::(res_segment, tx_info.version.clone())?; + res_segment = (res_segment + 1)?; + vm.insert_value(res_segment, tx_info.account_contract_address.0.clone())?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, tx_info.max_fee.into())?; + res_segment = (res_segment + 1)?; + vm.insert_value(res_segment, signature_start)?; + res_segment = (res_segment + 1)?; + vm.insert_value(res_segment, signature_end)?; + res_segment = (res_segment + 1)?; + vm.insert_value(res_segment, tx_info.transaction_hash.clone())?; + res_segment = (res_segment + 1)?; + vm.insert_value::( + res_segment, + self.block_context.starknet_os_config.chain_id.clone(), + )?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, tx_info.nonce.clone())?; + res_segment = (res_segment + 1)?; + + let block_info_ptr = res_segment; + vm.insert_value::(res_segment, block_info.block_number.into())?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, block_info.block_timestamp.into())?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, block_info.sequencer_address.0.clone())?; + res_segment = (res_segment + 1)?; + + let exec_info_ptr = res_segment; + vm.insert_value(res_segment, block_info_ptr)?; + res_segment = (res_segment + 1)?; + vm.insert_value(res_segment, tx_info_ptr)?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, self.caller_address.0.clone())?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, self.contract_address.0.clone())?; + res_segment = (res_segment + 1)?; + vm.insert_value::(res_segment, self.entry_point_selector.clone())?; + Ok(SyscallResponse { gas: remaining_gas, body: Some(ResponseBody::GetExecutionInfo { exec_info_ptr }), @@ -887,7 +876,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, fn send_message_to_l1( &mut self, - vm: &VirtualMachine, + vm: &mut VirtualMachine, request: SendMessageToL1Request, remaining_gas: u128, ) -> Result { diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 56817de19..9f0b66e32 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -193,7 +193,6 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(_) => todo!(), } } @@ -597,7 +596,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S pub(crate) fn storage_write( &mut self, - vm: &VirtualMachine, + vm: &mut VirtualMachine, syscall_ptr: Relocatable, ) -> Result<(), SyscallHandlerError> { let request = @@ -888,7 +887,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S pub(crate) fn replace_class( &mut self, - vm: &VirtualMachine, + vm: &mut VirtualMachine, syscall_ptr: Relocatable, ) -> Result<(), SyscallHandlerError> { let request = match self.read_and_validate_syscall_request("replace_class", vm, syscall_ptr) diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index 997f684df..eabf9bdfa 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -1214,7 +1214,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional().unwrap(); + let mut transactional = state.create_transactional(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 48a332316..065e31652 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -4,8 +4,6 @@ pub mod deprecated_syscall_handler; pub mod deprecated_syscall_request; pub mod deprecated_syscall_response; pub mod hint_code; -#[cfg(feature = "cairo-native")] -pub mod native_syscall_handler; pub mod other_syscalls; pub mod syscall_handler; pub mod syscall_handler_errors; diff --git a/src/syscalls/native_syscall_handler.rs b/src/syscalls/native_syscall_handler.rs deleted file mode 100644 index 00386eaea..000000000 --- a/src/syscalls/native_syscall_handler.rs +++ /dev/null @@ -1,576 +0,0 @@ -use crate::ContractClassCache; -use cairo_native::starknet::{ - BlockInfo, ExecutionInfo, StarkNetSyscallHandler, SyscallResult, TxInfo, U256, -}; -use cairo_vm::felt::Felt252; -use num_traits::Zero; - -use crate::definitions::constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR; -use crate::execution::CallResult; -use crate::hash_utils::calculate_contract_address; -use crate::services::api::contract_class_errors::ContractClassError; -use crate::services::api::contract_classes::compiled_class::CompiledClass; -use crate::state::state_api::State; -use crate::utils::felt_to_hash; -use crate::utils::ClassHash; -use crate::{ - core::errors::state_errors::StateError, - definitions::block_context::BlockContext, - execution::{ - execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, - CallInfo, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, - }, - state::{ - contract_storage_state::ContractStorageState, state_api::StateReader, - ExecutionResourcesManager, - }, - syscalls::business_logic_syscall_handler::{SYSCALL_BASE, SYSCALL_GAS_COST}, - utils::Address, - EntryPointType, -}; - -#[derive(Debug)] -pub struct NativeSyscallHandler<'a, S, C> -where - S: StateReader, - C: ContractClassCache, -{ - pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, - pub(crate) contract_address: Address, - pub(crate) caller_address: Address, - pub(crate) entry_point_selector: Felt252, - pub(crate) events: Vec, - pub(crate) l2_to_l1_messages: Vec, - pub(crate) tx_execution_context: TransactionExecutionContext, - pub(crate) block_context: BlockContext, - pub(crate) internal_calls: Vec, - pub(crate) resources_manager: ExecutionResourcesManager, -} - -impl<'a, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, S, C> { - /// Generic code that needs to be run on all syscalls. - fn handle_syscall_request(&mut self, gas: &mut u128, syscall_name: &str) -> SyscallResult<()> { - let required_gas = SYSCALL_GAS_COST - .get(syscall_name) - .map(|&x| x.saturating_sub(SYSCALL_BASE)) - .unwrap_or(0); - - if *gas < required_gas { - let out_of_gas_felt = Felt252::from_bytes_be("Out of gas".as_bytes()); - println!("out of gas!: {:?} < {:?}", *gas, required_gas); // TODO: remove once all other prints are removed - return Err(vec![out_of_gas_felt.clone()]); - } - - *gas = gas.saturating_sub(required_gas); - - self.resources_manager - .increment_syscall_counter(syscall_name, 1); - - Ok(()) - } -} - -impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler - for NativeSyscallHandler<'a, S, C> -{ - fn get_block_hash( - &mut self, - block_number: u64, - gas: &mut u128, - ) -> SyscallResult { - println!("Called `get_block_hash({block_number})` from MLIR."); - - self.handle_syscall_request(gas, "get_block_hash")?; - - Ok(Felt252::from_bytes_be(b"get_block_hash ok")) - } - - fn get_execution_info( - &mut self, - gas: &mut u128, - ) -> SyscallResult { - println!("Called `get_execution_info()` from MLIR."); - - self.handle_syscall_request(gas, "get_execution_info")?; - - Ok(ExecutionInfo { - block_info: BlockInfo { - block_number: self.block_context.block_info.block_number, - block_timestamp: self.block_context.block_info.block_timestamp, - sequencer_address: self.block_context.block_info.sequencer_address.0.clone(), - }, - tx_info: TxInfo { - version: self.tx_execution_context.version.clone(), - account_contract_address: self - .tx_execution_context - .account_contract_address - .0 - .clone(), - max_fee: self.tx_execution_context.max_fee, - signature: self.tx_execution_context.signature.clone(), - transaction_hash: self.tx_execution_context.transaction_hash.clone(), - chain_id: self.block_context.starknet_os_config.chain_id.clone(), - nonce: self.tx_execution_context.nonce.clone(), - }, - caller_address: self.caller_address.0.clone(), - contract_address: self.contract_address.0.clone(), - entry_point_selector: self.entry_point_selector.clone(), - }) - } - - fn deploy( - &mut self, - class_hash: cairo_vm::felt::Felt252, - contract_address_salt: cairo_vm::felt::Felt252, - calldata: &[cairo_vm::felt::Felt252], - deploy_from_zero: bool, - gas: &mut u128, - ) -> SyscallResult<(cairo_vm::felt::Felt252, Vec)> { - self.handle_syscall_request(gas, "deploy")?; - - let deployer_address = if deploy_from_zero { - Address::default() - } else { - self.contract_address.clone() - }; - - let contract_address = Address( - calculate_contract_address( - &contract_address_salt, - &class_hash, - calldata, - deployer_address, - ) - .map_err(|_| { - vec![Felt252::from_bytes_be( - b"FAILED_TO_CALCULATE_CONTRACT_ADDRESS", - )] - })?, - ); - // Initialize the contract. - let class_hash_bytes: ClassHash = felt_to_hash(&class_hash); - - self.starknet_storage_state - .state - .deploy_contract(contract_address.clone(), class_hash_bytes) - .map_err(|_| vec![Felt252::from_bytes_be(b"CONTRACT_ADDRESS_UNAVAILABLE")])?; - - let result = self - .execute_constructor_entry_point( - &contract_address, - class_hash_bytes, - calldata.to_vec(), - *gas, - ) - .map_err(|_| vec![Felt252::from_bytes_be(b"CONSTRUCTOR_ENTRYPOINT_FAILURE")])?; - - *gas = gas.saturating_sub(result.gas_consumed); - - Ok(( - contract_address.0, - result - .retdata - .iter() - .map(|mb| mb.get_int_ref().cloned().unwrap_or_default()) - .collect(), - )) - } - - fn replace_class( - &mut self, - class_hash: cairo_vm::felt::Felt252, - gas: &mut u128, - ) -> SyscallResult<()> { - println!("Called `replace_class({class_hash})` from MLIR."); - - self.handle_syscall_request(gas, "replace_class")?; - Ok(()) - } - - fn library_call( - &mut self, - class_hash: cairo_vm::felt::Felt252, - function_selector: cairo_vm::felt::Felt252, - calldata: &[cairo_vm::felt::Felt252], - gas: &mut u128, - ) -> SyscallResult> { - println!( - "Called `library_call({class_hash}, {function_selector}, {calldata:?})` from MLIR." - ); - - self.handle_syscall_request(gas, "library_call")?; - - Ok(calldata.iter().map(|x| x * &Felt252::new(3)).collect()) - } - - fn call_contract( - &mut self, - address: cairo_vm::felt::Felt252, - entrypoint_selector: cairo_vm::felt::Felt252, - calldata: &[cairo_vm::felt::Felt252], - gas: &mut u128, - ) -> SyscallResult> { - println!( - "Called `call_contract({address}, {entrypoint_selector}, {calldata:?})` from MLIR." - ); - - self.handle_syscall_request(gas, "call_contract")?; - - let address = Address(address); - let exec_entry_point = ExecutionEntryPoint::new( - address, - calldata.to_vec(), - entrypoint_selector, - self.caller_address.clone(), - EntryPointType::External, - Some(CallType::Call), - None, - *gas, - ); - - let ExecutionResult { call_info, .. } = exec_entry_point - .execute( - self.starknet_storage_state.state, - // TODO: This fields dont make much sense in the Cairo Native context, - // they are only dummy values for the `execute` method. - &self.block_context, - &mut self.resources_manager, - &mut self.tx_execution_context, - false, - self.block_context.invoke_tx_max_n_steps, - ) - .unwrap(); - - let call_info = call_info.unwrap(); - - *gas = gas.saturating_sub(call_info.gas_consumed); - - // update syscall handler information - self.starknet_storage_state - .read_values - .extend(call_info.storage_read_values.clone()); - self.starknet_storage_state - .accessed_keys - .extend(call_info.accessed_storage_keys.clone()); - - let retdata = call_info.retdata.clone(); - self.internal_calls.push(call_info); - - Ok(retdata) - } - - fn storage_read( - &mut self, - address_domain: u32, - address: cairo_vm::felt::Felt252, - gas: &mut u128, - ) -> SyscallResult { - println!("Called `storage_read({address_domain}, {address})` from MLIR."); - - self.handle_syscall_request(gas, "storage_read")?; - - let value = match self.starknet_storage_state.read(&address.to_be_bytes()) { - Ok(value) => Ok(value), - Err(_e @ StateError::Io(_)) => todo!(), - Err(_) => Ok(Felt252::zero()), - }; - - println!(" = {value:?}` from MLIR."); - - value - } - - fn storage_write( - &mut self, - address_domain: u32, - address: cairo_vm::felt::Felt252, - value: cairo_vm::felt::Felt252, - gas: &mut u128, - ) -> SyscallResult<()> { - println!("Called `storage_write({address_domain}, {address}, {value})` from MLIR."); - - self.handle_syscall_request(gas, "storage_write")?; - - self.starknet_storage_state - .write(&address.to_be_bytes(), value); - Ok(()) - } - - fn emit_event( - &mut self, - keys: &[cairo_vm::felt::Felt252], - data: &[cairo_vm::felt::Felt252], - gas: &mut u128, - ) -> SyscallResult<()> { - let order = self.tx_execution_context.n_emitted_events; - println!("Called `emit_event(KEYS: {keys:?}, DATA: {data:?})` from MLIR."); - - self.handle_syscall_request(gas, "emit_event")?; - - self.events - .push(OrderedEvent::new(order, keys.to_vec(), data.to_vec())); - self.tx_execution_context.n_emitted_events += 1; - Ok(()) - } - - fn send_message_to_l1( - &mut self, - to_address: cairo_vm::felt::Felt252, - payload: &[cairo_vm::felt::Felt252], - gas: &mut u128, - ) -> SyscallResult<()> { - println!("Called `send_message_to_l1({to_address}, {payload:?})` from MLIR."); - - self.handle_syscall_request(gas, "send_message_to_l1")?; - - let addr = Address(to_address); - self.l2_to_l1_messages.push(OrderedL2ToL1Message::new( - self.tx_execution_context.n_sent_messages, - addr, - payload.to_vec(), - )); - - // Update messages count. - self.tx_execution_context.n_sent_messages += 1; - - Ok(()) - } - - fn keccak( - &mut self, - input: &[u64], - gas: &mut u128, - ) -> SyscallResult { - println!("Called `keccak({input:?})` from MLIR."); - - self.handle_syscall_request(gas, "keccak")?; - - Ok(U256(Felt252::from(1234567890).to_le_bytes())) - } - - fn secp256k1_add( - &mut self, - _p0: cairo_native::starknet::Secp256k1Point, - _p1: cairo_native::starknet::Secp256k1Point, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256k1_get_point_from_x( - &self, - _x: cairo_native::starknet::U256, - _y_parity: bool, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256k1_get_xy( - &self, - _p: cairo_native::starknet::Secp256k1Point, - _gas: &mut u128, - ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { - todo!() - } - - fn secp256k1_mul( - &self, - _p: cairo_native::starknet::Secp256k1Point, - _m: cairo_native::starknet::U256, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256k1_new( - &self, - _x: cairo_native::starknet::U256, - _y: cairo_native::starknet::U256, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256r1_add( - &self, - _p0: cairo_native::starknet::Secp256k1Point, - _p1: cairo_native::starknet::Secp256k1Point, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256r1_get_point_from_x( - &self, - _x: cairo_native::starknet::U256, - _y_parity: bool, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256r1_get_xy( - &self, - _p: cairo_native::starknet::Secp256k1Point, - _gas: &mut u128, - ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { - todo!() - } - - fn secp256r1_mul( - &self, - _p: cairo_native::starknet::Secp256k1Point, - _m: cairo_native::starknet::U256, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn secp256r1_new( - &mut self, - _x: cairo_native::starknet::U256, - _y: cairo_native::starknet::U256, - _gas: &mut u128, - ) -> SyscallResult> { - todo!() - } - - fn pop_log(&mut self) { - todo!() - } - - fn set_account_contract_address(&mut self, contract_address: cairo_vm::felt::Felt252) { - self.tx_execution_context.account_contract_address = Address(contract_address); - } - - fn set_block_number(&mut self, block_number: u64) { - self.block_context.block_info.block_number = block_number; - } - - fn set_block_timestamp(&mut self, block_timestamp: u64) { - self.block_context.block_info.block_timestamp = block_timestamp; - } - - fn set_caller_address(&mut self, address: cairo_vm::felt::Felt252) { - self.caller_address = Address(address); - } - - fn set_chain_id(&mut self, chain_id: cairo_vm::felt::Felt252) { - self.block_context.starknet_os_config.chain_id = chain_id; - } - - fn set_contract_address(&mut self, address: cairo_vm::felt::Felt252) { - self.contract_address = Address(address); - } - - fn set_max_fee(&mut self, max_fee: u128) { - self.tx_execution_context.max_fee = max_fee; - } - - fn set_nonce(&mut self, nonce: cairo_vm::felt::Felt252) { - self.tx_execution_context.nonce = nonce; - } - - fn set_sequencer_address(&mut self, _address: cairo_vm::felt::Felt252) { - todo!() - } - - fn set_signature(&mut self, signature: &[cairo_vm::felt::Felt252]) { - self.tx_execution_context.signature = signature.to_vec(); - } - - fn set_transaction_hash(&mut self, transaction_hash: cairo_vm::felt::Felt252) { - self.tx_execution_context.transaction_hash = transaction_hash; - } - - fn set_version(&mut self, version: cairo_vm::felt::Felt252) { - self.tx_execution_context.version = version; - } -} - -impl<'a, S, C> NativeSyscallHandler<'a, S, C> -where - S: StateReader, - C: ContractClassCache, -{ - fn execute_constructor_entry_point( - &mut self, - contract_address: &Address, - class_hash_bytes: ClassHash, - constructor_calldata: Vec, - remaining_gas: u128, - ) -> Result { - let compiled_class = if let Ok(compiled_class) = self - .starknet_storage_state - .state - .get_contract_class(&class_hash_bytes) - { - compiled_class - } else { - return Ok(CallResult { - gas_consumed: 0, - is_success: false, - retdata: vec![Felt252::from_bytes_be(b"CLASS_HASH_NOT_FOUND").into()], - }); - }; - - if self.constructor_entry_points_empty(compiled_class)? { - if !constructor_calldata.is_empty() { - return Err(StateError::ConstructorCalldataEmpty); - } - - let call_info = CallInfo::empty_constructor_call( - contract_address.clone(), - self.contract_address.clone(), - Some(class_hash_bytes), - ); - self.internal_calls.push(call_info.clone()); - - return Ok(call_info.result()); - } - - let call = ExecutionEntryPoint::new( - contract_address.clone(), - constructor_calldata, - CONSTRUCTOR_ENTRY_POINT_SELECTOR.clone(), - self.contract_address.clone(), - EntryPointType::Constructor, - Some(CallType::Call), - None, - remaining_gas, - ); - - let ExecutionResult { call_info, .. } = call - .execute( - self.starknet_storage_state.state, - &self.block_context, - &mut self.resources_manager, - &mut self.tx_execution_context, - false, - u64::MAX, - ) - .map_err(|_| StateError::ExecutionEntryPoint)?; - - let call_info = call_info.ok_or(StateError::CustomError("Execution error".to_string()))?; - - self.internal_calls.push(call_info.clone()); - - Ok(call_info.result()) - } - - fn constructor_entry_points_empty( - &self, - contract_class: CompiledClass, - ) -> Result { - match contract_class { - CompiledClass::Deprecated(class) => Ok(class - .entry_points_by_type - .get(&EntryPointType::Constructor) - .ok_or(ContractClassError::NoneEntryPointType)? - .is_empty()), - CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - } - } -} diff --git a/src/syscalls/syscall_handler.rs b/src/syscalls/syscall_handler.rs index 679098a02..b62fb9b64 100644 --- a/src/syscalls/syscall_handler.rs +++ b/src/syscalls/syscall_handler.rs @@ -146,7 +146,7 @@ impl<'a, S: StateReader, C: ContractClassCache> HintProcessorPostRun // TODO: These four functions were copied from cairo-rs in // hint_processor/cairo-1-hint-processor/hint_processor_utils.rs as these functions are private. // They will became public soon and then we have to remove this ones and use the ones in cairo-rs instead -fn as_relocatable(vm: &VirtualMachine, value: &ResOperand) -> Result { +fn as_relocatable(vm: &mut VirtualMachine, value: &ResOperand) -> Result { let (base, offset) = extract_buffer(value)?; get_ptr(vm, base, &offset).map_err(HintError::from) } diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index bf173065c..364628bcd 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -32,8 +32,6 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::Zero; - -use std::fmt::Debug; use std::sync::Arc; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -148,44 +146,6 @@ impl Declare { Ok(internal_declare) } - #[allow(clippy::too_many_arguments)] - pub fn new_with_tx_and_class_hash( - contract_class: ContractClass, - sender_address: Address, - max_fee: u128, - version: Felt252, - signature: Vec, - nonce: Felt252, - hash_value: Felt252, - class_hash: ClassHash, - ) -> Result { - let validate_entry_point_selector = VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(); - - let internal_declare = Declare { - class_hash, - sender_address, - validate_entry_point_selector, - version, - max_fee, - signature, - nonce, - hash_value, - contract_class, - skip_execute: false, - skip_validate: false, - skip_fee_transfer: false, - }; - - verify_version( - &internal_declare.version, - internal_declare.max_fee, - &internal_declare.nonce, - &internal_declare.signature, - )?; - - Ok(internal_declare) - } - pub fn get_calldata(&self) -> Vec { let bytes = Felt252::from_bytes_be(&self.class_hash); Vec::from([bytes]) @@ -207,7 +167,7 @@ impl Declare { } else { self.run_validate_entrypoint(state, &mut resources_manager, block_context)? }; - let changes = state.count_actual_state_changes(Some(( + let changes = state.count_actual_storage_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.sender_address, )))?; @@ -306,14 +266,6 @@ impl Declare { /// Calculates actual fee used by the transaction using the execution /// info returned by apply(), then updates the transaction execution info with the data of the fee. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( - tx_type = ?TransactionType::Declare, - self.version = ?self.version, - self.class_hash = ?self.class_hash, - self.hash_value = ?self.hash_value, - self.sender_address = ?self.sender_address, - self.nonce = ?self.nonce, - ))] pub fn execute( &self, state: &mut CachedState, @@ -343,7 +295,7 @@ impl Declare { Ok(tx_exec_info) } - pub fn create_for_simulation( + pub(crate) fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -474,10 +426,10 @@ mod tests { entry_point_type: Some(EntryPointType::External), calldata, class_hash: Some(expected_class_hash), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 12, ..Default::default() - }), + }, ..Default::default() }); @@ -936,104 +888,4 @@ mod tests { Err(TransactionError::FeeTransferError(_)) ); } - - #[test] - fn declare_v1_with_validation_fee_higher_than_no_validation() { - // accounts contract class must be stored before running declaration of fibonacci - let contract_class = ContractClass::from_path("starknet_programs/Account.json").unwrap(); - - // Instantiate CachedState - let contract_class_cache = PermanentContractClassCache::default(); - - // ------------ contract data -------------------- - let hash = compute_deprecated_class_hash(&contract_class).unwrap(); - let class_hash = hash.to_be_bytes(); - - contract_class_cache.set_contract_class( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - ); - - // store sender_address - let sender_address = Address(1.into()); - // this is not conceptually correct as the sender address would be an - // Account contract (not the contract that we are currently declaring) - // but for testing reasons its ok - - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(sender_address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(sender_address.clone(), Felt252::new(1)); - - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - // Insert pubkey storage var to pass validation - let storage_entry = &( - sender_address, - felt_str!( - "1672321442399497129215646424919402195095307045612040218489019266998007191460" - ) - .to_be_bytes(), - ); - state.set_storage_at( - storage_entry, - felt_str!( - "1735102664668487605176656616876767369909409133946409161569774794110049207117" - ), - ); - - //* --------------------------------------- - //* Test declare with previous data - //* --------------------------------------- - - let fib_contract_class = - ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - - let chain_id = StarknetChainId::TestNet.to_felt(); - - // declare tx - // Signature & tx hash values are hand-picked for account validations to pass - let mut declare = Declare::new( - fib_contract_class, - chain_id, - Address(Felt252::one()), - 60000, - 1.into(), - vec![ - felt_str!( - "3086480810278599376317923499561306189851900463386393948998357832163236918254" - ), - felt_str!( - "598673427589502599949712887611119751108407514580626464031881322743364689811" - ), - ], - Felt252::one(), - ) - .unwrap(); - declare.skip_fee_transfer = true; - declare.hash_value = felt_str!("2718"); - - let simulate_declare = declare - .clone() - .create_for_simulation(true, false, true, false); - - // --------------------- - // Comparison - // --------------------- - let mut state_copy = state.clone_for_testing(); - let mut bock_context = BlockContext::default(); - bock_context.starknet_os_config.gas_price = 12; - assert!( - declare - .execute(&mut state, &bock_context) - .unwrap() - .actual_fee - > simulate_declare - .execute(&mut state_copy, &bock_context, 0) - .unwrap() - .actual_fee, - ); - } } diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index cbcca05cb..a342b9d25 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -28,7 +28,6 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; use cairo_vm::felt::Felt252; use num_traits::Zero; -use std::fmt::Debug; use std::sync::Arc; /// Represents a declare transaction in the starknet network. @@ -43,7 +42,7 @@ pub struct DeclareV2 { pub signature: Vec, pub nonce: Felt252, pub compiled_class_hash: Felt252, - pub sierra_contract_class: Option, + pub sierra_contract_class: SierraContractClass, pub sierra_class_hash: Felt252, pub hash_value: Felt252, pub casm_class: Option, @@ -90,7 +89,7 @@ impl DeclareV2 { )?; Self::new_with_sierra_class_hash_and_tx_hash( - Some(sierra_contract_class.clone()), + sierra_contract_class, sierra_class_hash, casm_contract_class, compiled_class_hash, @@ -119,7 +118,7 @@ impl DeclareV2 { /// may not hold. #[allow(clippy::too_many_arguments)] pub fn new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class: Option, + sierra_contract_class: &SierraContractClass, sierra_class_hash: Felt252, casm_contract_class: Option, compiled_class_hash: Felt252, @@ -185,7 +184,7 @@ impl DeclareV2 { let sierra_class_hash = compute_sierra_class_hash(sierra_contract_class)?; Self::new_with_sierra_class_hash_and_tx_hash( - Some(sierra_contract_class.clone()), + sierra_contract_class, sierra_class_hash, casm_contract_class, compiled_class_hash, @@ -212,7 +211,7 @@ impl DeclareV2 { /// - nonce: The nonce of the contract. #[allow(clippy::too_many_arguments)] pub fn new_with_sierra_class_hash( - sierra_contract_class: Option, + sierra_contract_class: &SierraContractClass, sierra_class_hash: Felt252, casm_contract_class: Option, compiled_class_hash: Felt252, @@ -297,21 +296,11 @@ impl DeclareV2 { /// ## Parameter: /// - state: An state that implements the State and StateReader traits. /// - block_context: The block that contains the execution context - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( - tx_type = ?TransactionType::Declare, - self.version = ?self.version, - self.sierra_class_hash = ?self.sierra_class_hash, - self.compiled_class_hash = ?self.compiled_class_hash, - self.hash_value = ?self.hash_value, - self.sender_address = ?self.sender_address, - self.nonce = ?self.nonce, - ))] pub fn execute( &self, state: &mut CachedState, block_context: &BlockContext, ) -> Result { - self.handle_nonce(state)?; verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; let initial_gas = INITIAL_GAS_COST; @@ -329,13 +318,11 @@ impl DeclareV2 { )?; (info, gas) }; - self.compile_and_store_casm_class(state)?; - let storage_changes = state.count_actual_state_changes(Some(( + let storage_changes = state.count_actual_storage_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.sender_address, )))?; - let actual_resources = calculate_tx_resources( resources_manager, &[execution_result.call_info.clone()], @@ -355,6 +342,7 @@ impl DeclareV2 { &mut tx_execution_context, self.skip_fee_transfer, )?; + self.compile_and_store_casm_class(state)?; let mut tx_exec_info = TransactionExecutionInfo::new_without_fee_info( execution_result.call_info, @@ -373,13 +361,10 @@ impl DeclareV2 { state: &mut S, ) -> Result<(), TransactionError> { let casm_class = match &self.casm_class { - None => CasmContractClass::from_contract_class( - self.sierra_contract_class - .clone() - .ok_or(TransactionError::DeclareV2NoSierraOrCasm)?, - true, - ) - .map_err(|e| TransactionError::SierraCompileError(e.to_string()))?, + None => { + CasmContractClass::from_contract_class(self.sierra_contract_class.clone(), true) + .map_err(|e| TransactionError::SierraCompileError(e.to_string()))? + } Some(casm_contract_class) => casm_contract_class.clone(), }; @@ -390,11 +375,8 @@ impl DeclareV2 { self.compiled_class_hash.to_string(), )); } - if let Some(ref class) = self.sierra_contract_class { - state.set_sierra_program(&self.sierra_class_hash, class.sierra_program.clone())?; - } - state.set_compiled_class_hash(&self.sierra_class_hash, &self.compiled_class_hash)?; + state.set_contract_class( &self.compiled_class_hash.to_be_bytes(), &CompiledClass::Casm(Arc::new(casm_class)), @@ -451,7 +433,7 @@ impl DeclareV2 { // --------------- // Simulation // --------------- - pub fn create_for_simulation( + pub(crate) fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -545,7 +527,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.unwrap().clone(), + internal_declare.sierra_contract_class.clone(), true, ) .unwrap(); @@ -614,7 +596,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.unwrap(), + internal_declare.sierra_contract_class.clone(), true, ) .unwrap(); @@ -637,13 +619,13 @@ mod tests { let path; #[cfg(not(feature = "cairo_1_tests"))] { - version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); + version = &2.into() | &QUERY_VERSION_BASE.clone(); path = PathBuf::from("starknet_programs/cairo2/fibonacci.sierra"); } #[cfg(feature = "cairo_1_tests")] { - version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); + version = &1.into() | &QUERY_VERSION_BASE.clone(); path = PathBuf::from("starknet_programs/cairo1/fibonacci.sierra"); } @@ -660,7 +642,7 @@ mod tests { // create internal declare v2 let internal_declare = DeclareV2::new_with_sierra_class_hash_and_tx_hash( - Some(sierra_contract_class), + &sierra_contract_class, sierra_class_hash, Some(casm_class), casm_class_hash, @@ -685,7 +667,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.unwrap(), + internal_declare.sierra_contract_class.clone(), true, ) .unwrap(); @@ -754,7 +736,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.unwrap().clone(), + internal_declare.sierra_contract_class.clone(), true, ) .unwrap(); diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index 47168dfc4..32bf9feb3 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -34,8 +34,6 @@ use cairo_vm::felt::Felt252; use num_traits::Zero; use std::sync::Arc; -use std::fmt::Debug; - /// Represents a Deploy Transaction in the starknet network #[derive(Debug, Clone)] pub struct Deploy { @@ -140,7 +138,6 @@ impl Deploy { .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(_) => todo!(), } } /// Deploys the contract in the starknet network and calls its constructor if it has one. @@ -152,13 +149,7 @@ impl Deploy { state: &mut CachedState, block_context: &BlockContext, ) -> Result { - match self.contract_class { - CompiledClass::Sierra(_) => todo!(), - _ => { - state.set_contract_class(&self.contract_hash, &self.contract_class)?; - } - } - + state.set_contract_class(&self.contract_hash, &self.contract_class)?; state.deploy_contract(self.contract_address.clone(), self.contract_hash)?; if self.constructor_entry_points_empty(self.contract_class.clone())? { @@ -189,7 +180,7 @@ impl Deploy { let resources_manager = ExecutionResourcesManager::default(); - let changes = state.count_actual_state_changes(None)?; + let changes = state.count_actual_storage_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[Some(call_info.clone())], @@ -252,7 +243,7 @@ impl Deploy { block_context.validate_max_n_steps, )?; - let changes = state.count_actual_state_changes(None)?; + let changes = state.count_actual_storage_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[call_info.clone()], @@ -276,14 +267,6 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( - tx_type = ?TransactionType::Deploy, - self.version = ?self.version, - self.contract_hash = ?self.contract_hash, - self.hash_value = ?self.hash_value, - self.contract_address = ?self.contract_address, - self.contract_address_salt = ?self.contract_address_salt, - ))] pub fn execute( &self, state: &mut CachedState, diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index 978cbcca0..b537c6f99 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -40,7 +40,6 @@ use crate::{ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; -use std::fmt::Debug; #[derive(Clone, Debug, PartialEq, Eq)] pub struct StateSelector { @@ -157,15 +156,6 @@ impl DeployAccount { } } - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( - tx_type = ?TransactionType::DeployAccount, - self.version = ?self.version, - self.class_hash = ?self.class_hash, - self.hash_value = ?self.hash_value, - self.contract_address = ?self.contract_address, - self.contract_address_salt = ?self.contract_address_salt, - self.nonce = ?self.nonce, - ))] pub fn execute( &self, state: &mut CachedState, @@ -173,7 +163,7 @@ impl DeployAccount { ) -> Result { self.handle_nonce(state)?; - let mut transactional_state = state.create_transactional()?; + let mut transactional_state = state.create_transactional(); let mut tx_exec_info = self.apply(&mut transactional_state, block_context)?; let actual_fee = calculate_tx_fee( @@ -225,7 +215,6 @@ impl DeployAccount { .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(_) => todo!(), } } @@ -254,7 +243,7 @@ impl DeployAccount { resources_manager, &[Some(constructor_call_info.clone()), validate_info.clone()], TransactionType::DeployAccount, - state.count_actual_state_changes(Some(( + state.count_actual_storage_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.contract_address, )))?, @@ -404,7 +393,7 @@ impl DeployAccount { Ok(call_info) } - pub fn create_for_simulation( + pub(crate) fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -425,42 +414,6 @@ impl DeployAccount { Transaction::DeployAccount(tx) } - - pub fn from_sn_api_transaction( - value: starknet_api::transaction::DeployAccountTransaction, - chain_id: Felt252, - ) -> Result { - let max_fee = value.max_fee.0; - let version = Felt252::from_bytes_be(value.version.0.bytes()); - let nonce = Felt252::from_bytes_be(value.nonce.0.bytes()); - let class_hash: [u8; 32] = value.class_hash.0.bytes().try_into().unwrap(); - let contract_address_salt = Felt252::from_bytes_be(value.contract_address_salt.0.bytes()); - - let signature = value - .signature - .0 - .iter() - .map(|f| Felt252::from_bytes_be(f.bytes())) - .collect(); - let constructor_calldata = value - .constructor_calldata - .0 - .as_ref() - .iter() - .map(|f| Felt252::from_bytes_be(f.bytes())) - .collect(); - - DeployAccount::new( - class_hash, - max_fee, - version, - nonce, - constructor_calldata, - signature, - contract_address_salt, - chain_id, - ) - } } // ---------------------------------- diff --git a/src/transaction/error.rs b/src/transaction/error.rs index 87a1f76a5..c254dd152 100644 --- a/src/transaction/error.rs +++ b/src/transaction/error.rs @@ -147,6 +147,4 @@ pub enum TransactionError { InvalidCompiledClassHash(String, String), #[error(transparent)] FromByteArrayError(#[from] FromByteArrayError), - #[error("DeclareV2 transaction has neither Sierra nor Casm contract class set")] - DeclareV2NoSierraOrCasm, } diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index aa04a6e38..9808591be 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -73,9 +73,11 @@ pub(crate) fn execute_fee_transfer( call_info.ok_or(TransactionError::CallInfoIsNone) } +// ---------------------------------------------------------------------------------------- /// Calculates the fee of a transaction given its execution resources. /// We add the l1_gas_usage (which may include, for example, the direct cost of L2-to-L1 /// messages) to the gas consumed by Cairo resource and multiply by the L1 gas price. + pub fn calculate_tx_fee( resources: &HashMap, gas_price: u128, @@ -92,9 +94,11 @@ pub fn calculate_tx_fee( Ok(total_l1_gas_usage.ceil() as u128 * gas_price) } +// ---------------------------------------------------------------------------------------- /// Calculates the L1 gas consumed when submitting the underlying Cairo program to SHARP. /// I.e., returns the heaviest Cairo resource weight (in terms of L1 gas), as the size of /// a proof is determined similarly - by the (normalized) largest segment. + pub(crate) fn calculate_l1_gas_by_cairo_usage( block_context: &BlockContext, cairo_resource_usage: &HashMap, @@ -113,7 +117,6 @@ pub(crate) fn calculate_l1_gas_by_cairo_usage( )) } -/// Calculates the maximum weighted value from a given resource usage mapping. fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap) -> f64 { let mut max = 0.0_f64; for (k, v) in weights { @@ -133,11 +136,6 @@ fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap( state: &mut CachedState, resources: &HashMap, @@ -197,8 +195,6 @@ mod tests { }; use std::{collections::HashMap, sync::Arc}; - /// Tests the behavior of the charge_fee function when the actual fee exceeds the maximum fee - /// for version 0. It expects to return an ActualFeeExceedsMaxFee error. #[test] fn charge_fee_v0_max_fee_exceeded_should_charge_nothing() { let mut state = CachedState::new( @@ -228,8 +224,6 @@ mod tests { assert_eq!(result.1, 0); } - /// Tests the behavior of the charge_fee function when the actual fee exceeds the maximum fee - /// for version 1. It expects the function to return the maximum fee. #[test] fn charge_fee_v1_max_fee_exceeded_should_charge_max_fee() { let mut state = CachedState::new( diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 1f8a0937c..877131c0f 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -28,7 +28,6 @@ use crate::{ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; -use std::fmt::Debug; /// Represents an InvokeFunction transaction in the starknet network. #[derive(Debug, Getters, Clone)] @@ -245,12 +244,8 @@ impl InvokeFunction { remaining_gas: u128, ) -> Result { let mut resources_manager = ExecutionResourcesManager::default(); - let validate_info = if self.skip_validation { - None - } else { - self.run_validate_entrypoint(state, &mut resources_manager, block_context)? - }; - + let validate_info = + self.run_validate_entrypoint(state, &mut resources_manager, block_context)?; // Execute transaction let ExecutionResult { call_info, @@ -266,7 +261,7 @@ impl InvokeFunction { remaining_gas, )? }; - let changes = state.count_actual_state_changes(Some(( + let changes = state.count_actual_storage_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.contract_address, )))?; @@ -294,14 +289,6 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. /// - remaining_gas: The amount of gas that the transaction disposes. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( - tx_type = ?TransactionType::InvokeFunction, - self.version = ?self.version, - self.hash_value = ?self.hash_value, - self.contract_address = ?self.contract_address, - self.entry_point_selector = ?self.entry_point_selector, - self.entry_point_type = ?self.entry_point_type, - ))] pub fn execute( &self, state: &mut CachedState, @@ -312,7 +299,7 @@ impl InvokeFunction { self.handle_nonce(state)?; } - let mut transactional_state = state.create_transactional()?; + let mut transactional_state = state.create_transactional(); let mut tx_exec_info = self.apply(&mut transactional_state, block_context, remaining_gas)?; @@ -672,7 +659,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional().unwrap(); + let mut transactional = state.create_transactional(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) @@ -817,7 +804,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional().unwrap(); + let mut transactional = state.create_transactional(); let expected_error = internal_invoke_function.apply(&mut transactional, &BlockContext::default(), 0); @@ -880,7 +867,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional().unwrap(); + let mut transactional = state.create_transactional(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) @@ -953,7 +940,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional().unwrap(); + let mut transactional = state.create_transactional(); // Invoke result let expected_error = internal_invoke_function.apply(&mut transactional, &BlockContext::default(), 0); @@ -1304,7 +1291,7 @@ mod tests { ) .unwrap(), None, - &Into::::into(1) | &QUERY_VERSION_BASE.clone(), + &1.into() | &QUERY_VERSION_BASE.clone(), ); assert!(expected_error.is_err()); } @@ -1355,7 +1342,7 @@ mod tests { let mut state = CachedState::new(Arc::new(state_reader), Arc::new(casm_contract_class_cache)); - let state_before_execution = state.clone_for_testing(); + let state_before_execution = state.clone(); let result = internal_invoke_function .execute(&mut state, &BlockContext::default(), 0) diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index f01031436..fbae7e3e6 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -7,7 +7,6 @@ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; -use super::Transaction; use crate::{ core::transaction_hash::{calculate_transaction_hash_common, TransactionHashPrefix}, definitions::{ @@ -26,9 +25,10 @@ use crate::{ utils::{calculate_tx_resources, Address}, }; +use super::Transaction; + #[allow(dead_code)] #[derive(Debug, Getters, Clone)] -/// Represents an L1Handler transaction in the StarkNet network. pub struct L1Handler { #[getset(get = "pub")] hash_value: Felt252, @@ -43,7 +43,6 @@ pub struct L1Handler { } impl L1Handler { - /// Constructor creates a new [L1Handler] instance. pub fn new( contract_address: Address, entry_point_selector: Felt252, @@ -72,12 +71,7 @@ impl L1Handler { hash_value, ) } - /// Creates a new [L1Handler] instance with a specified transaction hash. - /// - /// # Safety - /// - /// `tx_hash` will be assumed to be the same as would result from calling - /// `calculate_transaction_hash_common`. Non-compliance will result in silent misbehavior. + pub fn new_with_tx_hash( contract_address: Address, entry_point_selector: Felt252, @@ -99,13 +93,6 @@ impl L1Handler { } /// Applies self to 'state' by executing the L1-handler entry point. - #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( - tx_type = ?TransactionType::L1Handler, - self.hash_value = ?self.hash_value, - self.contract_address = ?self.contract_address, - self.entry_point_selector = ?self.entry_point_selector, - self.nonce = ?self.nonce, - ))] pub fn execute( &self, state: &mut CachedState, @@ -141,7 +128,7 @@ impl L1Handler { )? }; - let changes = state.count_actual_state_changes(None)?; + let changes = state.count_actual_storage_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[call_info.clone()], @@ -202,9 +189,11 @@ impl L1Handler { L1_HANDLER_VERSION.into(), )) } - - /// Creates a L1Handler for simulation purposes. - pub fn create_for_simulation(&self, skip_validate: bool, skip_execute: bool) -> Transaction { + pub(crate) fn create_for_simulation( + &self, + skip_validate: bool, + skip_execute: bool, + ) -> Transaction { let tx = L1Handler { skip_validate, skip_execute, @@ -213,27 +202,6 @@ impl L1Handler { Transaction::L1Handler(tx) } - - /// Creates a `L1Handler` from a starknet api `L1HandlerTransaction`. - pub fn from_sn_api_tx( - tx: starknet_api::transaction::L1HandlerTransaction, - tx_hash: Felt252, - paid_fee_on_l1: Option, - ) -> Result { - L1Handler::new_with_tx_hash( - Address(Felt252::from_bytes_be(tx.contract_address.0.key().bytes())), - Felt252::from_bytes_be(tx.entry_point_selector.0.bytes()), - tx.calldata - .0 - .as_ref() - .iter() - .map(|f| Felt252::from_bytes_be(f.bytes())) - .collect(), - Felt252::from_bytes_be(tx.nonce.0.bytes()), - paid_fee_on_l1, - tx_hash, - ) - } } #[cfg(test)] @@ -262,7 +230,6 @@ mod test { sync::Arc, }; - /// Test the correct execution of the L1Handler. #[test] fn test_execute_l1_handler() { let l1_handler = L1Handler::new( @@ -322,8 +289,6 @@ mod test { assert_eq!(tx_exec, expected_tx_exec) } - /// Helper function to construct the expected transaction execution info. - /// Expected output of the L1Handler's execution. fn expected_tx_exec_info() -> TransactionExecutionInfo { TransactionExecutionInfo { validate_info: None, @@ -346,14 +311,14 @@ mod test { 10.into(), ], retdata: vec![], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 141, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 6), ("pedersen_builtin".to_string(), 2), ]), - }), + }, events: vec![], l2_to_l1_messages: vec![], storage_read_values: vec![0.into(), 0.into()], diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index 3d75e4266..5584aa940 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -82,7 +82,6 @@ impl Transaction { Transaction::L1Handler(tx) => tx.execute(state, block_context, remaining_gas), } } - /// It creates a new transaction structure modificating the skip flags. It is meant to be used only to run a simulation ///## Parameters: ///- skip_validate: the transaction will not be verified. diff --git a/src/transaction/verify_version.rs b/src/transaction/verify_version.rs index 2f9abecdb..8787b09b9 100644 --- a/src/transaction/verify_version.rs +++ b/src/transaction/verify_version.rs @@ -31,8 +31,6 @@ pub fn verify_version( #[cfg(test)] mod test { - use cairo_vm::felt::Felt252; - // TODO: fixture tests would be better here use crate::{definitions::constants::QUERY_VERSION_BASE, transaction::error::TransactionError}; @@ -111,7 +109,7 @@ mod test { #[test] fn version_0_with_max_fee_0_nonce_0_and_empty_signature_and_query_version_set_should_return_ok() { - let version = &Into::::into(0) | &QUERY_VERSION_BASE.clone(); + let version = &0.into() | &QUERY_VERSION_BASE.clone(); let max_fee = 0; let nonce = 0.into(); let signature = vec![]; @@ -121,7 +119,7 @@ mod test { #[test] fn version_1_with_query_version_set_should_return_ok() { - let version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); + let version = &1.into() | &QUERY_VERSION_BASE.clone(); let max_fee = 2; let nonce = 3.into(); let signature = vec![5.into()]; @@ -131,7 +129,7 @@ mod test { #[test] fn version_2_with_query_version_set_should_return_ok() { - let version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); + let version = &2.into() | &QUERY_VERSION_BASE.clone(); let max_fee = 43; let nonce = 4.into(); let signature = vec![6.into()]; diff --git a/src/utils.rs b/src/utils.rs index dfa67e6d4..b1736f852 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ use crate::core::errors::hash_errors::HashError; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; -use crate::state::state_api::{State, StateChangesCount}; +use crate::state::state_api::State; use crate::{ definitions::transaction_type::TransactionType, execution::{ @@ -16,7 +16,6 @@ use cairo_vm::{ felt::Felt252, serde::deserialize_program::BuiltinName, vm::runners::builtin_runner, }; use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine}; -use core::fmt; use num_integer::Integer; use num_traits::{Num, ToPrimitive}; use serde::{Deserialize, Serialize}; @@ -37,21 +36,9 @@ pub type CompiledClassHash = [u8; 32]; //* Address //* ------------------- -#[derive(Clone, PartialEq, Hash, Eq, Default, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Hash, Eq, Default, Serialize, Deserialize)] pub struct Address(pub Felt252); -impl fmt::Display for Address { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "0x{}", self.0.to_str_radix(16)) - } -} - -impl fmt::Debug for Address { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self) - } -} - //* ------------------- //* Helper Functions //* ------------------- @@ -148,17 +135,17 @@ pub fn string_to_hash(class_string: &String) -> ClassHash { /// Converts CachedState storage mapping to StateDiff storage mapping. pub fn to_state_diff_storage_mapping( - storage_writes: &HashMap, + storage_writes: HashMap, ) -> HashMap> { let mut storage_updates: HashMap> = HashMap::new(); - for ((address, key), value) in storage_writes.iter() { + for ((address, key), value) in storage_writes.into_iter() { storage_updates - .entry(address.clone()) + .entry(address) .and_modify(|updates_for_address: &mut HashMap| { - let key_fe = Felt252::from_bytes_be(key); + let key_fe = Felt252::from_bytes_be(&key); updates_for_address.insert(key_fe, value.clone()); }) - .or_insert_with(|| HashMap::from([(Felt252::from_bytes_be(key), value.clone())])); + .or_insert_with(|| HashMap::from([(Felt252::from_bytes_be(&key), value)])); } storage_updates } @@ -182,11 +169,14 @@ pub fn calculate_tx_resources( resources_manager: ExecutionResourcesManager, call_info: &[Option], tx_type: TransactionType, - state_changes: StateChangesCount, + storage_changes: (usize, usize), l1_handler_payload_size: Option, n_reverted_steps: usize, ) -> Result, TransactionError> { + let (n_modified_contracts, n_storage_changes) = storage_changes; + let non_optional_calls: Vec = call_info.iter().flatten().cloned().collect(); + let n_deployments = non_optional_calls.iter().map(get_call_n_deployments).sum(); let mut l2_to_l1_messages = Vec::new(); @@ -194,8 +184,13 @@ pub fn calculate_tx_resources( l2_to_l1_messages.extend(call_info.get_sorted_l2_to_l1_messages()?) } - let l1_gas_usage = - calculate_tx_gas_usage(l2_to_l1_messages, &state_changes, l1_handler_payload_size); + let l1_gas_usage = calculate_tx_gas_usage( + l2_to_l1_messages, + n_modified_contracts, + n_storage_changes, + l1_handler_payload_size, + n_deployments, + ); let cairo_usage = resources_manager.cairo_usage.clone(); let tx_syscall_counter = resources_manager.syscall_counter; @@ -306,7 +301,7 @@ pub fn get_storage_var_address( let args = args .iter() - .map(felt_to_field_element) + .map(|felt| felt_to_field_element(felt)) .collect::, _>>()?; let storage_var_name_hash = @@ -493,7 +488,6 @@ pub mod test_utils { macro_rules! ids_data { ( $( $name: expr ),* ) => { { - #[allow(clippy::useless_vec)] let ids_names = vec![$( $name ),*]; let references = $crate::utils::test_utils::references!(ids_names.len() as i32); let mut ids_data = HashMap::::new(); @@ -816,7 +810,7 @@ mod test { storage.insert((address1.clone(), key1), value1.clone()); storage.insert((address2.clone(), key2), value2.clone()); - let map = to_state_diff_storage_mapping(&storage); + let map = to_state_diff_storage_mapping(storage); let key1_fe = Felt252::from_bytes_be(key1.as_slice()); let key2_fe = Felt252::from_bytes_be(key2.as_slice()); @@ -887,7 +881,7 @@ mod test { storage.insert((address1.clone(), key1), value1.clone()); storage.insert((address2.clone(), key2), value2.clone()); - let state_dff = to_state_diff_storage_mapping(&storage); + let state_dff = to_state_diff_storage_mapping(storage); let cache_storage = to_cache_state_storage_mapping(&state_dff); let mut expected_res = HashMap::new(); @@ -926,10 +920,4 @@ mod test { ], ); } - - #[test] - fn test_address_display() { - let address = Address(Felt252::from(123456789)); - assert_eq!(format!("{}", address), "0x75bcd15".to_string()); - } } diff --git a/starknet_programs/cairo1/square_root_recursive.cairo b/starknet_programs/cairo1/square_root_recursive.cairo deleted file mode 100644 index a38b7e1fe..000000000 --- a/starknet_programs/cairo1/square_root_recursive.cairo +++ /dev/null @@ -1,24 +0,0 @@ -#[abi] -trait Math { - #[external] - fn square_root(n: felt252) -> felt252; -} - -#[contract] -mod SquareRoot { - use super::MathDispatcherTrait; - use super::MathLibraryDispatcher; - use starknet::ClassHash; - - #[external] - fn square_root_recursive(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { - square_root_recursive_inner(n, math_class_hash, n_iterations) - } - - fn square_root_recursive_inner(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { - if n_iterations == 0 { - return n; - } - square_root_recursive_inner(MathLibraryDispatcher {class_hash: math_class_hash}.square_root(n), math_class_hash, n_iterations - 1) - } -} diff --git a/starknet_programs/cairo1/wallet_wrapper.cairo b/starknet_programs/cairo1/wallet_wrapper.cairo index ca65cef90..d3557a309 100644 --- a/starknet_programs/cairo1/wallet_wrapper.cairo +++ b/starknet_programs/cairo1/wallet_wrapper.cairo @@ -22,13 +22,4 @@ mod WalletWrapper { fn increase_balance(amount: felt252, simple_wallet_contract_address: ContractAddress) { SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(amount) } - - #[external] - fn increase_balance_recursive(amount: felt252, simple_wallet_contract_address: ContractAddress) { - if amount == 0 { - return(); - } - SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(1); - increase_balance_recursive(amount - 1, simple_wallet_contract_address) - } } diff --git a/starknet_programs/cairo2/account_panic.cairo b/starknet_programs/cairo2/account_panic.cairo deleted file mode 100644 index 3cb051250..000000000 --- a/starknet_programs/cairo2/account_panic.cairo +++ /dev/null @@ -1,148 +0,0 @@ -use starknet::account::Call; - -mod SUPPORTED_TX_VERSION { - const DEPLOY_ACCOUNT: felt252 = 1; - const DECLARE: felt252 = 2; - const INVOKE: felt252 = 1; -} - -#[starknet::interface] -trait IAccount { - fn is_valid_signature(self: @T, hash: felt252, signature: Array) -> felt252; - fn supports_interface(self: @T, interface_id: felt252) -> bool; - fn public_key(self: @T) -> felt252; -} - -#[starknet::contract] -mod Account { - use super::{Call, IAccount, SUPPORTED_TX_VERSION}; - use starknet::{get_caller_address, call_contract_syscall, get_tx_info, VALIDATED}; - use zeroable::Zeroable; - use array::{ArrayTrait, SpanTrait}; - use ecdsa::check_ecdsa_signature; - use box::BoxTrait; - use result::ResultTrait; - - const SIMULATE_TX_VERSION_OFFSET: felt252 = 340282366920938463463374607431768211456; // 2**128 - const SRC6_TRAIT_ID: felt252 = 1270010605630597976495846281167968799381097569185364931397797212080166453709; // hash of SNIP-6 trait - - #[storage] - struct Storage { - public_key: felt252 - } - - #[constructor] - fn constructor(ref self: ContractState, public_key: felt252) { - self.public_key.write(public_key); - } - - #[external(v0)] - impl AccountImpl of IAccount { - fn is_valid_signature(self: @ContractState, hash: felt252, signature: Array) -> felt252 { - let is_valid = self.is_valid_signature_bool(hash, signature.span()); - if is_valid { VALIDATED } else { 0 } - } - - fn supports_interface(self: @ContractState, interface_id: felt252) -> bool { - interface_id == SRC6_TRAIT_ID - } - - fn public_key(self: @ContractState) -> felt252 { - self.public_key.read() - } - } - - #[external(v0)] - #[generate_trait] - impl ProtocolImpl of ProtocolTrait { - fn __execute__(ref self: ContractState, calls: Array) -> Array> { - let arr = ArrayTrait::new(); - panic_with_felt252('panic'); - arr - //self.only_protocol(); - // self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); - // self.execute_multiple_calls(calls) - } - - fn __validate__(self: @ContractState, calls: Array) -> felt252 { - panic_with_felt252('panic'); - 0 -// self.only_protocol(); -// self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); -// self.validate_transaction() - } - - fn __validate_declare__(self: @ContractState, class_hash: felt252) -> felt252 { - self.only_protocol(); - self.only_supported_tx_version(SUPPORTED_TX_VERSION::DECLARE); - self.validate_transaction() - } - - fn __validate_deploy__(self: @ContractState, class_hash: felt252, salt: felt252, public_key: felt252) -> felt252 { - self.only_protocol(); - self.only_supported_tx_version(SUPPORTED_TX_VERSION::DEPLOY_ACCOUNT); - self.validate_transaction() - } - } - - #[generate_trait] - impl PrivateImpl of PrivateTrait { - fn only_protocol(self: @ContractState) { - let sender = get_caller_address(); - assert(sender.is_zero(), 'Account: invalid caller'); - } - - fn is_valid_signature_bool(self: @ContractState, hash: felt252, signature: Span) -> bool { - let is_valid_length = signature.len() == 2_u32; - - if !is_valid_length { - return false; - } - - check_ecdsa_signature( - hash, self.public_key.read(), *signature.at(0_u32), *signature.at(1_u32) - ) - } - - fn validate_transaction(self: @ContractState) -> felt252 { - let tx_info = get_tx_info().unbox(); - let tx_hash = tx_info.transaction_hash; - let signature = tx_info.signature; - - let is_valid = self.is_valid_signature_bool(tx_hash, signature); - assert(is_valid, 'Account: Incorrect tx signature'); - VALIDATED - } - - fn execute_single_call(self: @ContractState, call: Call) -> Span { - let Call{to, selector, calldata} = call; - call_contract_syscall(to, selector, calldata.span()).unwrap() - } - - fn execute_multiple_calls(self: @ContractState, mut calls: Array) -> Array> { - let mut res = ArrayTrait::new(); - loop { - match calls.pop_front() { - Option::Some(call) => { - let _res = self.execute_single_call(call); - res.append(_res); - }, - Option::None(_) => { - break (); - }, - }; - }; - res - } - - fn only_supported_tx_version(self: @ContractState, supported_tx_version: felt252) { - let tx_info = get_tx_info().unbox(); - let version = tx_info.version; - assert( - version == supported_tx_version || - version == SIMULATE_TX_VERSION_OFFSET + supported_tx_version, - 'Account: Unsupported tx version' - ); - } - } -} diff --git a/starknet_programs/cairo2/callee.cairo b/starknet_programs/cairo2/callee.cairo deleted file mode 100644 index 3a71ab549..000000000 --- a/starknet_programs/cairo2/callee.cairo +++ /dev/null @@ -1,22 +0,0 @@ -#[starknet::contract] -mod Callee { - #[storage] - struct Storage { - balance: felt252, - } - - #[constructor] - fn constructor(ref self: ContractState, initial_balance: felt252) { - self.balance.write(initial_balance); - } - - #[external(v0)] - fn return_42(ref self: ContractState) -> felt252 { - 42 - } - - #[external(v0)] - fn return_44(ref self: ContractState) -> felt252 { - 44 - } -} \ No newline at end of file diff --git a/starknet_programs/cairo2/caller.cairo b/starknet_programs/cairo2/caller.cairo deleted file mode 100644 index 179478d46..000000000 --- a/starknet_programs/cairo2/caller.cairo +++ /dev/null @@ -1,19 +0,0 @@ -#[starknet::contract] -mod Caller { - use starknet::call_contract_syscall; - use core::array; - use core::result::ResultTrait; - - #[storage] - struct Storage { - balance: felt252, - } - - #[external(v0)] - fn call_callee_contract(ref self: ContractState, function_selector: felt252) -> felt252 { - let calldata: Array = ArrayTrait::new(); - let callee_addr = starknet::get_contract_address(); - let return_data = call_contract_syscall(callee_addr, function_selector, calldata.span()).unwrap(); - *return_data.get(0_usize).unwrap().unbox() - } -} diff --git a/starknet_programs/cairo2/deploy.cairo b/starknet_programs/cairo2/deploy.cairo index 8025d11aa..b773e94bb 100644 --- a/starknet_programs/cairo2/deploy.cairo +++ b/starknet_programs/cairo2/deploy.cairo @@ -1,8 +1,6 @@ -use starknet::class_hash::ClassHash; - #[starknet::interface] trait IDeployTest { - fn deploy_test(self: @TContractState, class_hash: ClassHash, contract_address_salt: felt252) -> starknet::contract_address::ContractAddress; + fn deploy_test(self: @TContractState, class_hash: felt252, contract_address_salt: felt252) -> starknet::contract_address::ContractAddress; } #[starknet::contract] @@ -23,10 +21,10 @@ mod DeployTest { #[external(v0)] impl DeployTest of super::IDeployTest { - fn deploy_test(self: @ContractState, class_hash: ClassHash, contract_address_salt: felt252) -> ContractAddress { + fn deploy_test(self: @ContractState, class_hash: felt252, contract_address_salt: felt252) -> ContractAddress { let mut calldata = ArrayTrait::new(); calldata.append(100); - let (address0, _) = deploy_syscall(class_hash, contract_address_salt, calldata.span(), false).unwrap(); + let (address0, _) = deploy_syscall(class_hash.try_into().unwrap(), contract_address_salt, calldata.span(), false).unwrap(); address0 } } diff --git a/starknet_programs/cairo2/echo.cairo b/starknet_programs/cairo2/echo.cairo deleted file mode 100644 index 1cf32b282..000000000 --- a/starknet_programs/cairo2/echo.cairo +++ /dev/null @@ -1,17 +0,0 @@ -#[starknet::contract] -mod Echo { - #[storage] - struct Storage { - balance: felt252, - } - - #[constructor] - fn constructor(ref self: ContractState, initial_balance: felt252) { - self.balance.write(initial_balance); - } - - #[external(v0)] - fn echo(ref self: ContractState, value: felt252) -> felt252 { - value - } -} \ No newline at end of file diff --git a/starknet_programs/cairo2/echo_caller.cairo b/starknet_programs/cairo2/echo_caller.cairo deleted file mode 100644 index 80e29eb18..000000000 --- a/starknet_programs/cairo2/echo_caller.cairo +++ /dev/null @@ -1,20 +0,0 @@ -#[starknet::contract] -mod EchoCaller { - use starknet::call_contract_syscall; - use core::array; - use core::result::ResultTrait; - - #[storage] - struct Storage { - balance: felt252, - } - - #[external(v0)] - fn call_echo_contract(ref self: ContractState, function_selector: felt252, value: felt252) -> felt252 { - let mut calldata: Array = ArrayTrait::new(); - calldata.append(value); - let callee_addr = starknet::get_contract_address(); - let return_data = call_contract_syscall(callee_addr, function_selector, calldata.span()).unwrap(); - *return_data.get(0_usize).unwrap().unbox() - } -} diff --git a/starknet_programs/cairo2/erc20.cairo b/starknet_programs/cairo2/erc20.cairo index 464cf5d7d..c17e9b2f3 100644 --- a/starknet_programs/cairo2/erc20.cairo +++ b/starknet_programs/cairo2/erc20.cairo @@ -67,7 +67,7 @@ mod erc_20 { self.name.write(name); self.symbol.write(symbol); self.decimals.write(decimals); - // assert(!recipient.is_zero(), 'ERC20: mint to the 0 address'); + assert(!recipient.is_zero(), 'ERC20: mint to the 0 address'); self.total_supply.write(initial_supply); self.balances.write(recipient, initial_supply); self diff --git a/starknet_programs/cairo2/event_emitter.cairo b/starknet_programs/cairo2/event_emitter.cairo deleted file mode 100644 index fd5bb8129..000000000 --- a/starknet_programs/cairo2/event_emitter.cairo +++ /dev/null @@ -1,30 +0,0 @@ -#[starknet::contract] -mod EventTest { - use starknet::syscalls::emit_event_syscall; - - #[storage] - struct Storage { - balance: felt252, - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - EmitEvent: EmitEvent - } - - #[derive(Drop, starknet::Event)] - struct EmitEvent { - n: u128, - } - - #[external(v0)] - fn trigger_event(ref self: ContractState) -> felt252 { - let mut keys = ArrayTrait::new(); - keys.append('n'); - let mut values = ArrayTrait::new(); - values.append(1); - emit_event_syscall(keys.span(), values.span()).unwrap(); - 1234 - } -} diff --git a/starknet_programs/cairo2/hello_world_account.cairo b/starknet_programs/cairo2/hello_world_account.cairo index c98ded486..c87651795 100644 --- a/starknet_programs/cairo2/hello_world_account.cairo +++ b/starknet_programs/cairo2/hello_world_account.cairo @@ -108,7 +108,7 @@ mod Account { // Call the target contract starknet::call_contract_syscall( address: to, entry_point_selector: selector, calldata: calldata.span() - ).unwrap() + ).unwrap_syscall() } } } diff --git a/starknet_programs/cairo2/square_root_recursive.cairo b/starknet_programs/cairo2/square_root_recursive.cairo deleted file mode 100644 index a960e572e..000000000 --- a/starknet_programs/cairo2/square_root_recursive.cairo +++ /dev/null @@ -1,37 +0,0 @@ -use starknet::ClassHash; - -#[starknet::interface] -trait Math { - fn square_root(self: @TContractState, n: felt252) -> felt252; -} - -#[starknet::interface] -trait ISquareRoot { - fn square_root(self: @TContractState, n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252; -} - - -#[starknet::contract] -mod SquareRoot { - use super::MathDispatcherTrait; - use super::MathLibraryDispatcher; - use starknet::ClassHash; - - #[storage] - struct Storage{ - } - - #[external(v0)] - impl SquareRoot of super::ISquareRoot { - fn square_root(self: @ContractState, n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { - square_root_recursive_inner(n, math_class_hash, n_iterations) - } - } - - fn square_root_recursive_inner(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { - if n_iterations == 0 { - return n; - } - square_root_recursive_inner(MathLibraryDispatcher {class_hash: math_class_hash}.square_root(n), math_class_hash, n_iterations - 1) - } -} diff --git a/starknet_programs/cairo2/wallet_wrapper.cairo b/starknet_programs/cairo2/wallet_wrapper.cairo index d4a4a241b..5208f8f73 100644 --- a/starknet_programs/cairo2/wallet_wrapper.cairo +++ b/starknet_programs/cairo2/wallet_wrapper.cairo @@ -7,8 +7,7 @@ trait SimpleWallet { #[starknet::interface] trait IWalletWrapper { fn get_balance(self: @TContractState, simple_wallet_contract_address: starknet::ContractAddress) -> felt252; - fn increase_balance(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); - fn increase_balance_recursive(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); + fn increase_balance(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); } #[starknet::contract] @@ -29,16 +28,5 @@ mod WalletWrapper { fn increase_balance(ref self: ContractState, amount: felt252, simple_wallet_contract_address: ContractAddress) { SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(amount) } - fn increase_balance_recursive(ref self: ContractState, amount: felt252, simple_wallet_contract_address: ContractAddress) { - increase_balance_recursive_inner(amount, simple_wallet_contract_address) - } - } - - fn increase_balance_recursive_inner(amount: felt252, simple_wallet_contract_address: ContractAddress) { - if amount == 0 { - return(); - } - SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(1); - increase_balance_recursive_inner(amount - 1, simple_wallet_contract_address) } } diff --git a/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra b/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra deleted file mode 100644 index 0925ceabe..000000000 --- a/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra +++ /dev/null @@ -1,687 +0,0 @@ -{ - "sierra_program": [ - "0x1", - "0x2", - "0x0", - "0x2", - "0x0", - "0x0", - "0x13e", - "0xc2", - "0x2a", - "0x52616e6765436865636b", - "0x0", - "0x4761734275696c74696e", - "0x66656c74323532", - "0x4172726179", - "0x1", - "0x2", - "0x536e617073686f74", - "0x3", - "0x537472756374", - "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", - "0x4", - "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", - "0x456e756d", - "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", - "0x6", - "0x2d7b9ba5597ffc180f5bbd030da76b84ecf1e4f1311043a0a15295f29ccc1b0", - "0x7", - "0x753332", - "0x4275696c74696e436f737473", - "0xa5a3299e5660d06bfa52eacd3a1fcd165ecd6f0cbac6f443fe26f6f68c70f3", - "0x38c95698b12086e50047d206c91c7248ef6f3427861aea1234b080c80fddf35", - "0xb", - "0x53797374656d", - "0xc", - "0x14de46c93830b854d231d540339ee8ae16bb18830a375fe81572a472d5945f1", - "0xf", - "0x3b5488061ac7a66f24fcbc888e7d6d5454df009b3abc2572f25f2400cfac629", - "0xe", - "0x10", - "0x5", - "0x19b3b4955bdcfa379bfc5a4949111c4efdd79128f8676f4d0895419b22e2ad7", - "0x12", - "0x426f78", - "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", - "0x14", - "0x4e6f6e5a65726f", - "0x464c55b21b6d3dadb22fd8587d389a14c0e53182f19e003bdf15db3ecb1676", - "0x75313238", - "0x16c8ea90dd6c64f624ab9863dc00b8f2c35a45fb64a97fa4bac6359fba975ec", - "0x18", - "0x3610c7cf372ee49406b6d03ec0b82f790884fb8652a25c91b2a749ad8982bc5", - "0x19", - "0x17", - "0xcfb175da425fe9834ebf5c4c2342c0507188ad820763d15abada732ab9341a", - "0x1b", - "0x20df6a887dc282129d37d7fa362eda55eb38e5c74604aff8fd97f11e3e79a2f", - "0x1d", - "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", - "0xd3a26a7712a33547a4a74e7594a446ca400cb36a0c2c307b92eff9ce82ff8", - "0x20", - "0x53746f726167654261736541646472657373", - "0x2cf4ead4392e987c9b56754a10f0a8e0f13776791e096fa6503893f05582c51", - "0x23", - "0x1586938debaf5e59bfb4e9f27763dc7b3da65f9737172ffde9ff9b65b55d857", - "0x24", - "0x1ca27f4a416836d321a19551a437aeb9946fde25373762126dda39b53c0bd11", - "0x53746f7261676541646472657373", - "0x1909a2057b9c1373b889e003e050a09f431d8108e0659d03444ced99a6eea68", - "0xb1", - "0x7265766f6b655f61705f747261636b696e67", - "0x656e61626c655f61705f747261636b696e67", - "0x77697468647261775f676173", - "0x6272616e63685f616c69676e", - "0x73746f72655f74656d70", - "0x66756e6374696f6e5f63616c6c", - "0x656e756d5f6d61746368", - "0x8", - "0x7374727563745f6465636f6e737472756374", - "0x61727261795f6c656e", - "0x736e617073686f745f74616b65", - "0x9", - "0x64726f70", - "0x7533325f636f6e7374", - "0x72656e616d65", - "0x7533325f6571", - "0x7374727563745f636f6e737472756374", - "0x656e756d5f696e6974", - "0x6a756d70", - "0x626f6f6c5f6e6f745f696d706c", - "0x6765745f6275696c74696e5f636f737473", - "0xa", - "0x77697468647261775f6761735f616c6c", - "0x64697361626c655f61705f747261636b696e67", - "0xd", - "0x11", - "0x61727261795f6e6577", - "0x13", - "0x66656c743235325f636f6e7374", - "0x4f7574206f6620676173", - "0x61727261795f617070656e64", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x61727261795f736e617073686f745f706f705f66726f6e74", - "0x15", - "0x756e626f78", - "0x66656c743235325f737562", - "0x66656c743235325f69735f7a65726f", - "0x16", - "0x1a", - "0x1c", - "0x753132385f636f6e7374", - "0x1e", - "0x656d69745f6576656e745f73797363616c6c", - "0x1f", - "0x21", - "0x73746f726167655f626173655f616464726573735f636f6e7374", - "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", - "0x22", - "0x25", - "0x753132385f6f766572666c6f77696e675f616464", - "0x26", - "0x753132385f616464204f766572666c6f77", - "0x753132385f746f5f66656c74323532", - "0x73746f726167655f616464726573735f66726f6d5f62617365", - "0x27", - "0x73746f726167655f77726974655f73797363616c6c", - "0x477e157efde59c5531277ede78acb3e03ef69508c6c35fde3495aa0671d227", - "0x1d3bd105efd11cb4e1d188c3f2b302935b4db511160389bd8b0a936ce967708", - "0x73746f726167655f726561645f73797363616c6c", - "0x28", - "0x53746f7261676541636365737355313238202d206e6f6e2075313238", - "0x75313238735f66726f6d5f66656c74323532", - "0x29", - "0x304", - "0xffffffffffffffff", - "0x76", - "0x66", - "0x53", - "0x44", - "0x2b", - "0x2c", - "0x2d", - "0x2e", - "0x3d", - "0x2f", - "0x30", - "0x31", - "0x32", - "0x33", - "0x34", - "0x35", - "0x36", - "0x37", - "0x38", - "0x39", - "0x3a", - "0x3b", - "0x3c", - "0x3e", - "0x3f", - "0x40", - "0x41", - "0x42", - "0x43", - "0x45", - "0x46", - "0x47", - "0x48", - "0x4b", - "0x49", - "0x4a", - "0x4c", - "0x4d", - "0x4e", - "0x4f", - "0x50", - "0x51", - "0x52", - "0x54", - "0x55", - "0x56", - "0x57", - "0x58", - "0x59", - "0x5a", - "0x5b", - "0x5c", - "0x5d", - "0x5e", - "0x5f", - "0x60", - "0x61", - "0x62", - "0x63", - "0x64", - "0x65", - "0x67", - "0x68", - "0x69", - "0xe3", - "0x9a", - "0x9e", - "0xd1", - "0xc4", - "0xbd", - "0xf9", - "0xfe", - "0x124", - "0x11a", - "0x11f", - "0x145", - "0x13e", - "0x17d", - "0x1a3", - "0x19c", - "0x194", - "0x18c", - "0x185", - "0x6a", - "0x6b", - "0x6c", - "0x6d", - "0x6e", - "0x6f", - "0x70", - "0x71", - "0x72", - "0x73", - "0x74", - "0x75", - "0x77", - "0x78", - "0x79", - "0x7a", - "0x7b", - "0x1c2", - "0x1e3", - "0x1e8", - "0x1f3", - "0x219", - "0x212", - "0x226", - "0x7c", - "0x7d", - "0x22a", - "0x7e", - "0x7f", - "0x80", - "0x81", - "0x236", - "0x82", - "0x83", - "0x84", - "0x85", - "0x24b", - "0x250", - "0x25b", - "0x86", - "0x87", - "0x88", - "0x89", - "0x8a", - "0x271", - "0x8b", - "0x8c", - "0x8d", - "0x27c", - "0x8e", - "0x8f", - "0x90", - "0x91", - "0x92", - "0x287", - "0x93", - "0x94", - "0x95", - "0x96", - "0x97", - "0x2ad", - "0x98", - "0x99", - "0x29f", - "0x9b", - "0x9c", - "0x9d", - "0x9f", - "0xa0", - "0xa1", - "0x2bc", - "0xa2", - "0x2c9", - "0xa3", - "0xa4", - "0xa5", - "0xa6", - "0xa7", - "0x2e8", - "0xa8", - "0xa9", - "0x2ef", - "0xaa", - "0xab", - "0xac", - "0xad", - "0xae", - "0xaf", - "0xb0", - "0xf2", - "0x12b", - "0x1ab", - "0x1af", - "0x1c8", - "0x1fa", - "0x220", - "0x23b", - "0x262", - "0x264", - "0x281", - "0x28d", - "0x2b6", - "0x2c2", - "0x2d2", - "0x2dc", - "0x2e2", - "0x2f2", - "0x2fe", - "0x1c1c", - "0x241c0d01018140c0302c0407050240c060401c0c06028080802018080200", - "0x182c02038282a020302804140104c2006090182202048382006080181e02", - "0x700409070240c1b030340409050680406050400c19030340409050083017", - "0x184602048380e06030883c06108184002048383e06068080e0a0f0183a06", - "0xb00c2b030a80409070a40c280101c14021389804060501c0c06128400c24", - "0x185e020483820060b8181a02048283c06170185a02048385206068080e0a", - "0x8681e030cc0c32010241c10030340407050240c10030c40409070780c30", - "0x187202048383c061c0186e02048386c06068080e0a0481852061a808120e", - "0xfc043e010f47829030a40c0d010241410030a40c3b010241c021d0a40c29", - "0x1c0c062307c0c06229100c06218080c062081c12062107c0c06208088002", - "0x138200603134044c240180c41240180c4b0101c0c4a240180c49240180c47", - "0x400c06248480c0621808a006038480c07270089e12030188202038480c07", - "0x104aa06031040c06031043206031342e060313404540114ca406031040451", - "0x240c06248240c062381c0c062b8740c06249580c06218241206210640c06", - "0x180c490301cb00603938b0060310404072c0180e4e108180c4d0f8180c4d", - "0x18b20c04818841e030189a1b030189a0703018b60703018825a03818b212", - "0x180c410101cbe06039380e06031783e0903108ba07031643e0603124b807", - "0x1c0c062381c0c062581c0c063017c0c06218180e5f0301c9c5f03018820c", - "0x1388806031040407220180e4e318180c490118804610101c0c59038180c49", - "0x740c06228401206211900c06208180e640301c9c2c030189a06039100c07", - "0x10c2409031082e06031042e060311c320603114ac06031040c072b0180e4e", - "0x18842903018820603818cc02039900c07270ac0c06268b80c06229940c06", - "0x180c490101cac06039383a0603134600603114ce060310c9009031088809", - "0x188409030188264030189264030188e5204818840203818cc10030188217", - "0x240c42348180c4b0301cd20603938d206031040407348180e4e011a02e09", - "0x18865504818846d03018826c03818d619030189233030188a6a030188619", - "0x180c410101cca06039385c06031343a09031086c0603104700603114dc06", - "0x18b206039c00c07271c00c06208080e700301c9c02378180e650301c9c65", - "0x180e4e180180c4d011d4e806031040473011c8360903108e0060312ce207", - "0x18842b03018827603818b2640301886060399c0c072719c0c06208080e67", - "0x138660603134d2060310c12060312cac0903108580603104ee07031643c09", - "0x1c9c790301886210481884023c0180e6a0301c9c6a030188202039a80c07", - "0x1cdc0603938f40703164dc06031040407370180e4e1c0180c4d0101c6c06", - "0x1601206210ac0c06228a40c06249c00c06218d80c06218180e360301c9c06", - "0x180e4e3e0180c493e0180c4d3c8180c410101cf20603938047b160180c49", - "0x8047e0300804023e8901206210a40c06259e40c06258080c06258180e79", - "0x3004023f01804090104820073f87c18073f01c0c020381c04023f0180406", - "0x1200c12010300c7e030300c100112088073f018a4060f808a4063f0181206", - "0x1f80c55031200455031f80c440311004023f0180409010640c800b818fc07", - "0x1480456031f80c020c808047e0306c0c170107836073f0183a06290083a06", - "0x18b0062a80848063f0183c062a808047e030840c170116042073f018ac06", - "0x8fc0601024040215808fc072f8900e1b010900c7e030900c1d0117c0c7e", - "0x180458010a40c7e030b00c21010b00c7e0318c0c560118c0c7e030083c02", - "0x1900c21011900c7e030ac0c24010ac0c7e030083c02011f80c02048080430", - "0x18fc0717018c60217018fc0617018420217018fc0614818be0214818fc06", - "0x18560233818fc06010a404023f018ca0616008047e030081202180190265", - "0x8047e030081202369a80e82199a40e7e0399c3e0c049900467031f80c67", - "0x18fc063481820021c018fc061b01860021b018fc060119404023f018042e", - "0x840484031f80c38030cc0483031f80c07031a40400031f80c330319c047c", - "0x1f80e79031b404793a1c0dc0c3f0190a8441800f81f350090a063f0182e06", - "0x1b80489031f80c021c008047e032180c3601008fc060102404880321d0c06", - "0x1918063c80918063f01916063a008047e032280c700122d14073f0191206", - "0x2400c7e031c00c670123c0c7e031b80c10012380c7e032340c7c012340c7e", - "0x1f80c020480924914823c180649018fc0647018000248818fc063a018d202", - "0x1a40495031f80c700319c0494031f80c6e030400493031f80c880320c0402", - "0x8047e0300812024b21d2a94060192c063f0192606000090e063f018e806", - "0x930063f01804850125c0c7e030087002011f80c170321004023f018042e", - "0x2680e8a012680c7e0300912024c818fc064c25c0e88012600c7e032600c86", - "0x1f80c6d0319c049c031f80c6a030400482031f80c9b0320c049b031f80c99", - "0x812024fa793a9c060193e063f0190406000093c063f0180e06348093a06", - "0x1c0c6901008fc060b8190802011f80c30030b004023f018042e01008fc06", - "0x28c0c7e030087002011f80ca2030b004a25081cfc0650019160250018fc06", - "0x9120252818fc065228c0e88012900c7e032900c86012900c7e030091802", - "0x1f80c0c0304004a8031f80ca70320c04a7031f80ca55301d140253018fc06", - "0x1956063f01950060000954063f01942063480902063f0183e06338095206", - "0x191a02011f80c19030b004023f018042e01008fc060102404ab55205520c", - "0x95a063f0195a06430095a063f018048e012b00c7e030087002011f80c44", - "0x19060258018fc06572bc0e8a012bc0c7e03009120257018fc0656ab00e88", - "0x1f80c07031a404b3031f80c1f0319c04b2031f80c0c0304004b1031f80cb0", - "0x1f80c0217008047e0300812025aad166b2060196a063f0196206000096806", - "0x196e06430096e063f0180485012d80c7e030087002011f80c09032340402", - "0x18fc065c2e40e8a012e40c7e0300912025c018fc065bad80e88012dc0c7e", - "0x1a404bc031f80c120319c0480031f80c100304004bb031f80cba0320c04ba", - "0x8047e0300804025f2f57880060197c063f0197606000097a063f0180e06", - "0x11004023f01804090104820075f87c18073f01c0c020381c04023f0180406", - "0x1480c170105ca4073f01890062900890063f01888062400888063f0181206", - "0x8047e031540c1701074aa073f01832062900832063f018041901008fc06", - "0x300c100106c0c7e0306c0c1d010780c7e030740c550106c0c7e0305c0c55", - "0x1580c7e030083c02011f80c020480804c0011f80e1e0d81c360206018fc06", - "0x1f80c020480804c103008b0022c018fc0610818420210818fc062b018ac02", - "0x18be022c018fc062f81842022f818fc0612018480212018fc06010780402", - "0x8120214819842c031f80e630318c0463031f80c63030840463031f80c58", - "0xac0c2b010ac0c7e030085202011f80c2c030b004023f018042e01008fc06", - "0x19404023f0180409010c0ca07618b8c8073f01c561f06024c80215818fc06", - "0x1f80c07031a40436031f80c2e0319c0469031f80c67030c00467031f80c02", - "0x18c80608008da6a19824fc06370e06c0947808dc063f018d206198087006", - "0x8fc06380186c02011f80c0204808e806621c00c7e039b40c6d011900c7e", - "0xc7401008fc063e018e002001f00e7e031e40c6e011e40c7e030087002", - "0x18fc0632018200242818fc0642018f80242018fc0641818f20241818fc06", - "0x300c8a031f80c85030000489031f80c6a031a40488031f80c330319c0486", - "0x918063f018c8060800916063f018e80641808047e030081202452251086", - "0x235180c0323c0c7e0322c0c00012380c7e031a80c69012340c7e030cc0c67", - "0x1922064300922063f0180485012400c7e030087002011f80c02048091e8e", - "0x18fc064924c0e8a0124c0c7e03009120249018fc0648a400e88012440c7e", - "0x1a40496031f80c300319c0487031f80c65030400495031f80c940320c0494", - "0x8047e0300812024c25d2c870601930063f0192a06000092e063f0180e06", - "0x1cfc064d81916024d818fc0603818d202011f80c29030b004023f018042e", - "0x2700c86012700c7e03009180241018fc06010e004023f0193406160093499", - "0x1f80c9d4f01d14024f018fc0601224049d031f80c9c4101d10024e018fc06", - "0x940063f0183e063380944063f01818060800942063f0193e06418093e06", - "0x8fc060102404a451a81440c032900c7e032840c000128c0c7e032640c69", - "0x2980c7e030090a0252818fc06010e004023f018120646808047e030085c02", - "0x1d140254018fc060122404a7031f80ca65281d100253018fc06530190c02", - "0x1824063380954063f01820060800902063f01952064180952063f0194ea8", - "0x11004ad562ad540c032b40c7e032040c00012b00c7e0301c0c69012ac0c7e", - "0x192202011f80c02048081806628240e073f01c0c06480080c063f0180406", - "0x98c06011600412031f80c1f0324c0410031f80c0703248041f031f80c09", - "0x1f80c0c032480448031f80c44032500444031f80c020f008047e030081202", - "0x8a4063f018a40606008a4063f01820063a00824063f0189006498082006", - "0x192c022a818fc060b8190e02011f80c020480832066385c0c7e038480c95", - "0x18fc060126404023f01836064c0083c1b039f80c1d0325c041d031f80c55", - "0x25c0424031f80c1e0325804023f01842064c008b021039f80c560325c0456", - "0x1858064b80858063f018b0064b008047e0317c0c980118cbe073f0184806", - "0xb80c7e030ac0c96011900c7e0318c0c9601008fc06148193002158a40e7e", - "0x26c0465031f80c65032180465031f80c2e3201d340232018fc06320190c02", - "0x1f80c67030900467031f80c020f008047e0300812021801990023f01cca06", - "0x18600641008047e030081202013240c022c00866063f018d20610808d206", - "0x17c0433031f80c6d03084046d031f80c6a03158046a031f80c020f008047e", - "0x1870064e808dc063f018a4060600870063f0186c064e0086c063f0186606", - "0x1d00c7e030083c02011f80c19030b004023f0180409011c0dc07031c00c7e", - "0x1f00e0600018fc063c8193a023e018fc062901818023c818fc063a0193c02", - "0x27c04023f0183e0616008047e03008120208019941f031f80e0c0318c0400", - "0x1f80c07031a40419031f80c060319c0444031f80c12032840412031f80c02", - "0x1f80c1b0e954320c5000836063f0188806510083a063f018120619808aa06", - "0x1f80c1e0328c04023f0180409011580ccb0f018fc070b818da020b9489009", - "0x8be063f01890063380848063f018040608008047e031600c2c011604207", - "0x8fc06010240402660180458010b00c7e030840c330118c0c7e031480c69", - "0x18d20232018fc0624018ce0215818fc0601018200214818fc062b0194802", - "0xb004023f0180409011945c64158300c65031f80c2903294042e031f80c52", - "0x18040608008d267039f80c300329c0430031f80c090329804023f0182006", - "0x1d00c7e031a40ca8011c00c7e0301c0c69011b80c7e030180c67010e00c7e", - "0x24047c03334f2063f01c6c06408086c6d350cc187e031d0e06e1c0315202", - "0x18fc0641819580241818fc0600019560200018fc063c8195402011f80c02", - "0xcc048b031f80c6d031a4048a031f80c6a0319c0485031f80c67030c00484", - "0x2251086049f80c8d4622d140c500091a063f01908065100918063f0190a06", - "0x92290039f80c8e0328c04023f01804090123c0cce47018fc0744818da02", - "0xcc0c100125126073f01924065380924063f019200653008047e032440c2c", - "0x18fc064a01950024d018fc0644018d2024c818fc0643018ce024c018fc06", - "0x9380667a080c7e03a5c0c810125d2c874a830fc064da693298062a4049b", - "0x18fc064a81820024f018fc06012b4049d031f80c82032a804023f0180409", - "0x27c0e7e0328d40a204abc04a3031f80c9e032b804a0031f80c9d032b804a2", - "0x94c063f019480655008047e03008120252819a0a4031f80ea10320404a1", - "0x2980cae012ac0c7e0324c0ca8012a80c7e032580c69012040c7e0321c0c67", - "0x19a2ad031f80ea9032c404a95429c127e032b156aa40831600256018fc06", - "0x2bc0c3001008fc06580185802582bc0e7e032b40cb201008fc060102404ae", - "0x18fc0654018d2022f818fc0653818ce0212018fc064f818200258818fc06", - "0x2d004b3031f80cb21601d660259018fc0601078042c031f80cb1030cc0463", - "0x18c606348096c063f018be06338096a063f01848060800968063f0196606", - "0x2b80ca401008fc060102404b85bad96a0c032e00c7e032d00ca5012dc0c7e", - "0x18fc0654018d2025d818fc0653818ce025d018fc064f81820025c818fc06", - "0x1f80c93032d404023f0180409012f100bb5d0300cbc031f80cb9032940480", - "0x1a404d2031f80c870319c04be031f80c9f0304004bd031f80ca5032900402", - "0x8047e0300812026a34da4be06019a8063f0197a0652809a6063f0192c06", - "0x190e0633809ac063f0192a0608009aa063f019380652008047e0324c0cb5", - "0x2404d96c35dac0c033640c7e033540ca5013600c7e032580c690135c0c7e", - "0x18fc0643018ce026d818fc061981820026d018fc06478194802011f80c02", - "0x180409011fdbadc6d8300c7f031f80cda0329404dd031f80c88031a404dc", - "0x19c04df031f80c330304004de031f80c7c0329004023f018ce065a808047e", - "0x385c0df06019c4063f019bc0652809c2063f018da0634809c0063f018d406", - "0x1c0e0604818fc06030196c0203818fc0601018d20203018fc060107804e2", - "0x18d20222018fc0601018ce0206018fc06012dc0409031f80c07032980409", - "0x1489044062c00417031f80c0c032b80452031f80c09032a00448031f80c06", - "0x196402011f80c0204808aa06718640c7e038480cb101048201f049f80c17", - "0x18fc0601078041e031f80c1d030c004023f018360616008361d039f80c19", - "0x848063f0183e0633808b0063f01842065a00842063f018ac1e03acc0456", - "0x8047e0300812023197c48090318c0c7e031600ca50117c0c7e030400c69", - "0xb00ca5010ac0c7e030400c69010a40c7e0307c0c67010b00c7e031540ca4", - "0xe0040c031f80c1f032e0041f031f80c09032880464158a4120632018fc06", - "0x1f80c44032e804482201cfc0606019720209018fc06010e00410031f80c02", - "0x200041b031f80c12032ec041d031f80c10032ec0455031f80c48032880402", - "0x8ac1e039f80c52031b804023f018320616008321729024fc060d874aa09", - "0x1600c7001090b0073f0182e063700842063f018ac063a008047e030780c70", - "0x17c0c7e0317c0c0c010840c7e030840c0c0117c0c7e030900c7401008fc06", - "0x18041e01008fc06010240464158a412e41618c0e7e0397c4206010317802", - "0x19c0c7e030b00c69010c00c7e0318c0c67011940c7e030b80cbd010b80c7e", - "0x18fc0632019a402011f80c020480804e503008b00234818fc06328197c02", - "0x34c0469031f80c33032f80467031f80c2b031a40430031f80c290319c0433", - "0x240438033986c063f01cd4066a808d4063f018da066a008da063f018d206", - "0x1f80c70032d00470031f80c6e0381d660237018fc061b019ac02011f80c02", - "0x1800063f018e80652808f8063f018ce0634808f2063f018600633808e806", - "0x19c0483031f80c380329004023f0180e066b808047e030081202001f0f209", - "0x2190a84048190c063f0190606528090a063f018ce063480908063f0186006", - "0x1f80c0203040041f031f80c020c80818063f01804d801008fc06048196a02", - "0x8aa063f0183e060e80832063f0180e06348082e063f0180c0633808a406", - "0x1c90066d808904409040187e03074aa190b9483eda010740c7e030300cd9", - "0x18fc062b019ba022b018fc060d819b802011f80c02048083c067386c0c7e", - "0x8047e0300812022f819d024031f80e21032040421031f80c58031fc0458", - "0x400c10010a40c7e030b00cdf010b00c7e0318c0cde0118c0c7e030900caa", - "0x18fc0614819c00217018fc0622018d20232018fc0609018ce0215818fc06", - "0x1f80c10030400430031f80c5f0338404023f0180409011945c64158300c65", - "0x18d4063f01860067000866063f018880634808d2063f018240633808ce06", - "0xd80c7e030400c10011b40c7e030780ce101008fc0601024046a199a4ce0c", - "0xd8180638018fc0636819c00237018fc0622018d2021c018fc0609018ce02", - "0x19d402011f80c0204808201f03ba41809039f80e070300812e2011c0dc38", - "0x9d806011600448031f80c12033ac0444031f80c09030400412031f80c0c", - "0x18a4067580888063f0183e0608008a4063f018200676808047e030081202", - "0x83a063f0182e0643008aa063f0189006778082e063f01804ee011200c7e", - "0x2a804023f0180409010780cf10d818fc070c81902020c818fc060e9540ef0", - "0x18880608008b0063f01842066f80842063f018ac066f008ac063f0183606", - "0x1f80c1e0338404023f01804090117c48070317c0c7e031600ce0010900c7e", - "0x180e0653808522c0381852063f018c6067000858063f018880608008c606", - "0x824063f01812067900820063f01804d801008fc060f8196a020f8300e7e", - "0x1888067a00890063f01890060e80890063f0180419011100c7e030400cf3", - "0x8fc0601024041d2a86412f60b9480e7e038488848030083ef5011100c7e", - "0x5c0c69011580c7e031480c67010780c7e0306c0cbd0106c0c7e030083c02", - "0x19a402011f80c020480804f703008b0022c018fc060f0197c0210818fc06", - "0x1f80c24032f80421031f80c55031a40456031f80c190319c0424031f80c1d", - "0x3e058063f01cbe066a808be063f018c6066a008c6063f018b00669808b006", - "0x3e80464031f80c2b0601df20215818fc0616019ac02011f80c02048085206", - "0x185c067d80860063f018420634808ca063f018ac06338085c063f018c806", - "0x1f80c29033f004023f01818065a808047e030081202338c0ca090319c0c7e", - "0x18da063f018d2067d808d4063f01842063480866063f018ac0633808d206", - "0x818067f0240c7e038080cfd010180c0603018fc06010194402369a86609", - "0x1f80c1f0301d10020f818fc060f8190c020f818fc06013fc04023f0180409", - "0x832063f0180e065d8082e063f01820065d808a4063f0181206800082006", - "0x8aa063f01824065d808047e031200c2c011208812049f80c190b9481301", - "0x836063f018050301008fc06010240402810180458010740c7e031100cbb", - "0x19760212018fc060601a08020f018fc060d8180e880106c0c7e0306c0c86", - "0xb0045810958127e0318cbe2404c140463031f80c07032ec045f031f80c1e", - "0x18fc0601078041d031f80c21032ec0455031f80c56032ec04023f018b006", - "0x240c64031f80c2c032d8042b031f80c1d034180429031f80c5503418042c", - "0x18fc060301a1202011f80c02048080e06840180c7e038080d07011905629", - "0x8047e0300812020f8180c1f031f80c0c0342c040c031f80c09034280409", - "0x1100d0b011100c7e030480d0c010480c7e0301c20074500820063f0180489", - "0x4820093f01c3e0903818190d0107c0c7e030300cf3011200c0624018fc06", - "0x18fc06220190c020e818fc06010182002011f80c02048082e52240261c44", - "0x480c7e030480c69010400c7e030400c670115432073f018361d03c3c041b", - "0x4480421031f80c1e0330004023f0180409011580d110f018fc072a81a2002", - "0x18200633808be063f01832060800848063f018b00689808b0063f0184206", - "0x2404291618cbe0c030a40c7e030900d14010b00c7e030480c690118c0c7e", - "0x2180464031f80c026080856063f018043801008fc062b0185802011f80c02", - "0xb8ca0745008ca063f0180489010b80c7e03190560744008c8063f018c806", - "0x18fc0608018ce0234818fc060c818200233818fc061801a2a0218018fc06", - "0x180409011b4d433348300c6d031f80c6703450046a031f80c12031a40433", - "0x8dc063f01870068980870063f0186c06890086c063f0182e068b008047e", - "0x1b80d14011e40c7e031480c69011d00c7e031200c67011c00c7e030080c10", - "0x8fc06010240407034600c063f01c04068b808f8793a1c018063e018fc06", - "0x7c0c060f818fc0606019c00206018fc0604819be0204818fc0603019bc02", - "0x1824067080824063f0180e1003a280410031f80c0244808047e030081202", - "0x240409034680e063f01c04068c8089006031200c7e031100ce0011100c7e", - "0x7c0c7e030300cdf010300c7e0301c0cde01008fc06030193002011f80c02", - "0x87002011f80c090346c04023f0180409010400c0608018fc060f819c002", - "0x1f80c442401d140224018fc06012240444031f80c060901d100209018fc06", - "0x1f80c020347004190301832063f0182e06700082e063f018a40670808a406", - "0x300e7e0304820078e80824063f0180e065d80820063f0181206570081206", - "0x300cbb011200c7e030180cbb011100c7e030083c02011f80c1f030b0041f", - "0x83c02011f80c020347804172912012060b818fc06220196c0229018fc06", - "0x18fc06048196c020f818fc0603819760206018fc0603019760204818fc06", - "0x8fc060102404100f83013200481c0e7e0381804078f808201f060240c10", - "0x8b00224018fc060901a440222018fc0603818200209018fc060481a4202", - "0x7804023f018a40692808a4063f018201f03c9004023f01804090100a4606", - "0x1f80c19034880444031f80c0c030400419031f80c17034980417031f80c02", - "0x180406948083a55038183a063f018900694008aa063f0188806938089006", - "0x8fc060601930020f8300e7e030240c97010240c7e0301c0cf20101c0c7e", - "0x82410039f80c482201e540224018fc0603019760222018fc060f8190c02", - "0x1f80c52032d80417031f80c10032ec0452031f80c020f008047e030480c2c", - "0x18041e010240c7e0301c0c07440080e063f01804064b0083217038183206", - "0x18040c2f8403e07030400c7e030300cb60107c0c7e030240cbb010300c7e", - "0x3d4120703008b05503008181f2a818040c010240e0601160aa06010303e55", - "0x1caa0696030120703008ac550300818120c9540c020fcac04440f81c3e06", - "0x1804562a81812640c9540c0c9701c0c022b1540c090c9540c09968082055", - "0x1804650101c52290102660090381804652a818040c0b9540c02064bc1207", - "0x24120932026660232018c806990240e060119caa06048a42e55030326207", - "0x1c0c02371540c02061b49055030083f35011a80c69034d00e06010401209", - "0x180410048241209048ac133803008ca06039c00f37011940c36034d81809", - "0x1c122903cec0c023c8080e070101e7407030082009048241209160267207", - "0x27a060104012070481c0f3c030082009" - ], - "sierra_program_debug_info": { - "type_names": [], - "libfunc_names": [], - "user_func_names": [] - }, - "contract_class_version": "0.1.0", - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x966af5d72d3975f70858b044c77785d3710638bbcebbd33cc7001a91025588", - "function_idx": 0 - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [ - { - "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", - "function_idx": 1 - } - ] - }, - "abi": [ - { - "type": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "function", - "name": "emit_event", - "inputs": [ - { - "name": "incremental", - "type": "core::bool" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "event", - "name": "events::events::ContractWithEvent::IncrementalEvent", - "kind": "struct", - "members": [ - { - "name": "value", - "type": "core::integer::u128", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "events::events::ContractWithEvent::StaticEvent", - "kind": "struct", - "members": [] - }, - { - "type": "event", - "name": "events::events::ContractWithEvent::Event", - "kind": "enum", - "variants": [ - { - "name": "IncrementalEvent", - "type": "events::events::ContractWithEvent::IncrementalEvent", - "kind": "nested" - }, - { - "name": "StaticEvent", - "type": "events::events::ContractWithEvent::StaticEvent", - "kind": "nested" - } - ] - } - ] -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm b/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm deleted file mode 100644 index e8527a982..000000000 --- a/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm +++ /dev/null @@ -1,1429 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.0.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xfffffffffffffffffffffffffffefe08", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x79", - "0x4825800180007ffa", - "0x101f8", - "0x400280007ff97fff", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0xf9", - "0x482680017ff98000", - "0x1", - "0x20680017fff7ffd", - "0x60", - "0x48307ffb80007ffc", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x3d", - "0x1104800180018000", - "0x354", - "0x482480017fff8000", - "0x353", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007fe1", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007ff37fff", - "0x10780017fff7fff", - "0x20", - "0x4824800180007fe1", - "0x0", - "0x400080007ff47fff", - "0x482480017ff48000", - "0x1", - "0x48127ffe7fff8000", - "0x480a7ffb7fff8000", - "0x48127ff07fff8000", - "0x1104800180018000", - "0xfe", - "0x20680017fff7ffd", - "0xc", - "0x40780017fff7fff", - "0x1", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017ff18000", - "0x1", - "0x48127fdc7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x15a", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff47fff8000", - "0x48127fdf7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ffd7fff8000", - "0x48127fe87fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xffffffffffffffffffffffffffffe3b8", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x64", - "0x4825800180007ffa", - "0x1c48", - "0x400280007ff97fff", - "0x48297ffc80007ffd", - "0x482680017ff98000", - "0x1", - "0x4824800180007ffe", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x3c", - "0x1104800180018000", - "0x2cd", - "0x482480017fff8000", - "0x2cc", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007ff4", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007ff47fff", - "0x10780017fff7fff", - "0x1f", - "0x4824800180007ff4", - "0x0", - "0x400080007ff57fff", - "0x48127fff7fff8000", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0xfe", - "0x482480017fd48000", - "0x1", - "0x20680017fff7ffc", - "0xc", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127fff7fff8000", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017ff28000", - "0x1", - "0x48127fef7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0xd4", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff57fff8000", - "0x48127ff27fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48297ffc80007ffd", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xa", - "0x482680017ffc8000", - "0x1", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x10780017fff7fff", - "0x8", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x20680017fff7ffc", - "0x15", - "0x480080007ffd8000", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x6", - "0x480680017fff8000", - "0x1", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x0", - "0x48307ffb80007ffc", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x4", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffd", - "0x1d", - "0x40780017fff7fff", - "0x96", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x1104800180018000", - "0x92", - "0x20680017fff7ffd", - "0x7", - "0x480a7ffa7fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x10780017fff7fff", - "0x35", - "0x40780017fff7fff", - "0x3", - "0x480a7ffa7fff8000", - "0x48127ff77fff8000", - "0x48127ff77fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff77fff8000", - "0x48127ff77fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x1104800180018000", - "0xc1", - "0x20680017fff7ffd", - "0x56", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x1104800180018000", - "0x73", - "0x20680017fff7ffd", - "0x43", - "0x48127fb17fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x1104800180018000", - "0xb1", - "0x20680017fff7ffd", - "0x32", - "0x48127ffa7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x1", - "0x1104800180018000", - "0xd6", - "0x20680017fff7ffd", - "0x20", - "0x48127fe57fff8000", - "0x48127fe57fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0xf9", - "0x20680017fff7ffd", - "0xf", - "0x48127fe47fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x3", - "0x48127fe17fff8000", - "0x48127ff77fff8000", - "0x48127ff77fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff77fff8000", - "0x48127ff77fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1b", - "0x48127fe17fff8000", - "0x48127fc97fff8000", - "0x48127fc97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127fdf7fff8000", - "0x48127fdf7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x31", - "0x48127fc97fff8000", - "0x48127fc97fff8000", - "0x48127fc97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127fc97fff8000", - "0x48127fc97fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x65", - "0x48127f4c7fff8000", - "0x48127f957fff8000", - "0x48127f957fff8000", - "0x480680017fff8000", - "0x1", - "0x48127f957fff8000", - "0x48127f957fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0xae", - "0x48127f4c7fff8000", - "0x48127f4c7fff8000", - "0x48127f4c7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127f4c7fff8000", - "0x48127f4c7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x1104800180018000", - "0xb0", - "0x20680017fff7ffd", - "0xb", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0xce", - "0x40780017fff7fff", - "0x1", - "0x40780017fff7fff", - "0x1", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x48127ffa7fff8000", - "0x1104800180018000", - "0xc5", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x480680017fff8000", - "0x456d69744576656e74", - "0x400280007ffb7fff", - "0x400380017ffb7ffa", - "0x400280027ffb7ffb", - "0x400280037ffb7ffc", - "0x400280047ffb7ffd", - "0x400280057ffb7ffe", - "0x480280077ffb8000", - "0x20680017fff7fff", - "0xd", - "0x480280067ffb8000", - "0x482680017ffb8000", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x9", - "0x480280067ffb8000", - "0x482680017ffb8000", - "0xa", - "0x480680017fff8000", - "0x1", - "0x480280087ffb8000", - "0x480280097ffb8000", - "0x1104800180018000", - "0xc6", - "0x20680017fff7ffd", - "0xb", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", - "0x1104800180018000", - "0xb9", - "0x20680017fff7ffc", - "0x1a", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0xee", - "0x20680017fff7ffd", - "0xb", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x8", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff27fff8000", - "0x48127ff27fff8000", - "0x208b7fff7fff7ffe", - "0x482a7ffd7ffc8001", - "0xa0680017fff7fff", - "0x7", - "0x4824800180007fff", - "0x100000000000000000000000000000000", - "0x400280007ffb7fff", - "0x10780017fff7fff", - "0xc", - "0x400280007ffb7fff", - "0x40780017fff7fff", - "0x1", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x10780017fff7fff", - "0x7", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x753132385f616464204f766572666c6f77", - "0x1104800180018000", - "0xc3", - "0x20680017fff7ffd", - "0x9", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", - "0x480680017fff8000", - "0x53746f726167655772697465", - "0x400280007ffc7fff", - "0x400380017ffc7ffb", - "0x400280027ffc7ffd", - "0x400280037ffc7ffe", - "0x400380047ffc7ffd", - "0x480280067ffc8000", - "0x20680017fff7fff", - "0xd", - "0x480280057ffc8000", - "0x482680017ffc8000", - "0x7", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x9", - "0x480280057ffc8000", - "0x482680017ffc8000", - "0x9", - "0x480680017fff8000", - "0x1", - "0x480280077ffc8000", - "0x480280087ffc8000", - "0x1104800180018000", - "0x3b", - "0x20680017fff7ffd", - "0xb", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ff8", - "0x13", - "0x480680017fff8000", - "0x477e157efde59c5531277ede78acb3e03ef69508c6c35fde3495aa0671d227", - "0x400280007ffb7fff", - "0x480a7ff97fff8000", - "0x480a7ffa7fff8000", - "0x482680017ffb8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x83", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x10780017fff7fff", - "0x12", - "0x40780017fff7fff", - "0xf", - "0x480680017fff8000", - "0x1d3bd105efd11cb4e1d188c3f2b302935b4db511160389bd8b0a936ce967708", - "0x400280007ffb7fff", - "0x480a7ffa7fff8000", - "0x482680017ffb8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x7b", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0x9", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x53746f7261676552656164", - "0x400280007ffb7fff", - "0x400380017ffb7ffa", - "0x400380027ffb7ffc", - "0x400380037ffb7ffd", - "0x480280057ffb8000", - "0x20680017fff7fff", - "0x28", - "0x480a7ff97fff8000", - "0x480280067ffb8000", - "0x1104800180018000", - "0x60", - "0x480280047ffb8000", - "0x482680017ffb8000", - "0x7", - "0x20680017fff7ffc", - "0xf", - "0x40780017fff7fff", - "0x2", - "0x48127ff97fff8000", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff57fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x53746f7261676541636365737355313238202d206e6f6e2075313238", - "0x400080007ffe7fff", - "0x48127ff97fff8000", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ff97fff8000", - "0x482480017ff88000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x11", - "0x480a7ff97fff8000", - "0x480280047ffb8000", - "0x482680017ffb8000", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1", - "0x480280067ffb8000", - "0x480280077ffb8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0xa", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x400180007fff7ffd", - "0x480680017fff8000", - "0x1", - "0x48127ffe7fff8000", - "0x482480017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ff97fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x33", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x16", - "0x480280007ffc8003", - "0x480280017ffc8003", - "0x4844800180017ffe", - "0x100000000000000000000000000000000", - "0x483180017ffd7ffd", - "0x482480017fff7ffd", - "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", - "0x20680017fff7ffc", - "0x6", - "0x402480017fff7ffd", - "0xffffffffffffffffffffffffffffffff", - "0x10780017fff7fff", - "0x4", - "0x402480017ffe7ffd", - "0xf7ffffffffffffef0000000000000000", - "0x400280027ffc7ffd", - "0x20680017fff7ffe", - "0xe", - "0x402780017fff7fff", - "0x1", - "0x400380007ffc7ffd", - "0x40780017fff7fff", - "0x5", - "0x482680017ffc8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x10780017fff7fff", - "0x8", - "0x482680017ffc8000", - "0x3", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x5", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x101f8" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 41, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -30 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 62, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 80, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 98, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 112, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 126, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 141, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x1c48" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 176, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -11 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 196, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 214, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 232, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 246, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 472, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 474, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 496, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -5 - } - } - } - } - ] - ], - [ - 583, - [ - { - "TestLessThan": { - "lhs": { - "Deref": { - "register": "AP", - "offset": 0 - } - }, - "rhs": { - "Immediate": "0x100000000000000000000000000000000" - }, - "dst": { - "register": "AP", - "offset": -1 - } - } - } - ] - ], - [ - 635, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -4 - } - } - } - } - ] - ], - [ - 735, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -5 - } - } - } - } - ] - ], - [ - 760, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 812, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 836, - [ - { - "TestLessThan": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Immediate": "0x100000000000000000000000000000000" - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 838, - [ - { - "DivMod": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Immediate": "0x100000000000000000000000000000000" - }, - "quotient": { - "register": "AP", - "offset": 3 - }, - "remainder": { - "register": "AP", - "offset": 4 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 66040 <= memory[fp + -6]" - ] - ], - [ - 41, - [ - "memory[ap + 0] = 0 <= memory[ap + -30]" - ] - ], - [ - 62, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 80, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 98, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 112, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 126, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 141, - [ - "memory[ap + 0] = 7240 <= memory[fp + -6]" - ] - ], - [ - 176, - [ - "memory[ap + 0] = 0 <= memory[ap + -11]" - ] - ], - [ - 196, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 214, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 232, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 246, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 472, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 474, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 496, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" - ] - ], - [ - 583, - [ - "memory[ap + -1] = memory[ap + 0] < 340282366920938463463374607431768211456" - ] - ], - [ - 635, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" - ] - ], - [ - 735, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" - ] - ], - [ - 760, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 812, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 836, - [ - "memory[ap + 0] = memory[fp + -3] < 340282366920938463463374607431768211456" - ] - ], - [ - 838, - [ - "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -3], 340282366920938463463374607431768211456)" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x966af5d72d3975f70858b044c77785d3710638bbcebbd33cc7001a91025588", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [ - { - "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", - "offset": 141, - "builtins": [ - "range_check" - ] - } - ] - } -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm b/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm deleted file mode 100644 index a3629918d..000000000 --- a/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm +++ /dev/null @@ -1,524 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.0.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xffffffffffffffffffffffffffff43f4", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x68", - "0x4825800180007ffa", - "0xbc0c", - "0x400280007ff97fff", - "0x48297ffc80007ffd", - "0x482680017ff98000", - "0x1", - "0x4824800180007ffe", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x40", - "0x1104800180018000", - "0x118", - "0x482480017fff8000", - "0x117", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007ff4", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007ff47fff", - "0x10780017fff7fff", - "0x23", - "0x4824800180007ff4", - "0x0", - "0x400080007ff57fff", - "0x48127fff7fff8000", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x4b", - "0x482480017f268000", - "0x1", - "0x20680017fff7ffc", - "0x10", - "0x40780017fff7fff", - "0x1", - "0x48127fff7fff8000", - "0x48127ffe7fff8000", - "0x1104800180018000", - "0x81", - "0x48127ff87fff8000", - "0x48127ff27fff8000", - "0x48127ff27fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127fff7fff8000", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017ff28000", - "0x1", - "0x48127fef7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x62", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff57fff8000", - "0x48127ff27fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1", - "0x1104800180018000", - "0x3f", - "0x20680017fff7ffd", - "0x2f", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x2", - "0x1104800180018000", - "0x35", - "0x20680017fff7ffd", - "0x1c", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x3", - "0x1104800180018000", - "0x2b", - "0x20680017fff7ffd", - "0xb", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x42", - "0x48127fb97fff8000", - "0x48127fb97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127fb97fff8000", - "0x48127fb97fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x84", - "0x48127f777fff8000", - "0x48127f777fff8000", - "0x480680017fff8000", - "0x1", - "0x48127f777fff8000", - "0x48127f777fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x43", - "0x40780017fff7fff", - "0x1", - "0x40780017fff7fff", - "0x1", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x48127ffa7fff8000", - "0x1104800180018000", - "0x3a", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x480680017fff8000", - "0x456d69744576656e74", - "0x400280007ffb7fff", - "0x400380017ffb7ffa", - "0x400280027ffb7ffb", - "0x400280037ffb7ffc", - "0x400280047ffb7ffd", - "0x400280057ffb7ffe", - "0x480280077ffb8000", - "0x20680017fff7fff", - "0xd", - "0x480280067ffb8000", - "0x482680017ffb8000", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x9", - "0x480280067ffb8000", - "0x482680017ffb8000", - "0xa", - "0x480680017fff8000", - "0x1", - "0x480280087ffb8000", - "0x480280097ffb8000", - "0x1104800180018000", - "0x27", - "0x20680017fff7ffd", - "0xb", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x363b90c0b8be133a6373701cce2f678d73ec604cb810f4d8b511c6a3ea4fcfd", - "0x400280007ffb7fff", - "0x480a7ff97fff8000", - "0x480a7ffa7fff8000", - "0x482680017ffb8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x15", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0x9", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ff97fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x7", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0xbc0c" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 35, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -11 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 55, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 77, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 95, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 109, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 197, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 199, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 221, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -5 - } - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 48140 <= memory[fp + -6]" - ] - ], - [ - 35, - [ - "memory[ap + 0] = 0 <= memory[ap + -11]" - ] - ], - [ - 55, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 77, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 95, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 109, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 197, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 199, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 221, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x2e8359222ced3eab92eabe6442847adf1c8234edbdea21c3fa8b2d5573346c4", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - } -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm b/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm deleted file mode 100644 index bf0ff34ca..000000000 --- a/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm +++ /dev/null @@ -1,1097 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.0.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xffffffffffffffffffffffffffff8a94", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x7e", - "0x4825800180007ffa", - "0x756c", - "0x400280007ff97fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x111", - "0x20680017fff7ffe", - "0x65", - "0x48307ffc80007ffd", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x42", - "0x1104800180018000", - "0x25f", - "0x482480017fff8000", - "0x25e", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007fd7", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007fef7fff", - "0x10780017fff7fff", - "0x25", - "0x4824800180007fd7", - "0x0", - "0x400080007ff07fff", - "0x482480017ff08000", - "0x1", - "0x48127ffe7fff8000", - "0x480a7ffb7fff8000", - "0x48127ff17fff8000", - "0x1104800180018000", - "0x11b", - "0x20680017fff7ffd", - "0x11", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0x13b", - "0x48127feb7fff8000", - "0x48127feb7fff8000", - "0x48127feb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017fed8000", - "0x1", - "0x48127fd27fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x121", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff07fff8000", - "0x48127fd57fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff97fff8000", - "0x48127fde7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xffffffffffffffffffffffffffffd346", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x79", - "0x4825800180007ffa", - "0x2cba", - "0x400280007ff97fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x7f", - "0x20680017fff7ffe", - "0x60", - "0x48307ffc80007ffd", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x3d", - "0x1104800180018000", - "0x1cd", - "0x482480017fff8000", - "0x1cc", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007fd7", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007fef7fff", - "0x10780017fff7fff", - "0x20", - "0x4824800180007fd7", - "0x0", - "0x400080007ff07fff", - "0x48127fff7fff8000", - "0x480a7ffb7fff8000", - "0x48127ff27fff8000", - "0x1104800180018000", - "0xbe", - "0x482480017fce8000", - "0x1", - "0x20680017fff7ffc", - "0xc", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127fff7fff8000", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017fed8000", - "0x1", - "0x48127fd27fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x94", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff07fff8000", - "0x48127fd57fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff97fff8000", - "0x48127fde7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48297ffc80007ffd", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xa", - "0x482680017ffc8000", - "0x1", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x10780017fff7fff", - "0x8", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x20680017fff7ffc", - "0x17", - "0x480a7ffb7fff8000", - "0x480080007ffc8000", - "0x1104800180018000", - "0x67", - "0x20680017fff7ffe", - "0x9", - "0x48127ffd7fff8000", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffd7fff8000", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0xd", - "0x480a7ffb7fff8000", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x1104800180018000", - "0x6e", - "0x20680017fff7ffd", - "0x1a", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x94", - "0x20680017fff7ffd", - "0xb", - "0x48127fe27fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127fe27fff8000", - "0x208b7fff7fff7ffe", - "0x48127fe27fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x18", - "0x48127fe27fff8000", - "0x48127fe27fff8000", - "0x48127fe27fff8000", - "0x480680017fff8000", - "0x1", - "0x48127fe27fff8000", - "0x48127fe27fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0xa6", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x68", - "0x20680017fff7ffd", - "0xb", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x16", - "0x480280007ffc8003", - "0x480280017ffc8003", - "0x4844800180017ffe", - "0x100000000000000000000000000000000", - "0x483180017ffd7ffd", - "0x482480017fff7ffd", - "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", - "0x20680017fff7ffc", - "0x6", - "0x402480017fff7ffd", - "0xffffffffffffffffffffffffffffffff", - "0x10780017fff7fff", - "0x4", - "0x402480017ffe7ffd", - "0xf7ffffffffffffef0000000000000000", - "0x400280027ffc7ffd", - "0x20680017fff7ffe", - "0xe", - "0x402780017fff7fff", - "0x1", - "0x400380007ffc7ffd", - "0x40780017fff7fff", - "0x5", - "0x482680017ffc8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x10780017fff7fff", - "0x8", - "0x482680017ffc8000", - "0x3", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", - "0x1104800180018000", - "0x5f", - "0x20680017fff7ffc", - "0x1a", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0x94", - "0x20680017fff7ffd", - "0xb", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x8", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x48127ff17fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff27fff8000", - "0x48127ff27fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", - "0x480680017fff8000", - "0x53746f726167655772697465", - "0x400280007ffc7fff", - "0x400380017ffc7ffb", - "0x400280027ffc7ffd", - "0x400280037ffc7ffe", - "0x400380047ffc7ffd", - "0x480280067ffc8000", - "0x20680017fff7fff", - "0xd", - "0x480280057ffc8000", - "0x482680017ffc8000", - "0x7", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x9", - "0x480280057ffc8000", - "0x482680017ffc8000", - "0x9", - "0x480680017fff8000", - "0x1", - "0x480280077ffc8000", - "0x480280087ffc8000", - "0x1104800180018000", - "0x62", - "0x20680017fff7ffd", - "0xb", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x53746f7261676552656164", - "0x400280007ffb7fff", - "0x400380017ffb7ffa", - "0x400380027ffb7ffc", - "0x400380037ffb7ffd", - "0x480280057ffb8000", - "0x20680017fff7fff", - "0x28", - "0x480a7ff97fff8000", - "0x480280067ffb8000", - "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff69", - "0x480280047ffb8000", - "0x482680017ffb8000", - "0x7", - "0x20680017fff7ffc", - "0xf", - "0x40780017fff7fff", - "0x2", - "0x48127ff97fff8000", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff57fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x53746f7261676541636365737355313238202d206e6f6e2075313238", - "0x400080007ffe7fff", - "0x48127ff97fff8000", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ff97fff8000", - "0x482480017ff88000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x11", - "0x480a7ff97fff8000", - "0x480280047ffb8000", - "0x482680017ffb8000", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1", - "0x480280067ffb8000", - "0x480280077ffb8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0x9", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x756c" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 41, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -40 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 62, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 85, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 103, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 117, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 131, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 146, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x2cba" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 187, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -40 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 208, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 226, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 244, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 258, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 272, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 415, - [ - { - "TestLessThan": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Immediate": "0x100000000000000000000000000000000" - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 417, - [ - { - "DivMod": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Immediate": "0x100000000000000000000000000000000" - }, - "quotient": { - "register": "AP", - "offset": 3 - }, - "remainder": { - "register": "AP", - "offset": 4 - } - } - } - ] - ], - [ - 510, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -4 - } - } - } - } - ] - ], - [ - 562, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -5 - } - } - } - } - ] - ], - [ - 587, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 30060 <= memory[fp + -6]" - ] - ], - [ - 41, - [ - "memory[ap + 0] = 0 <= memory[ap + -40]" - ] - ], - [ - 62, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 85, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 103, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 117, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 131, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 146, - [ - "memory[ap + 0] = 11450 <= memory[fp + -6]" - ] - ], - [ - 187, - [ - "memory[ap + 0] = 0 <= memory[ap + -40]" - ] - ], - [ - 208, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 226, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 244, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 258, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 272, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 415, - [ - "memory[ap + 0] = memory[fp + -3] < 340282366920938463463374607431768211456" - ] - ], - [ - 417, - [ - "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -3], 340282366920938463463374607431768211456)" - ] - ], - [ - 510, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" - ] - ], - [ - 562, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" - ] - ], - [ - 587, - [ - "memory[ap + 0] = segments.add()" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x1b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [ - { - "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", - "offset": 146, - "builtins": [ - "range_check" - ] - } - ] - } -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm b/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm deleted file mode 100644 index c4da4fc1c..000000000 --- a/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm +++ /dev/null @@ -1,755 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.0.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xffffffffffffffffffffffffffffc144", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x93", - "0x4825800180007ffa", - "0x3ebc", - "0x400280007ff97fff", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x9b", - "0x482680017ff98000", - "0x1", - "0x20680017fff7ffd", - "0x7a", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x1104800180018000", - "0x93", - "0x20680017fff7ffe", - "0x66", - "0x48307ffc80007ffd", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x43", - "0x1104800180018000", - "0x158", - "0x482480017fff8000", - "0x157", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007fd6", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007fe47fff", - "0x10780017fff7fff", - "0x26", - "0x4824800180007fd6", - "0x0", - "0x400080007fe57fff", - "0x482480017fe58000", - "0x1", - "0x48127ffe7fff8000", - "0x480a7ffb7fff8000", - "0x48127fe17fff8000", - "0x48127ff07fff8000", - "0x1104800180018000", - "0x8a", - "0x20680017fff7ffd", - "0x11", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0xd7", - "0x48127feb7fff8000", - "0x48127feb7fff8000", - "0x48127feb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017fe28000", - "0x1", - "0x48127fd17fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0xbd", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127fe57fff8000", - "0x48127fd47fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127fee7fff8000", - "0x48127fdd7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ffd7fff8000", - "0x48127fec7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48297ffc80007ffd", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xa", - "0x482680017ffc8000", - "0x1", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x10780017fff7fff", - "0x8", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x20680017fff7ffc", - "0x8", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x0", - "0x480080007ffa8000", - "0x208b7fff7fff7ffe", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x64", - "0x400080007ffe7fff", - "0x480a7ff97fff8000", - "0x480a7ffc7fff8000", - "0x1104800180018000", - "0x59", - "0x48127ff17fff8000", - "0x482480017ff08000", - "0x1", - "0x20680017fff7ffc", - "0x3a", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x4465706c6f79", - "0x400280007ffb7fff", - "0x400380017ffb7ffa", - "0x400280027ffb7ff9", - "0x400380037ffb7ffd", - "0x400280047ffb7ffc", - "0x400280057ffb7ffd", - "0x400280067ffb7ffe", - "0x480280087ffb8000", - "0x20680017fff7fff", - "0xc", - "0x480280077ffb8000", - "0x482680017ffb8000", - "0xc", - "0x480680017fff8000", - "0x0", - "0x480280097ffb8000", - "0x4802800a7ffb8000", - "0x4802800b7ffb8000", - "0x10780017fff7fff", - "0xb", - "0x480280077ffb8000", - "0x482680017ffb8000", - "0xb", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480280097ffb8000", - "0x4802800a7ffb8000", - "0x1104800180018000", - "0x55", - "0x20680017fff7ffc", - "0xb", - "0x48127fde7fff8000", - "0x48127fe77fff8000", - "0x48127fe77fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff87fff8000", - "0x208b7fff7fff7ffe", - "0x48127fde7fff8000", - "0x48127fe77fff8000", - "0x48127fe77fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1b", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7074696f6e3a3a756e77726170206661696c65642e", - "0x400080007ffe7fff", - "0x48127fde7fff8000", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x44", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0xa0680017fff8004", - "0xe", - "0x4825800180047ffd", - "0x800000000000000000000000000000000000000000000000000000000000000", - "0x484480017ffe8000", - "0x110000000000000000", - "0x48307ffe7fff8002", - "0x480280007ffc7ffc", - "0x480280017ffc7ffc", - "0x402480017ffb7ffd", - "0xffffffffffffffeeffffffffffffffff", - "0x400280027ffc7ffd", - "0x10780017fff7fff", - "0x13", - "0x484480017fff8001", - "0x8000000000000000000000000000000", - "0x48317fff80007ffd", - "0x480280007ffc7ffd", - "0x480280017ffc7ffd", - "0x402480017ffc7ffe", - "0xf8000000000000000000000000000000", - "0x400280027ffc7ffe", - "0x40780017fff7fff", - "0x1", - "0x482680017ffc8000", - "0x3", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x10780017fff7fff", - "0x8", - "0x482680017ffc8000", - "0x3", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x526573756c743a3a756e77726170206661696c65642e", - "0x1104800180018000", - "0x16", - "0x20680017fff7ffc", - "0x8", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x20780017fff7ff9", - "0xa", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x400180007fff7ffd", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffd7fff8000", - "0x482480017ffc8000", - "0x1", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x3ebc" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 47, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -41 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 69, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 92, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 110, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 124, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 138, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 152, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 203, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 230, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -5 - } - } - } - } - ] - ], - [ - 275, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 299, - [ - { - "TestLessThan": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Immediate": "0x800000000000000000000000000000000000000000000000000000000000000" - }, - "dst": { - "register": "AP", - "offset": 4 - } - } - } - ] - ], - [ - 303, - [ - { - "LinearSplit": { - "value": { - "Deref": { - "register": "AP", - "offset": 3 - } - }, - "scalar": { - "Immediate": "0x110000000000000000" - }, - "max_x": { - "Immediate": "0xffffffffffffffffffffffffffffffff" - }, - "x": { - "register": "AP", - "offset": -2 - }, - "y": { - "register": "AP", - "offset": -1 - } - } - } - ] - ], - [ - 313, - [ - { - "LinearSplit": { - "value": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "scalar": { - "Immediate": "0x8000000000000000000000000000000" - }, - "max_x": { - "Immediate": "0xffffffffffffffffffffffffffffffff" - }, - "x": { - "register": "AP", - "offset": -1 - }, - "y": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 375, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 16060 <= memory[fp + -6]" - ] - ], - [ - 47, - [ - "memory[ap + 0] = 0 <= memory[ap + -41]" - ] - ], - [ - 69, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 92, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 110, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 124, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 138, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 152, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 203, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 230, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" - ] - ], - [ - 275, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 299, - [ - "memory[ap + 4] = memory[fp + -3] < 3618502788666131106986593281521497120414687020801267626233049500247285301248" - ] - ], - [ - 303, - [ - "\n(value, scalar) = (memory[ap + 3], 313594649253062377472)\nx = min(value // scalar, 340282366920938463463374607431768211455)\ny = value - x * scalar\nmemory[ap + -2] = x\nmemory[ap + -1] = y\n" - ] - ], - [ - 313, - [ - "\n(value, scalar) = (memory[fp + -3], 10633823966279326983230456482242756608)\nx = min(value // scalar, 340282366920938463463374607431768211455)\ny = value - x * scalar\nmemory[ap + -1] = x\nmemory[ap + 0] = y\n" - ] - ], - [ - 375, - [ - "memory[ap + 0] = segments.add()" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x2f459db2a642c91d279cdbe9185f3934bb1cde01b16f89896c71066cf42bb18", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - } -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm b/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm deleted file mode 100644 index 03cf472ff..000000000 --- a/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm +++ /dev/null @@ -1,557 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.0.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xfffffffffffffffffffffffffffff8ee", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0xa7", - "0x4825800180007ffa", - "0x712", - "0x400280007ff97fff", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0xaf", - "0x482680017ff98000", - "0x1", - "0x20680017fff7ffd", - "0x8e", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x1104800180018000", - "0xa7", - "0x20680017fff7ffe", - "0x7a", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x1104800180018000", - "0xa1", - "0x20680017fff7ffe", - "0x66", - "0x48307ffc80007ffd", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x43", - "0x1104800180018000", - "0xfa", - "0x482480017fff8000", - "0xf9", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007fc7", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007fd57fff", - "0x10780017fff7fff", - "0x26", - "0x4824800180007fc7", - "0x0", - "0x400080007fd67fff", - "0x482480017fd68000", - "0x1", - "0x48127ffe7fff8000", - "0x48127fd37fff8000", - "0x48127fe27fff8000", - "0x48127ff07fff8000", - "0x1104800180018000", - "0x98", - "0x20680017fff7ffd", - "0x11", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0xd3", - "0x48127ff37fff8000", - "0x48127ff37fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017fd38000", - "0x1", - "0x48127fc27fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0xb6", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127fd67fff8000", - "0x48127fc57fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127fdf7fff8000", - "0x48127fce7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127fee7fff8000", - "0x48127fdd7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ffd7fff8000", - "0x48127fec7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48297ffc80007ffd", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xa", - "0x482680017ffc8000", - "0x1", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x10780017fff7fff", - "0x8", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x20680017fff7ffc", - "0x8", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x0", - "0x480080007ffa8000", - "0x208b7fff7fff7ffe", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x1104800180018000", - "0x4b", - "0x482480017fff8000", - "0x4a", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4825800180007ffa", - "0xa0a", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x2a", - "0x4825800180007ffa", - "0xa0a", - "0x400280007ff97fff", - "0x482680017ff98000", - "0x1", - "0x20780017fff7ffd", - "0x7", - "0x48127fff7fff8000", - "0x48127ffd7fff8000", - "0x480a7ffb7fff8000", - "0x10780017fff7fff", - "0xf", - "0x48127fff7fff8000", - "0x48127ffd7fff8000", - "0x480a7ffc7fff8000", - "0x482a7ffc7ffb8000", - "0x4825800180007ffd", - "0x1", - "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe1", - "0x20680017fff7ffd", - "0xd", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x482480017ffa8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x712" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 53, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -56 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 75, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 98, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 116, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 130, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 144, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 158, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 172, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 228, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0xa0a" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 277, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 1810 <= memory[fp + -6]" - ] - ], - [ - 53, - [ - "memory[ap + 0] = 0 <= memory[ap + -56]" - ] - ], - [ - 75, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 98, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 116, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 130, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 144, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 158, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 172, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 228, - [ - "memory[ap + 0] = 2570 <= memory[fp + -6]" - ] - ], - [ - 277, - [ - "memory[ap + 0] = segments.add()" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x112e35f48499939272000bd72eb840e502ca4c3aefa8800992e8defb746e0c9", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - } -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm b/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm deleted file mode 100644 index c2420dff1..000000000 --- a/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm +++ /dev/null @@ -1,476 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.0.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0x100000000000000000000000000000000", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x7d", - "0x4825800180007ffa", - "0x0", - "0x400280007ff97fff", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x85", - "0x482680017ff98000", - "0x1", - "0x20680017fff7ffd", - "0x64", - "0x48307ffb80007ffc", - "0x4824800180007fff", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48307ffe80007fff", - "0x20680017fff7fff", - "0x41", - "0x1104800180018000", - "0xdb", - "0x482480017fff8000", - "0xda", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007fe5", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007ff37fff", - "0x10780017fff7fff", - "0x24", - "0x4824800180007fe5", - "0x0", - "0x400080007ff47fff", - "0x482480017ff48000", - "0x1", - "0x48127ffe7fff8000", - "0x48127ff17fff8000", - "0x1104800180018000", - "0x7c", - "0x20680017fff7ffd", - "0x11", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0xb6", - "0x48127ff37fff8000", - "0x48127ff37fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017ff18000", - "0x1", - "0x48127fe07fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x99", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff47fff8000", - "0x48127fe37fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ffd7fff8000", - "0x48127fec7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48297ffc80007ffd", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xa", - "0x482680017ffc8000", - "0x1", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x10780017fff7fff", - "0x8", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x20680017fff7ffc", - "0x8", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x0", - "0x480080007ffa8000", - "0x208b7fff7fff7ffe", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x1104800180018000", - "0x4a", - "0x482480017fff8000", - "0x49", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4825800180007ffc", - "0x942", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400280007ffb7fff", - "0x10780017fff7fff", - "0x29", - "0x4825800180007ffc", - "0x942", - "0x400280007ffb7fff", - "0x482680017ffb8000", - "0x1", - "0x20780017fff7ffd", - "0x8", - "0x48127fff7fff8000", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x10780017fff7fff", - "0xd", - "0x48127fff7fff8000", - "0x48127ffd7fff8000", - "0x4825800180007ffd", - "0x1", - "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe2", - "0x20680017fff7ffd", - "0xd", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x48527ffd7ffd8000", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ffb8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x482480017ffa8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 41, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -26 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 61, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 84, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 102, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 116, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 130, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 186, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x942" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -4 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 234, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 0 <= memory[fp + -6]" - ] - ], - [ - 41, - [ - "memory[ap + 0] = 0 <= memory[ap + -26]" - ] - ], - [ - 61, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 84, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 102, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 116, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 130, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 186, - [ - "memory[ap + 0] = 2370 <= memory[fp + -4]" - ] - ], - [ - 234, - [ - "memory[ap + 0] = segments.add()" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x36fbc999025b89d36d31dc2f9c0a03b4377755e1f27e0e42a385aaba90f61a6", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - } -} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/fibonacci.sierra b/starknet_programs/raw_contract_classes/fibonacci.sierra deleted file mode 100644 index 8cd932a4e..000000000 --- a/starknet_programs/raw_contract_classes/fibonacci.sierra +++ /dev/null @@ -1,373 +0,0 @@ -{ - "sierra_program": [ - "0x1", - "0x2", - "0x0", - "0x2", - "0x0", - "0x0", - "0xd5", - "0x2b", - "0x16", - "0x52616e6765436865636b", - "0x0", - "0x4761734275696c74696e", - "0x66656c74323532", - "0x4172726179", - "0x1", - "0x2", - "0x536e617073686f74", - "0x3", - "0x537472756374", - "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", - "0x4", - "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", - "0x456e756d", - "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", - "0x6", - "0x753332", - "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", - "0x4275696c74696e436f737473", - "0x17bc4bcbb517b92736828af382c42b71df97fe5d0a8db42d13069b34a1ddbe9", - "0x14de46c93830b854d231d540339ee8ae16bb18830a375fe81572a472d5945f1", - "0xd", - "0x2f528e3c691e195fca674982b69c0dc4284f206c3ea4d680220e99b59315a92", - "0xc", - "0xe", - "0x5", - "0x19b3b4955bdcfa379bfc5a4949111c4efdd79128f8676f4d0895419b22e2ad7", - "0x10", - "0x53797374656d", - "0x426f78", - "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", - "0x13", - "0x4e6f6e5a65726f", - "0x50", - "0x7265766f6b655f61705f747261636b696e67", - "0x656e61626c655f61705f747261636b696e67", - "0x77697468647261775f676173", - "0x6272616e63685f616c69676e", - "0x73746f72655f74656d70", - "0x66756e6374696f6e5f63616c6c", - "0x656e756d5f6d61746368", - "0x7", - "0x7374727563745f6465636f6e737472756374", - "0x61727261795f6c656e", - "0x736e617073686f745f74616b65", - "0x8", - "0x64726f70", - "0x7533325f636f6e7374", - "0x72656e616d65", - "0x7533325f6571", - "0x7374727563745f636f6e737472756374", - "0x656e756d5f696e6974", - "0x9", - "0x6a756d70", - "0x626f6f6c5f6e6f745f696d706c", - "0x6765745f6275696c74696e5f636f737473", - "0xa", - "0x77697468647261775f6761735f616c6c", - "0x64697361626c655f61705f747261636b696e67", - "0xb", - "0xf", - "0x61727261795f6e6577", - "0x11", - "0x12", - "0x66656c743235325f636f6e7374", - "0x4f7574206f6620676173", - "0x61727261795f617070656e64", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", - "0x61727261795f736e617073686f745f706f705f66726f6e74", - "0x14", - "0x756e626f78", - "0x647570", - "0x66656c743235325f69735f7a65726f", - "0x15", - "0x66656c743235325f616464", - "0x66656c743235325f737562", - "0x122", - "0xffffffffffffffff", - "0xad", - "0x9d", - "0x8c", - "0x7a", - "0x17", - "0x18", - "0x19", - "0x1a", - "0x1b", - "0x1c", - "0x1d", - "0x1e", - "0x1f", - "0x21", - "0x20", - "0x22", - "0x25", - "0x23", - "0x24", - "0x26", - "0x65", - "0x27", - "0x28", - "0x29", - "0x2a", - "0x54", - "0x2b", - "0x2c", - "0x2d", - "0x2e", - "0x2f", - "0x33", - "0x34", - "0x35", - "0x36", - "0x37", - "0x38", - "0x30", - "0x31", - "0x32", - "0x39", - "0x4d", - "0x3a", - "0x3b", - "0x3c", - "0x3d", - "0x3e", - "0x41", - "0x42", - "0x3f", - "0x40", - "0x43", - "0x44", - "0x45", - "0x46", - "0x47", - "0x48", - "0x49", - "0x4a", - "0x4b", - "0x4c", - "0x4e", - "0x4f", - "0x51", - "0x52", - "0x53", - "0x55", - "0x56", - "0x57", - "0x58", - "0x59", - "0x5a", - "0x5d", - "0x5b", - "0x5c", - "0x5e", - "0x5f", - "0x60", - "0x61", - "0x62", - "0x63", - "0x64", - "0x66", - "0x67", - "0x68", - "0x69", - "0x6a", - "0x6b", - "0x6c", - "0x6d", - "0x6e", - "0x6f", - "0x70", - "0x71", - "0x72", - "0x73", - "0x74", - "0x75", - "0x76", - "0x77", - "0x78", - "0x79", - "0x7b", - "0x7c", - "0x7d", - "0x7e", - "0x7f", - "0x80", - "0x81", - "0x82", - "0x83", - "0x84", - "0x85", - "0x86", - "0x87", - "0x88", - "0x89", - "0x8a", - "0x8b", - "0x8d", - "0x8e", - "0x8f", - "0xc3", - "0xc8", - "0xd2", - "0x108", - "0xe9", - "0xfc", - "0x102", - "0xbc", - "0xd9", - "0x118", - "0x11e", - "0xa93", - "0x7060f02090e0d02060a0c060b02070a090606080706060502040203020100", - "0x2090a1502060a07060d02070a1402060a0213100610061202090e02111006", - "0x61e021d19061c061b02090e1a060d02070a190618061702090e090616060d", - "0x60906281a06062702260225022402232207060621100620061f02090e0706", - "0x60631020706302e06062f2e06062d0706062c1a06062b2a06062902060627", - "0x2370607350607340236350606270207350607341006063302322e0606272e", - "0x273c06062f3c06062d3c060633023b023a3906062702381006062f35060629", - "0x706062d0706063e1806062b3d06062907090628070606273c060627060606", - "0x607341c0606331a0606330906062f0906062d09090628090606270706062f", - "0x63316060633070606434207064106073f0607343f0606274006062702073f", - "0x6062702074706073407060646450706411a06062f440706410c0906281906", - "0x62702072a060734070606310706064847060629060747060734470606270c", - "0x3418060633024d06070641024c4b06062f024a0706064906072a0607342a06", - "0x4f06020602024f060202024e1006062706073d0607343d06062702073d0607", - "0x1a0239064f0609060c02024f060209022a1007501a0c074f07060207070202", - "0x4f060209021806513c064f0735062a020c064f060c061002352e074f063906", - "0x9023f06521c064f0719062a021916074f063d061a023d064f062e060c0202", - "0x6534b064f0720062a022040074f0647061a0247064f0616060c02024f0602", - "0x56074f065506390255064f065406350254064f0640062e02024f0602090200", - "0x24f0659063c025a59074f065806390258064f06021802024f0656063c0257", - "0x4f075c5b073d025b064f065b0619025c064f065a0616025b064f0657061602", - "0x64f065d0640025d064f065e063f025e064f06021c02024f06020902025d02", - "0x6400262064f066106470261064f06021c02024f060209020260060220025f", - "0x66463064f076006000260064f066006400260064f065f064b025f064f0662", - "0x570266064f066606560266064f06025502024f0663065402024f0602090265", - "0x64f06025902024f06025802024f060209026b6a07696867074f07661a0c09", - "0x4f0668065c026f064f0667061002024f066d065b026e6d074f066c065a026c", - "0x64b065d0273064f061c065d0272064f063c065d0271064f066e065e027006", - "0x9027a067978064f0777066102777675094f0674737271706f105f0274064f", - "0x665027e7d074f067b0663027c064f060260027b064f0678066202024f0602", - "0x28281074f06807f07670280064f067c0666027f064f067e065d02024f067d", - "0x285064f0684066b02024f0683066a028483074f0681066802024f06820654", - "0x89064f0676065c0288064f067506100287064f0686066d0286064f0685066c", - "0x67602024f060209028b8a89880c068b064f06870675028a064f0607066e02", - "0x75028e064f0607066e028d064f0676065c0279064f06750610028c064f067a", - "0x24f064b066502024f06025802024f06020902228e8d790c0622064f068c06", - "0x65d0290064f060277028f064f06026002024f063c066502024f061c066502", - "0x292064f06916907710269064f0602700291064f06908f076f0290064f0690", - "0x96064f0607066e0295064f066b065c0294064f066a06100293064f06920676", - "0x665065402024f06025802024f06020902979695940c0697064f0693067502", - "0x98064f0607066e02024f063c066502024f061c066502024f064b066502024f", - "0x29c064f060273029b064f06026002024f069a0654029a99074f0698067202", - "0x64f069d9e0771029e064f060270029d064f069c9b076f029c064f069c065d", - "0x4f0699066e0264064f061a065c02a1064f060c061002a0064f069f0676029f", - "0x65402024f06025802024f06020902a3a264a10c06a3064f06a0067502a206", - "0x64f06026002024f063c066502024f061c066502024f0640067402024f0600", - "0x64f06027002a6064f06a5a4076f02a5064f06a5065d02a5064f06027802a4", - "0x61a065c02aa064f060c061002a9064f06a8067602a8064f06a6a7077102a7", - "0x24f06020902adacabaa0c06ad064f06a9067502ac064f0607066e02ab064f", - "0x6026002024f063c066502024f0616067402024f063f065402024f06025802", - "0x6027002b0064f06afae076f02af064f06af065d02af064f06027802ae064f", - "0x65c02b4064f060c061002b3064f06b2067602b2064f06b0b1077102b1064f", - "0x6020902b653b5b40c06b6064f06b306750253064f0607066e02b5064f061a", - "0x7802b7064f06026002024f062e067402024f0618065402024f06025802024f", - "0x7102ba064f06027002b9064f06b8b7076f02b8064f06b8065d02b8064f0602", - "0xbe064f061a065c02bd064f060c061002bc064f06bb067602bb064f06b9ba07", - "0x25802024f06020902c0bfbebd0c06c0064f06bc067502bf064f0607066e02", - "0x64f06c2065d02c2064f06027702c1064f06026002024f0609067402024f06", - "0x6c5067602c5064f06c3c4077102c4064f06027002c3064f06c2c1076f02c2", - "0xc6067502c8064f0607066e02c7064f062a065c0252064f0610061002c6064f", - "0x20c06ca0907074f0706067a0206064f0602062e02c9c8c7520c06c9064f06", - "0x20022a064f061a067d0210064f0607067c021a064f0609067b02024f060209", - "0x4f060c067c0235064f062e067e022e064f06021c02024f0602090202cb0602", - "0x72a06810239064f0639060c0239064f0610066b022a064f0635067d021006", - "0x6800219064f0616067f0216064f063c068202024f060209021806cc3c064f", - "0x24f060209023f1c07063f064f063d0683021c064f0639060c023d064f0619", - "0x247064f0639060c0220064f064006840240064f06021c02024f0618065402", - "0x64f061006560210064f06025502024f060258024b4707064b064f06200683", - "0x3c1a074f061a068502024f06020902393507cd2e2a074f0710060209570210", - "0x24f061a066502024f060209021806ce024f073c0686022a064f062a061002", - "0x219064f062e065c0216064f062a061002024f0607065b02024f060c066502", - "0x60c068502024f0618068702024f0602090202cf060220023d064f0609065d", - "0x100220064f06401a078a0240064f060289021c064f063f090788023f0c074f", - "0x257064f060c065d0256064f0607065e0255064f062e065c0254064f062a06", - "0x2004b47094f06595857565554105f0259064f0620065d0258064f061c065d", - "0x64f06470610025c064f065a066202024f060209025b06d05a064f07000661", - "0x4f065e068c025e064f063d068b023d064f065c065d0219064f064b065c0216", - "0x62615f090662064f065d06790261064f0619065c025f064f06160610025d06", - "0x265064f064b065c0263064f064706100260064f065b068d02024f06020902", - "0x4f0607065b02024f060c066502024f06020902666563090666064f06600679", - "0x5d0268064f0602770267064f06026002024f061a066502024f060906650202", - "0x6c064f066a6b0771026b064f060270026a064f066867076f0268064f066806", - "0x64f066d06790275064f0639065c026e064f06350610026d064f066c068d02", - "0x20c064f06021c0209064f060706076f0207064f0602067f0276756e090676", - "0x602066e0206064f06021c02101a070610064f060c068e021a064f06090666", - "0x2090706023f4006020c1a4006020c1a0907070609064f0606068e0207064f", - "0x100907090707d21a0c090706023d0602090707073c060210d1022a1a071a06", - "0xd4021040074006d30602" - ], - "sierra_program_debug_info": { - "type_names": [], - "libfunc_names": [], - "user_func_names": [] - }, - "contract_class_version": "0.1.0", - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x112e35f48499939272000bd72eb840e502ca4c3aefa8800992e8defb746e0c9", - "function_idx": 0 - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - }, - "abi": [ - { - "type": "impl", - "name": "Fibonacci", - "interface_name": "fibonacci::fibonacci::IFibonacci" - }, - { - "type": "interface", - "name": "fibonacci::fibonacci::IFibonacci", - "items": [ - { - "type": "function", - "name": "fib", - "inputs": [ - { - "name": "a", - "type": "core::felt252" - }, - { - "name": "b", - "type": "core::felt252" - }, - { - "name": "n", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "fibonacci::fibonacci::Fibonacci::Event", - "kind": "enum", - "variants": [] - } - ] -} \ No newline at end of file diff --git a/tests/account_panic.rs b/tests/account_panic.rs deleted file mode 100644 index 195b21d9f..000000000 --- a/tests/account_panic.rs +++ /dev/null @@ -1,117 +0,0 @@ -use std::sync::Arc; - -use cairo_vm::felt::Felt252; -use starknet_in_rust::{ - core::contract_address::compute_casm_class_hash, - definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, - services::api::contract_classes::compiled_class::CompiledClass, - state::{ - cached_state::CachedState, - contract_class_cache::{ContractClassCache, PermanentContractClassCache}, - in_memory_state_reader::InMemoryStateReader, - }, - transaction::{InvokeFunction, Transaction}, - utils::{calculate_sn_keccak, Address}, - CasmContractClass, -}; - -#[test] -fn account_panic() { - let account_data = include_bytes!("../starknet_programs/cairo2/account_panic.casm"); - let contract_data = include_bytes!("../starknet_programs/cairo2/contract_a.casm"); - - let account_contract_class: CasmContractClass = serde_json::from_slice(account_data).unwrap(); - let account_class_hash = compute_casm_class_hash(&account_contract_class) - .unwrap() - .to_be_bytes(); - - let contract_class: CasmContractClass = serde_json::from_slice(contract_data).unwrap(); - let contract_class_hash_felt = compute_casm_class_hash(&contract_class).unwrap(); - let contract_class_hash = contract_class_hash_felt.to_be_bytes(); - - let account_address = Address(1111.into()); - let contract_address = Address(0000.into()); - let nonce = 0.into(); - - let block_context = BlockContext::default(); - - let contract_class_cache = PermanentContractClassCache::default(); - - contract_class_cache.set_contract_class( - account_class_hash, - CompiledClass::Casm(Arc::new(account_contract_class)), - ); - contract_class_cache.set_contract_class( - contract_class_hash, - CompiledClass::Casm(Arc::new(contract_class.clone())), - ); - - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(account_address.clone(), account_class_hash); - state_reader - .address_to_nonce_mut() - .insert(account_address.clone(), nonce); - state_reader - .address_to_class_hash_mut() - .insert(contract_address.clone(), contract_class_hash); - state_reader - .address_to_nonce_mut() - .insert(contract_address, 1.into()); - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"__execute__")); - - // arguments of contract_a contract - // calldata is a Vec of Call, which is - /* - #[derive(Drop, Serde)] - struct Call { - to: ContractAddress, - selector: felt252, - calldata: Array - } - */ - let selector_contract = &contract_class - .entry_points_by_type - .external - .get(0) - .unwrap() - .selector; - // calldata of contract_a is 1 value. - let calldata: Vec<_> = [ - 1.into(), - contract_class_hash_felt, - selector_contract.into(), - 1.into(), - 2.into(), - ] - .to_vec(); - - // set up remaining structures - - let invoke = InvokeFunction::new( - account_address, - Felt252::new(selector), - 0, - TRANSACTION_VERSION.clone(), - calldata, - vec![], - block_context.starknet_os_config().chain_id().clone(), - Some(0.into()), - ) - .unwrap(); - - let tx = Transaction::InvokeFunction(invoke); - let exec_info = tx - .execute(&mut state, &block_context, u128::MAX) - .expect("failed to invoke"); - let call_info = exec_info.call_info.as_ref().unwrap(); - - assert_eq!(exec_info.revert_error, None); - - // 482670963043u128 == 'panic' - assert_eq!(call_info.retdata[0], 482670963043u128.into()); - assert!(call_info.failure_flag); -} diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index c43af7bb6..e4b542843 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -5,8 +5,6 @@ use cairo_vm::{ }; use num_bigint::BigUint; use num_traits::{Num, One, Zero}; -use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; -use starknet_in_rust::utils::calculate_sn_keccak; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ @@ -278,7 +276,7 @@ fn library_call() { let mut resources_manager = ExecutionResourcesManager::default(); let expected_execution_resources = ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 247, + n_steps: 255, #[cfg(feature = "cairo_1_tests")] n_steps: 259, n_memory_holes: 8, @@ -286,7 +284,7 @@ fn library_call() { }; let expected_execution_resources_internal_call = ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 80, + n_steps: 84, #[cfg(feature = "cairo_1_tests")] n_steps: 85, n_memory_holes: 5, @@ -302,7 +300,7 @@ fn library_call() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [5.into()].to_vec(), - execution_resources: Some(expected_execution_resources), + execution_resources: expected_execution_resources, class_hash: Some(class_hash), internal_calls: vec![CallInfo { caller_address: Address(0.into()), @@ -318,7 +316,7 @@ fn library_call() { entry_point_type: Some(EntryPointType::External), calldata: vec![25.into()], retdata: [5.into()].to_vec(), - execution_resources: Some(expected_execution_resources_internal_call), + execution_resources: expected_execution_resources_internal_call, class_hash: Some(lib_class_hash), gas_consumed: 0, ..Default::default() @@ -329,13 +327,13 @@ fn library_call() { storage_read_values: vec![], accessed_storage_keys: HashSet::new(), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 78250, + gas_consumed: 78650, #[cfg(feature = "cairo_1_tests")] gas_consumed: 78980, ..Default::default() }; - assert_eq_sorted!( + assert_eq!( exec_entry_point .execute( &mut state, @@ -361,10 +359,9 @@ fn call_contract_storage_write_read() { let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let get_balance_entrypoint_selector = - &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); - let increase_balance_entrypoint_selector = - &BigUint::from_bytes_be(&calculate_sn_keccak("increase_balance".as_bytes())); + let entrypoints = contract_class.clone().entry_points_by_type; + let get_balance_entrypoint_selector = &entrypoints.external.get(1).unwrap().selector; + let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data let contract_class_cache = PermanentContractClassCache::default(); @@ -745,7 +742,6 @@ fn deploy_cairo1_from_cairo1() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), - CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -846,7 +842,6 @@ fn deploy_cairo0_from_cairo1_without_constructor() { let ret_class_hash = state.get_class_hash_at(&ret_address).unwrap(); let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), - CompiledClass::Sierra(_) => unreachable!(), CompiledClass::Casm(_) => unreachable!(), }; @@ -948,7 +943,6 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), CompiledClass::Casm(_) => unreachable!(), - CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1051,7 +1045,6 @@ fn deploy_cairo0_and_invoke() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), CompiledClass::Casm(_) => unreachable!(), - CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1163,18 +1156,8 @@ fn test_send_message_to_l1_syscall() { payload: vec![555.into(), 666.into()], }]; - #[cfg(not(feature = "cairo_1_tests"))] - let expected_n_steps = 46; - #[cfg(feature = "cairo_1_tests")] - let expected_n_steps = 50; - - #[cfg(not(feature = "cairo_1_tests"))] - let expected_gas_consumed = 9640; - #[cfg(feature = "cairo_1_tests")] - let expected_gas_consumed = 10040; - let expected_execution_resources = ExecutionResources { - n_steps: expected_n_steps, + n_steps: 50, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 2)]), }; @@ -1187,8 +1170,8 @@ fn test_send_message_to_l1_syscall() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), l2_to_l1_messages, - execution_resources: Some(expected_execution_resources), - gas_consumed: expected_gas_consumed, + execution_resources: expected_execution_resources, + gas_consumed: 10040, ..Default::default() }; @@ -1268,18 +1251,8 @@ fn test_get_execution_info() { address.0.clone(), ]; - #[cfg(not(feature = "cairo_1_tests"))] - let expected_n_steps = 213; - #[cfg(feature = "cairo_1_tests")] - let expected_n_steps = 268; - - #[cfg(not(feature = "cairo_1_tests"))] - let expected_gas_consumed = 22980; - #[cfg(feature = "cairo_1_tests")] - let expected_gas_consumed = 28580; - let expected_execution_resources = ExecutionResources { - n_steps: expected_n_steps, + n_steps: 268, n_memory_holes: 4, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 4)]), }; @@ -1292,8 +1265,8 @@ fn test_get_execution_info() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), retdata: expected_ret_data, - execution_resources: Some(expected_execution_resources), - gas_consumed: expected_gas_consumed, + execution_resources: expected_execution_resources, + gas_consumed: 28580, ..Default::default() }; @@ -3071,539 +3044,3 @@ fn keccak_syscall() { assert_eq!(retdata[0], Felt252::one()); } - -#[test] -fn library_call_recursive_50_calls() { - // Create program and entry point types for contract class - #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/square_root_recursive.casm"); - #[cfg(feature = "cairo_1_tests")] - let program_data = include_bytes!("../starknet_programs/cairo1/square_root_recursive.casm"); - - let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let entrypoints = contract_class.clone().entry_points_by_type; - let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - let address = Address(1111.into()); - let class_hash: ClassHash = [1; 32]; - let nonce = Felt252::zero(); - - contract_class_cache - .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(address.clone(), nonce); - - // Add lib contract to the state - - #[cfg(not(feature = "cairo_1_tests"))] - let lib_program_data = include_bytes!("../starknet_programs/cairo2/math_lib.casm"); - #[cfg(feature = "cairo_1_tests")] - let lib_program_data = include_bytes!("../starknet_programs/cairo1/math_lib.casm"); - - let lib_contract_class: CasmContractClass = serde_json::from_slice(lib_program_data).unwrap(); - - let lib_address = Address(1112.into()); - let lib_class_hash: ClassHash = [2; 32]; - let lib_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - lib_class_hash, - CompiledClass::Casm(Arc::new(lib_contract_class)), - ); - state_reader - .address_to_class_hash_mut() - .insert(lib_address.clone(), lib_class_hash); - state_reader - .address_to_nonce_mut() - .insert(lib_address, lib_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - // Create an execution entry point - let calldata = [ - felt_str!("1125899906842624"), - Felt252::from_bytes_be(&lib_class_hash), - Felt252::from(50), - ] - .to_vec(); - let caller_address = Address(0000.into()); - let entry_point_type = EntryPointType::External; - - let exec_entry_point = ExecutionEntryPoint::new( - address, - calldata, - Felt252::new(entrypoint_selector.clone()), - caller_address, - entry_point_type, - Some(CallType::Delegate), - Some(class_hash), - u128::MAX, - ); - - // Execute the entrypoint - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - let mut resources_manager = ExecutionResourcesManager::default(); - let expected_execution_resources_internal_call = ExecutionResources { - #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 80, - #[cfg(feature = "cairo_1_tests")] - n_steps: 85, - n_memory_holes: 5, - builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 7)]), - }; - - let call_info = exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap(); - - assert_eq!(call_info.internal_calls.len(), 50); - assert_eq!( - call_info.internal_calls[0], - CallInfo { - caller_address: Address(0.into()), - call_type: Some(CallType::Delegate), - contract_address: Address(1111.into()), - entry_point_selector: Some( - Felt252::from_str_radix( - "544923964202674311881044083303061611121949089655923191939299897061511784662", - 10, - ) - .unwrap(), - ), - entry_point_type: Some(EntryPointType::External), - calldata: vec![felt_str!("1125899906842624")], - retdata: [felt_str!("33554432")].to_vec(), - execution_resources: Some(expected_execution_resources_internal_call), - class_hash: Some(lib_class_hash), - gas_consumed: 0, - ..Default::default() - } - ); - assert_eq!(call_info.retdata, [1.into()].to_vec()); - assert!(!call_info.failure_flag); -} - -#[test] -fn call_contract_storage_write_read_recursive_50_calls() { - // Create program and entry point types for contract class - #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); - #[cfg(feature = "cairo_1_tests")] - let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); - - let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let get_balance_entrypoint_selector = - &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); - let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( - "increase_balance_recursive".as_bytes(), - )); - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - let address = Address(1111.into()); - let class_hash: ClassHash = [1; 32]; - let nonce = Felt252::zero(); - - contract_class_cache - .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(address.clone(), nonce); - - // Add simple_wallet contract to the state - #[cfg(not(feature = "cairo_1_tests"))] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); - #[cfg(feature = "cairo_1_tests")] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); - - let simple_wallet_contract_class: CasmContractClass = - serde_json::from_slice(simple_wallet_program_data).unwrap(); - let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class - .entry_points_by_type - .constructor - .get(0) - .unwrap() - .selector - .clone(); - - let simple_wallet_address = Address(1112.into()); - let simple_wallet_class_hash: ClassHash = [2; 32]; - let simple_wallet_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - simple_wallet_class_hash, - CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), - ); - state_reader - .address_to_class_hash_mut() - .insert(simple_wallet_address.clone(), simple_wallet_class_hash); - state_reader - .address_to_nonce_mut() - .insert(simple_wallet_address.clone(), simple_wallet_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - - let mut resources_manager = ExecutionResourcesManager::default(); - - let create_execute_extrypoint = |selector: &BigUint, - calldata: Vec, - entry_point_type: EntryPointType, - class_hash: [u8; 32], - address: Address| - -> ExecutionEntryPoint { - ExecutionEntryPoint::new( - address, - calldata, - Felt252::new(selector.clone()), - Address(0000.into()), - entry_point_type, - Some(CallType::Delegate), - Some(class_hash), - u64::MAX.into(), - ) - }; - - // RUN SIMPLE_WALLET CONSTRUCTOR - // Create an execution entry point - let calldata = [25.into()].to_vec(); - let constructor_exec_entry_point = create_execute_extrypoint( - &simple_wallet_constructor_entrypoint_selector, - calldata, - EntryPointType::Constructor, - simple_wallet_class_hash, - simple_wallet_address.clone(), - ); - - // Run constructor entrypoint - constructor_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0.clone()].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); - - // RUN INCREASE_BALANCE - // Create an execution entry point - let calldata = [50.into(), simple_wallet_address.0.clone()].to_vec(); - let increase_balance_entry_point = create_execute_extrypoint( - increase_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run increase_balance entrypoint - let call_info = increase_balance_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap(); - // Check that the recursive function did in fact call the simple_wallet contract 50 times - assert_eq!(call_info.internal_calls.len(), 50); - assert!(!call_info.failure_flag); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address, - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [75.into()]) -} - -#[test] -fn call_contract_storage_write_read_recursive_100_calls() { - // Create program and entry point types for contract class - #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); - #[cfg(feature = "cairo_1_tests")] - let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); - - let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let get_balance_entrypoint_selector = - &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); - let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( - "increase_balance_recursive".as_bytes(), - )); - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - let address = Address(1111.into()); - let class_hash: ClassHash = [1; 32]; - let nonce = Felt252::zero(); - - contract_class_cache - .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(address.clone(), nonce); - - // Add simple_wallet contract to the state - #[cfg(not(feature = "cairo_1_tests"))] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); - #[cfg(feature = "cairo_1_tests")] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); - - let simple_wallet_contract_class: CasmContractClass = - serde_json::from_slice(simple_wallet_program_data).unwrap(); - let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class - .entry_points_by_type - .constructor - .get(0) - .unwrap() - .selector - .clone(); - - let simple_wallet_address = Address(1112.into()); - let simple_wallet_class_hash: ClassHash = [2; 32]; - let simple_wallet_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - simple_wallet_class_hash, - CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), - ); - state_reader - .address_to_class_hash_mut() - .insert(simple_wallet_address.clone(), simple_wallet_class_hash); - state_reader - .address_to_nonce_mut() - .insert(simple_wallet_address.clone(), simple_wallet_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - - let mut resources_manager = ExecutionResourcesManager::default(); - - let create_execute_extrypoint = |selector: &BigUint, - calldata: Vec, - entry_point_type: EntryPointType, - class_hash: [u8; 32], - address: Address| - -> ExecutionEntryPoint { - ExecutionEntryPoint::new( - address, - calldata, - Felt252::new(selector.clone()), - Address(0000.into()), - entry_point_type, - Some(CallType::Delegate), - Some(class_hash), - u64::MAX.into(), - ) - }; - - // RUN SIMPLE_WALLET CONSTRUCTOR - // Create an execution entry point - let calldata = [25.into()].to_vec(); - let constructor_exec_entry_point = create_execute_extrypoint( - &simple_wallet_constructor_entrypoint_selector, - calldata, - EntryPointType::Constructor, - simple_wallet_class_hash, - simple_wallet_address.clone(), - ); - - // Run constructor entrypoint - constructor_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0.clone()].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); - - // RUN INCREASE_BALANCE - // Create an execution entry point - let calldata = [100.into(), simple_wallet_address.0.clone()].to_vec(); - let increase_balance_entry_point = create_execute_extrypoint( - increase_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run increase_balance entrypoint - let call_info = increase_balance_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap(); - // Check that the recursive function did in fact call the simple_wallet contract 50 times - assert_eq!(call_info.internal_calls.len(), 100); - assert!(!call_info.failure_flag); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address, - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) -} diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs deleted file mode 100644 index dfa10b1de..000000000 --- a/tests/cairo_native.rs +++ /dev/null @@ -1,1001 +0,0 @@ -#![cfg(all(feature = "cairo-native", not(feature = "cairo_1_tests")))] - -use crate::CallType::Call; -use cairo_lang_starknet::casm_contract_class::CasmContractEntryPoints; -use cairo_lang_starknet::contract_class::ContractEntryPoints; -use cairo_vm::felt::Felt252; -use num_bigint::BigUint; -use num_traits::One; -use num_traits::Zero; -use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; -use starknet_in_rust::definitions::block_context::BlockContext; -use starknet_in_rust::execution::{Event, OrderedEvent}; -use starknet_in_rust::hash_utils::calculate_contract_address; -use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; -use starknet_in_rust::state::contract_class_cache::ContractClassCache; -use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; -use starknet_in_rust::CasmContractClass; -use starknet_in_rust::EntryPointType::{self, External}; -use starknet_in_rust::{ - definitions::constants::TRANSACTION_VERSION, - execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, - }, - state::cached_state::CachedState, - state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, - utils::{Address, ClassHash}, -}; - -use std::collections::HashSet; -use std::sync::Arc; - -#[test] -fn integration_test_erc20() { - let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/erc20.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - let casm_data = include_bytes!("../starknet_programs/cairo2/erc20.casm"); - let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); - - let native_entrypoints = sierra_contract_class.clone().entry_points_by_type; - let native_constructor_selector = &native_entrypoints.constructor.get(0).unwrap().selector; - - let casm_entrypoints = casm_contract_class.clone().entry_points_by_type; - let casm_constructor_selector = &casm_entrypoints.constructor.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - static NATIVE_CLASS_HASH: ClassHash = [1; 32]; - static CASM_CLASS_HASH: ClassHash = [2; 32]; - - let caller_address = Address(123456789.into()); - - contract_class_cache.set_contract_class( - NATIVE_CLASS_HASH, - CompiledClass::Sierra(Arc::new(sierra_contract_class)), - ); - contract_class_cache.set_contract_class( - CASM_CLASS_HASH, - CompiledClass::Casm(Arc::new(casm_contract_class)), - ); - let mut state_reader = InMemoryStateReader::default(); - let nonce = Felt252::zero(); - - state_reader - .address_to_class_hash_mut() - .insert(caller_address.clone(), CASM_CLASS_HASH); - state_reader - .address_to_nonce_mut() - .insert(caller_address.clone(), nonce); - - // Create state from the state_reader and contract cache. - let state_reader = Arc::new(state_reader); - let mut state_vm = - CachedState::new(state_reader.clone(), Arc::new(contract_class_cache.clone())); - let mut state_native = CachedState::new(state_reader, Arc::new(contract_class_cache)); - - /* - 1 recipient - 2 name - 3 decimals - 4 initial_supply - 5 symbol - */ - let calldata = [ - caller_address.0.clone(), - 2.into(), - 3.into(), - 4.into(), - 5.into(), - ] - .to_vec(); - - let vm_result = execute( - &mut state_vm, - &caller_address, - &caller_address, - casm_constructor_selector, - &calldata, - EntryPointType::Constructor, - &CASM_CLASS_HASH, - ); - - let native_result = execute( - &mut state_native, - &caller_address, - &caller_address, - native_constructor_selector, - &calldata, - EntryPointType::Constructor, - &NATIVE_CLASS_HASH, - ); - - assert_eq!(vm_result.caller_address, caller_address); - assert_eq!(vm_result.call_type, Some(CallType::Delegate)); - assert_eq!(vm_result.contract_address, caller_address); - assert_eq!( - vm_result.entry_point_selector, - Some(Felt252::new(casm_constructor_selector)) - ); - assert_eq!( - vm_result.entry_point_type, - Some(EntryPointType::Constructor) - ); - assert_eq!(vm_result.calldata, calldata); - assert!(!vm_result.failure_flag); - assert_eq!(vm_result.retdata, [].to_vec()); - assert_eq!(vm_result.class_hash, Some(CASM_CLASS_HASH)); - - assert_eq!(native_result.caller_address, caller_address); - assert_eq!(native_result.call_type, Some(CallType::Delegate)); - assert_eq!(native_result.contract_address, caller_address); - assert_eq!( - native_result.entry_point_selector, - Some(Felt252::new(native_constructor_selector)) - ); - assert_eq!( - native_result.entry_point_type, - Some(EntryPointType::Constructor) - ); - assert_eq!(native_result.calldata, calldata); - assert!(!native_result.failure_flag); - assert_eq!(native_result.retdata, [].to_vec()); - assert_eq!(native_result.execution_resources, None); - assert_eq!(native_result.class_hash, Some(NATIVE_CLASS_HASH)); - - assert_eq!(vm_result.events, native_result.events); - assert_eq!( - vm_result.accessed_storage_keys, - native_result.accessed_storage_keys - ); - assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); - assert_eq!(vm_result.gas_consumed, native_result.gas_consumed); - - #[allow(clippy::too_many_arguments)] - fn compare_results( - state_vm: &mut CachedState, - state_native: &mut CachedState, - selector_idx: usize, - native_entrypoints: &ContractEntryPoints, - casm_entrypoints: &CasmContractEntryPoints, - calldata: &[Felt252], - caller_address: &Address, - debug_name: &str, - ) { - let native_selector = &native_entrypoints - .external - .get(selector_idx) - .unwrap() - .selector; - let casm_selector = &casm_entrypoints - .external - .get(selector_idx) - .unwrap() - .selector; - - let vm_result = execute( - state_vm, - caller_address, - caller_address, - casm_selector, - calldata, - EntryPointType::External, - &CASM_CLASS_HASH, - ); - - let native_result = execute( - state_native, - caller_address, - caller_address, - native_selector, - calldata, - EntryPointType::External, - &NATIVE_CLASS_HASH, - ); - - assert_eq!(vm_result.failure_flag, native_result.failure_flag); - assert_eq!(vm_result.retdata, native_result.retdata); - assert_eq!(vm_result.events, native_result.events); - assert_eq!( - vm_result.accessed_storage_keys, - native_result.accessed_storage_keys - ); - assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); - - assert_eq!( - vm_result.gas_consumed, native_result.gas_consumed, - "gas consumed mismatch for {debug_name}", - ); - } - - // --------------- GET TOTAL SUPPLY ----------------- - - compare_results( - &mut state_vm, - &mut state_native, - 5, - &native_entrypoints, - &casm_entrypoints, - &[], - &caller_address, - "get total supply 1", - ); - - // ---------------- GET DECIMALS ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 1, - &native_entrypoints, - &casm_entrypoints, - &[], - &caller_address, - "get decimals 1", - ); - - // ---------------- GET NAME ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 6, - &native_entrypoints, - &casm_entrypoints, - &[], - &caller_address, - "get name", - ); - - // // ---------------- GET SYMBOL ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 7, - &native_entrypoints, - &casm_entrypoints, - &[], - &caller_address, - "get symbol", - ); - - // ---------------- GET BALANCE OF CALLER ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 8, - &native_entrypoints, - &casm_entrypoints, - &[caller_address.0.clone()], - &caller_address, - "get balance of caller", - ); - - // // ---------------- ALLOWANCE OF ADDRESS 1 ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 3, - &native_entrypoints, - &casm_entrypoints, - &[caller_address.0.clone(), 1.into()], - &caller_address, - "get allowance of address 1", - ); - - // // ---------------- INCREASE ALLOWANCE OF ADDRESS 1 by 10_000 ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 2, - &native_entrypoints, - &casm_entrypoints, - &[1.into(), 10_000.into()], - &caller_address, - "increase allowance of address 1 by 10000", - ); - - // ---------------- ALLOWANCE OF ADDRESS 1 ---------------------- - - // Checking again because allowance changed with previous call. - compare_results( - &mut state_vm, - &mut state_native, - 3, - &native_entrypoints, - &casm_entrypoints, - &[caller_address.0.clone(), 1.into()], - &caller_address, - "allowance of address 1 part 2", - ); - - // ---------------- APPROVE ADDRESS 1 TO MAKE TRANSFERS ON BEHALF OF THE CALLER ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 4, - &native_entrypoints, - &casm_entrypoints, - &[1.into(), 5000.into()], - &caller_address, - "approve address 1 to make transfers", - ); - - // ---------------- TRANSFER 3 TOKENS FROM CALLER TO ADDRESS 2 --------- - - compare_results( - &mut state_vm, - &mut state_native, - 0, - &native_entrypoints, - &casm_entrypoints, - &[2.into(), 3.into()], - &caller_address, - "transfer 3 tokens", - ); - - // // ---------------- GET BALANCE OF CALLER ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 8, - &native_entrypoints, - &casm_entrypoints, - &[caller_address.0.clone()], - &caller_address, - "GET BALANCE OF CALLER", - ); - - // // ---------------- GET BALANCE OF ADDRESS 2 ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 8, - &native_entrypoints, - &casm_entrypoints, - &[2.into()], - &caller_address, - "GET BALANCE OF ADDRESS 2", - ); - - // // ---------------- TRANSFER 1 TOKEN FROM CALLER TO ADDRESS 2, CALLED FROM ADDRESS 1 ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 9, - &native_entrypoints, - &casm_entrypoints, - &[1.into(), 2.into(), 1.into()], - &caller_address, - "TRANSFER 1 TOKEN FROM CALLER TO ADDRESS 2, CALLED FROM ADDRESS 1", - ); - - // // ---------------- GET BALANCE OF ADDRESS 2 ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 8, - &native_entrypoints, - &casm_entrypoints, - &[2.into()], - &caller_address, - "GET BALANCE OF ADDRESS 2 part 2", - ); - - // // ---------------- GET BALANCE OF CALLER ---------------------- - - compare_results( - &mut state_vm, - &mut state_native, - 8, - &native_entrypoints, - &casm_entrypoints, - &[caller_address.0.clone()], - &caller_address, - "GET BALANCE OF CALLER last", - ); -} - -#[test] -fn call_contract_test() { - // Caller contract - let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/caller.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Callee contract - let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/callee.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Caller contract entrypoints - let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; - let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; - - // Callee contract entrypoints - let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; - let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - // Caller contract data - let caller_address = Address(1111.into()); - let caller_class_hash: ClassHash = [1; 32]; - let caller_nonce = Felt252::zero(); - - // Callee contract data - let callee_address = Address(1112.into()); - let callee_class_hash: ClassHash = [2; 32]; - let callee_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - caller_class_hash, - CompiledClass::Sierra(Arc::new(caller_contract_class)), - ); - contract_class_cache.set_contract_class( - callee_class_hash, - CompiledClass::Sierra(Arc::new(callee_contract_class)), - ); - - let mut state_reader = InMemoryStateReader::default(); - - // Insert caller contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(caller_address.clone(), caller_class_hash); - state_reader - .address_to_nonce_mut() - .insert(caller_address.clone(), caller_nonce); - - // Insert callee contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(callee_address.clone(), callee_class_hash); - state_reader - .address_to_nonce_mut() - .insert(callee_address.clone(), callee_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let calldata = [fn_selector.into()].to_vec(); - let result = execute( - &mut state, - &caller_address, - &callee_address, - call_contract_selector, - &calldata, - EntryPointType::External, - &caller_class_hash, - ); - - assert_eq!(result.retdata, [Felt252::new(44)]); -} - -#[test] -fn call_echo_contract_test() { - // Caller contract - let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/echo_caller.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Callee contract - let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Caller contract entrypoints - let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; - let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; - - // Callee contract entrypoints - let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; - let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - // Caller contract data - let caller_address = Address(1111.into()); - let caller_class_hash: ClassHash = [1; 32]; - let caller_nonce = Felt252::zero(); - - // Callee contract data - let callee_address = Address(1112.into()); - let callee_class_hash: ClassHash = [2; 32]; - let callee_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - caller_class_hash, - CompiledClass::Sierra(Arc::new(caller_contract_class)), - ); - - contract_class_cache.set_contract_class( - callee_class_hash, - CompiledClass::Sierra(Arc::new(callee_contract_class)), - ); - - let mut state_reader = InMemoryStateReader::default(); - - // Insert caller contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(caller_address.clone(), caller_class_hash); - state_reader - .address_to_nonce_mut() - .insert(caller_address.clone(), caller_nonce); - - // Insert callee contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(callee_address.clone(), callee_class_hash); - state_reader - .address_to_nonce_mut() - .insert(callee_address.clone(), callee_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let calldata = [fn_selector.into(), 99999999.into()].to_vec(); - let result = execute( - &mut state, - &caller_address, - &callee_address, - call_contract_selector, - &calldata, - EntryPointType::External, - &caller_class_hash, - ); - - assert_eq!(result.retdata, [Felt252::new(99999999)]); - assert_eq!(result.gas_consumed, 89110); -} - -#[test] -#[cfg(feature = "cairo-native")] -fn call_events_contract_test() { - // Caller contract - let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/caller.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Callee contract - let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/event_emitter.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Caller contract entrypoints - let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; - let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; - - // Event emmitter contract entrypoints - let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; - let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - // Caller contract data - let caller_address = Address(1111.into()); - let caller_class_hash: ClassHash = [1; 32]; - let caller_nonce = Felt252::zero(); - - // Callee contract data - let callee_address = Address(1112.into()); - let callee_class_hash: ClassHash = [2; 32]; - let callee_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - caller_class_hash, - CompiledClass::Sierra(Arc::new(caller_contract_class)), - ); - - contract_class_cache.set_contract_class( - callee_class_hash, - CompiledClass::Sierra(Arc::new(callee_contract_class)), - ); - - let mut state_reader = InMemoryStateReader::default(); - - // Insert caller contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(caller_address.clone(), caller_class_hash); - state_reader - .address_to_nonce_mut() - .insert(caller_address.clone(), caller_nonce); - - // Insert callee contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(callee_address.clone(), callee_class_hash); - state_reader - .address_to_nonce_mut() - .insert(callee_address.clone(), callee_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let calldata = [fn_selector.into()].to_vec(); - let result = execute( - &mut state, - &caller_address, - &callee_address, - call_contract_selector, - &calldata, - EntryPointType::External, - &caller_class_hash, - ); - - let internal_call = CallInfo { - caller_address: Address(1111.into()), - call_type: Some(Call), - contract_address: Address(1112.into()), - code_address: None, - class_hash: Some([ - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, - ]), - entry_point_selector: Some(fn_selector.into()), - entry_point_type: Some(External), - calldata: Vec::new(), - retdata: vec![1234.into()], - execution_resources: None, - events: vec![OrderedEvent { - order: 0, - keys: vec![110.into()], - data: vec![1.into()], - }], - l2_to_l1_messages: Vec::new(), - storage_read_values: Vec::new(), - accessed_storage_keys: HashSet::new(), - internal_calls: Vec::new(), - gas_consumed: 9640, - failure_flag: false, - }; - - let event = Event { - from_address: Address(1112.into()), - keys: vec![110.into()], - data: vec![1.into()], - }; - - assert_eq!(result.retdata, [1234.into()]); - assert_eq!(result.events, []); - assert_eq_sorted!(result.internal_calls, [internal_call]); - - let sorted_events = result.get_sorted_events().unwrap(); - assert_eq!(sorted_events, vec![event]); -} - -fn execute( - state: &mut CachedState, - caller_address: &Address, - callee_address: &Address, - selector: &BigUint, - calldata: &[Felt252], - entrypoint_type: EntryPointType, - class_hash: &ClassHash, -) -> CallInfo { - let exec_entry_point = ExecutionEntryPoint::new( - (*callee_address).clone(), - calldata.to_vec(), - Felt252::new(selector), - (*caller_address).clone(), - entrypoint_type, - Some(CallType::Delegate), - Some(*class_hash), - u64::MAX.into(), - ); - - // Execute the entrypoint - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - let mut resources_manager = ExecutionResourcesManager::default(); - - exec_entry_point - .execute( - state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap() -} - -fn execute_deploy( - state: &mut CachedState, - caller_address: &Address, - selector: &BigUint, - calldata: &[Felt252], - entrypoint_type: EntryPointType, - class_hash: &ClassHash, -) -> CallInfo { - let exec_entry_point = ExecutionEntryPoint::new( - (*caller_address).clone(), - calldata.to_vec(), - Felt252::new(selector), - (*caller_address).clone(), - entrypoint_type, - Some(CallType::Delegate), - Some(*class_hash), - u64::MAX.into(), - ); - - // Execute the entrypoint - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - let mut resources_manager = ExecutionResourcesManager::default(); - - exec_entry_point - .execute( - state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap() -} - -#[test] -#[cfg(feature = "cairo-native")] -fn deploy_syscall_test() { - // Deployer contract - - let deployer_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/deploy.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Deployee contract - let deployee_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // deployer contract entrypoints - let deployer_entrypoints = deployer_contract_class.clone().entry_points_by_type; - let deploy_contract_selector = &deployer_entrypoints.external.get(0).unwrap().selector; - - // Echo contract entrypoints - let deployee_entrypoints = deployee_contract_class.clone().entry_points_by_type; - let _fn_selector = &deployee_entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - // Deployer contract data - let deployer_address = Address(1111.into()); - let deployer_class_hash: ClassHash = [1; 32]; - let deployer_nonce = Felt252::zero(); - - // Deployee contract data - let deployee_class_hash: ClassHash = Felt252::one().to_be_bytes(); - let _deployee_nonce = Felt252::zero(); - - contract_class_cache.set_contract_class( - deployer_class_hash, - CompiledClass::Sierra(Arc::new(deployer_contract_class)), - ); - - contract_class_cache.set_contract_class( - deployee_class_hash, - CompiledClass::Sierra(Arc::new(deployee_contract_class)), - ); - - let mut state_reader = InMemoryStateReader::default(); - - // Insert deployer contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(deployer_address.clone(), deployer_class_hash); - state_reader - .address_to_nonce_mut() - .insert(deployer_address.clone(), deployer_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let calldata = [Felt252::from_bytes_be(&deployee_class_hash), Felt252::one()].to_vec(); - let result = execute_deploy( - &mut state, - &deployer_address, - deploy_contract_selector, - &calldata, - EntryPointType::External, - &deployer_class_hash, - ); - let expected_deployed_contract_address = Address( - calculate_contract_address( - &Felt252::one(), - &Felt252::from_bytes_be(&deployee_class_hash), - &[100.into()], - deployer_address, - ) - .unwrap(), - ); - - assert_eq!(result.retdata, [expected_deployed_contract_address.0]); - assert_eq!(result.events, []); - assert_eq!(result.internal_calls.len(), 1); - - let sorted_events = result.get_sorted_events().unwrap(); - assert_eq!(sorted_events, vec![]); - assert_eq!(result.failure_flag, false) -} - -#[test] -#[cfg(feature = "cairo-native")] -fn deploy_syscall_address_unavailable_test() { - // Deployer contract - - use starknet_in_rust::utils::felt_to_hash; - let deployer_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/deploy.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // Deployee contract - let deployee_contract_class: cairo_lang_starknet::contract_class::ContractClass = - serde_json::from_str( - std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") - .unwrap() - .as_str(), - ) - .unwrap(); - - // deployer contract entrypoints - let deployer_entrypoints = deployer_contract_class.clone().entry_points_by_type; - let deploy_contract_selector = &deployer_entrypoints.external.get(0).unwrap().selector; - - // Echo contract entrypoints - let deployee_entrypoints = deployee_contract_class.clone().entry_points_by_type; - let _fn_selector = &deployee_entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let contract_class_cache = PermanentContractClassCache::default(); - - // Deployer contract data - let deployer_address = Address(1111.into()); - let deployer_class_hash: ClassHash = [2; 32]; - let deployer_nonce = Felt252::zero(); - - // Deployee contract data - let deployee_class_hash: ClassHash = felt_to_hash(&Felt252::one()); - let deployee_nonce = Felt252::zero(); - let expected_deployed_contract_address = Address( - calculate_contract_address( - &Felt252::one(), - &Felt252::from_bytes_be(&deployee_class_hash), - &[100.into()], - deployer_address.clone(), - ) - .unwrap(), - ); - // Insert contract to be deployed so that its address is taken - let deployee_address = expected_deployed_contract_address; - - contract_class_cache.set_contract_class( - deployer_class_hash, - CompiledClass::Sierra(Arc::new(deployer_contract_class)), - ); - - contract_class_cache.set_contract_class( - deployee_class_hash, - CompiledClass::Sierra(Arc::new(deployee_contract_class)), - ); - - let mut state_reader = InMemoryStateReader::default(); - - // Insert deployer contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(deployer_address.clone(), deployer_class_hash); - state_reader - .address_to_nonce_mut() - .insert(deployer_address.clone(), deployer_nonce); - - // Insert deployee contract info into state reader - state_reader - .address_to_class_hash_mut() - .insert(deployee_address.clone(), deployee_class_hash); - state_reader - .address_to_nonce_mut() - .insert(deployee_address.clone(), deployee_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - let calldata = [Felt252::from_bytes_be(&deployee_class_hash), Felt252::one()].to_vec(); - let result = execute_deploy( - &mut state, - &deployer_address, - deploy_contract_selector, - &calldata, - EntryPointType::External, - &deployer_class_hash, - ); - - assert_eq!( - std::str::from_utf8(&result.retdata[0].to_be_bytes()) - .unwrap() - .trim_start_matches('\0'), - "Result::unwrap failed." - ); - assert_eq!(result.events, []); - assert_eq!(result.failure_flag, true); - assert!(result.internal_calls.is_empty()); -} diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index 98653cd58..747ddca2c 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -95,14 +95,14 @@ fn amm_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 232, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 14), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: vec![Felt252::zero(), Felt252::zero()], @@ -184,14 +184,14 @@ fn amm_add_demo_tokens_test() { entry_point_selector: Some(add_demo_token_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata_add_demo_token.clone(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 393, n_memory_holes: 44, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 20), (HASH_BUILTIN_NAME.to_string(), 8), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys: accessed_storage_keys_add_demo_token, storage_read_values: vec![ @@ -263,14 +263,14 @@ fn amm_get_pool_token_balance() { entry_point_selector: Some(get_pool_balance_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata_get_pool_token_balance.clone(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 84, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 1), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys: accessed_storage_keys_get_pool_token_balance, storage_read_values: vec![10000.into()], @@ -358,14 +358,14 @@ fn amm_swap_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata_swap.clone(), retdata: expected_return, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 820, n_memory_holes: 95, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 41), (HASH_BUILTIN_NAME.to_string(), 14), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: [ @@ -608,14 +608,14 @@ fn amm_get_account_token_balance_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata_get_balance, retdata: expected_return, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 92, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: [10.into()].to_vec(), diff --git a/tests/complex_contracts/amm_contracts/amm_proxy.rs b/tests/complex_contracts/amm_contracts/amm_proxy.rs index 88da2bb2e..df8978826 100644 --- a/tests/complex_contracts/amm_contracts/amm_proxy.rs +++ b/tests/complex_contracts/amm_contracts/amm_proxy.rs @@ -82,14 +82,14 @@ fn amm_proxy_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone()[1..].to_vec(), retdata: [].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 232, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 14), ]), - }), + }, class_hash: Some(contract_class_hash), accessed_storage_keys, storage_read_values: vec![Felt252::zero(), Felt252::zero()], @@ -104,14 +104,14 @@ fn amm_proxy_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 280, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 14), ]), - }), + }, class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -190,14 +190,14 @@ fn amm_proxy_get_pool_token_balance_test() { calldata: calldata.clone()[1..].to_vec(), retdata: [555.into()].to_vec(), storage_read_values: [555.into()].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 84, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 1), ("range_check_builtin".to_string(), 3), ]), - }), + }, class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -211,14 +211,14 @@ fn amm_proxy_get_pool_token_balance_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [555.into()].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 140, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 1), ("range_check_builtin".to_string(), 3), ]), - }), + }, class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -304,14 +304,14 @@ fn amm_proxy_add_demo_token_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone()[1..].to_vec(), storage_read_values: vec![0.into(), 0.into(), 0.into(), 0.into()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 397, n_memory_holes: 42, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 8), ("range_check_builtin".to_string(), 20), ]), - }), + }, class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -324,14 +324,14 @@ fn amm_proxy_add_demo_token_test() { entry_point_selector: Some(amm_proxy_entrypoint_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 445, n_memory_holes: 42, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 8), ("range_check_builtin".to_string(), 20), ]), - }), + }, class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -429,14 +429,14 @@ fn amm_proxy_get_account_token_balance() { calldata: calldata.clone()[1..].to_vec(), retdata: [200.into()].to_vec(), storage_read_values: [200.into()].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 92, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 3), ]), - }), + }, class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -450,14 +450,14 @@ fn amm_proxy_get_account_token_balance() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [200.into()].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 151, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 3), ]), - }), + }, class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -572,14 +572,14 @@ fn amm_proxy_swap() { 1000.into(), ] .to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 826, n_memory_holes: 92, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 14), ("range_check_builtin".to_string(), 41), ]), - }), + }, class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -593,14 +593,14 @@ fn amm_proxy_swap() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_result, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 885, n_memory_holes: 92, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 14), ("range_check_builtin".to_string(), 41), ]), - }), + }, class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() diff --git a/tests/complex_contracts/nft/erc721.rs b/tests/complex_contracts/nft/erc721.rs index de1a8afed..6ae4b4894 100644 --- a/tests/complex_contracts/nft/erc721.rs +++ b/tests/complex_contracts/nft/erc721.rs @@ -143,14 +143,14 @@ fn erc721_balance_of_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result.clone(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 105, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 1), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, @@ -225,14 +225,14 @@ fn erc721_test_owner_of() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result.clone(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 116, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 5), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, @@ -324,14 +324,14 @@ fn erc721_test_get_approved() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 192, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 8), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -426,14 +426,14 @@ fn erc721_test_is_approved_for_all() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 101, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -529,14 +529,14 @@ fn erc721_test_approve() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 332, n_memory_holes: 30, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 13), (HASH_BUILTIN_NAME.to_string(), 6), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -627,14 +627,14 @@ fn erc721_set_approval_for_all() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 154, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }), + }, class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -777,14 +777,14 @@ fn erc721_transfer_from_test() { accessed_storage_keys, storage_read_values: expected_read_values, events: expected_events, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 1131, n_memory_holes: 117, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 53), (HASH_BUILTIN_NAME.to_string(), 16), ]), - }), + }, ..Default::default() }; @@ -868,14 +868,14 @@ fn erc721_transfer_from_and_get_owner_test() { class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 116, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 5), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }), + }, ..Default::default() }; diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index f6330312c..842267831 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -103,7 +103,7 @@ fn internal_deploy_account() { ("n_steps", 3612), ("pedersen_builtin", 23), ("range_check_builtin", 83), - ("l1_gas_usage", 3060) + ("l1_gas_usage", 3672) ] .into_iter() .map(|(k, v)| (k.to_string(), v)) @@ -177,11 +177,11 @@ fn internal_deploy_account_cairo1() { let n_steps; #[cfg(not(feature = "cairo_1_tests"))] { - n_steps = 3921; + n_steps = 3948; } #[cfg(feature = "cairo_1_tests")] { - n_steps = 3937; + n_steps = 3952; } assert_eq!( @@ -195,7 +195,7 @@ fn internal_deploy_account_cairo1() { )), code_address: None, #[cfg(not(feature="cairo_1_tests"))] - gas_consumed: 15540, + gas_consumed: 16440, #[cfg(feature="cairo_1_tests")] gas_consumed: 16770, class_hash: Some([ @@ -212,12 +212,12 @@ fn internal_deploy_account_cairo1() { 2.into() ], retdata: vec![felt_str!("370462705988")], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { #[cfg(not(feature="cairo_1_tests"))] - n_steps: 144, + n_steps: 152, #[cfg(feature="cairo_1_tests")] n_steps: 155, - n_memory_holes: 2, + n_memory_holes: 17, builtin_instance_counter: [ ("range_check_builtin", 2), @@ -225,7 +225,7 @@ fn internal_deploy_account_cairo1() { .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), - }), + }, ..Default::default() }), @@ -242,14 +242,14 @@ fn internal_deploy_account_cairo1() { entry_point_selector: Some(felt_str!("1159040026212278395030414237414753050475174923702621880048416706425641521556")), entry_point_type: Some(EntryPointType::Constructor), #[cfg(not(feature="cairo_1_tests"))] - gas_consumed: 13840, + gas_consumed: 14240, #[cfg(feature="cairo_1_tests")] gas_consumed: 14350, calldata: vec![2.into()], accessed_storage_keys: keys, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { #[cfg(not(feature="cairo_1_tests"))] - n_steps: 88, + n_steps: 92, #[cfg(feature="cairo_1_tests")] n_steps: 93, n_memory_holes: 0, @@ -260,7 +260,7 @@ fn internal_deploy_account_cairo1() { .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), - }), + }, ..Default::default() }), None, @@ -270,7 +270,7 @@ fn internal_deploy_account_cairo1() { ("n_steps", n_steps), ("pedersen_builtin", 23), ("range_check_builtin", 87), - ("l1_gas_usage", 5508) + ("l1_gas_usage", 4896) ] .into_iter() .map(|(k, v)| (k.to_string(), v)) diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index 90ef33054..abad548d8 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -117,10 +117,10 @@ fn integration_test() { calldata, retdata: [144.into()].to_vec(), class_hash: Some(class_hash), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 94, ..Default::default() - }), + }, ..Default::default() }; @@ -211,13 +211,13 @@ fn integration_test_cairo1() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [144.into()].to_vec(), - execution_resources: Some(ExecutionResources { - n_steps: 414, + execution_resources: ExecutionResources { + n_steps: 418, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 15)]), - }), + }, class_hash: Some(class_hash), - gas_consumed: 34820, + gas_consumed: 35220, ..Default::default() }; diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index 6808f16de..c5910b321 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -123,10 +123,10 @@ fn hello_starknet_increase_balance() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 65, ..Default::default() - }), + }, class_hash: Some(class_hash), accessed_storage_keys: expected_accessed_storage_keys, storage_read_values: expected_storage_read_values, diff --git a/tests/internals.rs b/tests/internals.rs index e54d26240..5a7443a92 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -406,10 +406,10 @@ fn expected_validate_call_info( // Entries **not** in blockifier. class_hash: Some(felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH)), call_type: Some(CallType::Call), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 13, ..Default::default() - }), + }, ..Default::default() } @@ -476,14 +476,14 @@ fn expected_fee_transfer_call_info( Felt252::zero(), Felt252::zero(), ], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 529, n_memory_holes: 57, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }), + }, ..Default::default() } } @@ -610,20 +610,6 @@ fn invoke_tx(calldata: Vec, max_fee: u128) -> InvokeFunction { .unwrap() } -fn invoke_tx_with_nonce(calldata: Vec, max_fee: u128, nonce: Felt252) -> InvokeFunction { - InvokeFunction::new( - TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), - EXECUTE_ENTRY_POINT_SELECTOR.clone(), - max_fee, - TRANSACTION_VERSION.clone(), - calldata, - vec![], - StarknetChainId::TestNet.to_felt(), - Some(nonce), - ) - .unwrap() -} - fn expected_fee_transfer_info(fee: u128) -> CallInfo { CallInfo { failure_flag: false, @@ -637,14 +623,14 @@ fn expected_fee_transfer_info(fee: u128) -> CallInfo { entry_point_type: Some(EntryPointType::External), calldata: vec![Felt252::from(4096), Felt252::from(fee), Felt252::zero()], retdata: vec![Felt252::from(1)], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }), + }, l2_to_l1_messages: vec![], internal_calls: vec![], events: vec![OrderedEvent { @@ -701,14 +687,14 @@ fn expected_fib_fee_transfer_info(fee: u128) -> CallInfo { entry_point_type: Some(EntryPointType::External), calldata: vec![Felt252::from(4096), Felt252::from(fee), Felt252::zero()], retdata: vec![Felt252::from(1)], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 21), ("pedersen_builtin".to_string(), 4), ]), - }), + }, l2_to_l1_messages: vec![], internal_calls: vec![], events: vec![OrderedEvent { @@ -722,13 +708,13 @@ fn expected_fib_fee_transfer_info(fee: u128) -> CallInfo { ], }], storage_read_values: vec![ - INITIAL_BALANCE.clone() - Felt252::from(3700), + INITIAL_BALANCE.clone() - Felt252::from(1252), Felt252::zero(), - INITIAL_BALANCE.clone() - Felt252::from(3700), + INITIAL_BALANCE.clone() - Felt252::from(1252), Felt252::zero(), - Felt252::from(3700), + Felt252::from(1252), Felt252::zero(), - Felt252::from(3700), + Felt252::from(1252), Felt252::zero(), ], accessed_storage_keys: HashSet::from([ @@ -771,7 +757,7 @@ fn declare_tx() -> Declare { fn declarev2_tx() -> DeclareV2 { #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/raw_contract_classes/fibonacci.sierra"); + let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.sierra"); #[cfg(feature = "cairo_1_tests")] let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.sierra"); let sierra_contract_class: SierraContractClass = serde_json::from_slice(program_data).unwrap(); @@ -789,7 +775,7 @@ fn declarev2_tx() -> DeclareV2 { nonce: 0.into(), hash_value: 0.into(), compiled_class_hash: casm_class_hash, - sierra_contract_class: Some(sierra_contract_class), + sierra_contract_class, sierra_class_hash, casm_class: casm_class.into(), skip_execute: false, @@ -885,14 +871,14 @@ fn expected_declare_fee_transfer_info(fee: u128) -> CallInfo { ], ]), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }), + }, ..Default::default() } } @@ -968,10 +954,10 @@ fn test_declare_tx() { entry_point_selector: Some(VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone()), entry_point_type: Some(EntryPointType::External), calldata: vec![TEST_EMPTY_CONTRACT_CLASS_HASH.clone()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 12, ..Default::default() - }), + }, ..Default::default() }), None, @@ -1048,7 +1034,7 @@ fn test_declarev2_tx() { ("n_steps".to_string(), 2715), ("range_check_builtin".to_string(), 63), ("pedersen_builtin".to_string(), 15), - ("l1_gas_usage".to_string(), 3672), + ("l1_gas_usage".to_string(), 1224), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); @@ -1069,10 +1055,10 @@ fn test_declarev2_tx() { entry_point_selector: Some(VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone()), entry_point_type: Some(EntryPointType::External), calldata: vec![contract_hash], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 12, ..Default::default() - }), + }, ..Default::default() }), None, @@ -1126,18 +1112,18 @@ fn expected_execute_call_info() -> CallInfo { internal_calls: vec![], contract_address: TEST_CONTRACT_ADDRESS.clone(), code_address: None, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 22, ..Default::default() - }), + }, ..Default::default() }], events: vec![], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 61, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 1)]), - }), + }, ..Default::default() } } @@ -1169,14 +1155,14 @@ fn expected_fib_execute_call_info() -> CallInfo { Felt252::from(0), ], retdata: vec![Felt252::from(42)], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 153, + n_steps: 157, #[cfg(feature = "cairo_1_tests")] n_steps: 160, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 4)]), - }), + }, l2_to_l1_messages: vec![], internal_calls: vec![CallInfo { caller_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), @@ -1192,17 +1178,17 @@ fn expected_fib_execute_call_info() -> CallInfo { contract_address: TEST_FIB_CONTRACT_ADDRESS.clone(), code_address: None, #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 3980, + gas_consumed: 4380, #[cfg(feature = "cairo_1_tests")] gas_consumed: 4710, - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 114, + n_steps: 118, #[cfg(feature = "cairo_1_tests")] n_steps: 121, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 3)]), - }), + }, ..Default::default() }], events: vec![], @@ -1228,11 +1214,11 @@ fn expected_validate_call_info_2() -> CallInfo { Felt252::from(1), Felt252::from(2), ], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 21, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 1)]), - }), + }, ..Default::default() } } @@ -1253,11 +1239,11 @@ fn expected_fib_validate_call_info_2() -> CallInfo { Felt252::from(0), Felt252::from(0), ], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 21, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 1)]), - }), + }, ..Default::default() } } @@ -1287,7 +1273,7 @@ fn expected_fib_transaction_execution_info( let n_steps; #[cfg(not(feature = "cairo_1_tests"))] { - n_steps = 4227; + n_steps = 4231; } #[cfg(feature = "cairo_1_tests")] { @@ -1295,7 +1281,7 @@ fn expected_fib_transaction_execution_info( } let resources = HashMap::from([ ("n_steps".to_string(), n_steps), - ("l1_gas_usage".to_string(), 6732), + ("l1_gas_usage".to_string(), 4896), ("pedersen_builtin".to_string(), 16), ("range_check_builtin".to_string(), 104), ]); @@ -1518,9 +1504,9 @@ fn test_invoke_with_declarev2_tx() { Felt252::from(0), // b Felt252::from(0), // n ]; - let invoke_tx = invoke_tx_with_nonce(calldata, u128::MAX, Felt252::one()); + let invoke_tx = invoke_tx(calldata, u128::MAX); - let expected_gas_consumed = 5551; + let expected_gas_consumed = 4908; let result = invoke_tx .execute(state, block_context, expected_gas_consumed) .unwrap(); @@ -1533,7 +1519,7 @@ fn test_invoke_with_declarev2_tx() { fn test_deploy_account() { let (block_context, mut state) = create_account_tx_test_state().unwrap(); - let expected_fee = 3097; + let expected_fee = 3709; let deploy_account_tx = DeployAccount::new( felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH), @@ -1611,7 +1597,7 @@ fn test_deploy_account() { ("n_steps".to_string(), 3625), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), - ("l1_gas_usage".to_string(), 3060), + ("l1_gas_usage".to_string(), 3672), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); @@ -1758,12 +1744,12 @@ fn test_deploy_account_revert() { ("n_steps".to_string(), 3625), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), - ("l1_gas_usage".to_string(), 3060), + ("l1_gas_usage".to_string(), 3672), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); - assert_eq!(fee, 3097); + assert_eq!(fee, 3709); let mut expected_execution_info = TransactionExecutionInfo::new( None, @@ -1801,7 +1787,7 @@ fn expected_deploy_account_states() -> ( CachedState, CachedState, ) { - let fee = Felt252::from(3097); + let fee = Felt252::from(3709); let mut state_before = CachedState::new( Arc::new(InMemoryStateReader::new( HashMap::from([ @@ -1852,7 +1838,7 @@ fn expected_deploy_account_states() -> ( INITIAL_BALANCE.clone(), ); - let mut state_after = state_before.clone_for_testing(); + let mut state_after = state_before.clone(); // Make the contract cache independent (otherwise tests will fail because the initial state's // cache will not be empty anymore). @@ -2349,19 +2335,19 @@ fn test_library_call_with_declare_v2() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 29680, + gas_consumed: 30080, #[cfg(feature = "cairo_1_tests")] gas_consumed: 30410, calldata: vec![1.into(), 1.into(), 10.into()], retdata: vec![89.into()], // fib(10) - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 364, + n_steps: 368, #[cfg(feature = "cairo_1_tests")] n_steps: 371, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 13)]), - }), + }, ..Default::default() }; @@ -2373,19 +2359,19 @@ fn test_library_call_with_declare_v2() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 111690, + gas_consumed: 112490, #[cfg(feature = "cairo_1_tests")] gas_consumed: 113480, calldata, retdata: vec![89.into()], // fib(10) - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 570, + n_steps: 578, #[cfg(feature = "cairo_1_tests")] n_steps: 587, n_memory_holes: 1, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 16)]), - }), + }, internal_calls: vec![expected_internal_call_info], ..Default::default() }; diff --git a/tests/storage.rs b/tests/storage.rs index 73a092b17..22b87180d 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -120,10 +120,10 @@ fn integration_storage_test() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [42.into()].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 68, ..Default::default() - }), + }, class_hash: Some(class_hash), storage_read_values: vec![0.into(), 42.into()], accessed_storage_keys: expected_accessed_storage_keys, diff --git a/tests/syscalls.rs b/tests/syscalls.rs index e60ecca52..4e96b104f 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -175,7 +175,7 @@ fn test_contract<'a>( assert_eq!(result.calldata, calldata); assert_eq_sorted!(result.retdata, return_data.into()); assert_eq_sorted!(result.internal_calls, internal_calls.into()); - assert_eq!(result.execution_resources, Some(execution_resources)); + assert_eq!(result.execution_resources, execution_resources); assert_eq!(result.gas_consumed, 0); assert!(!result.failure_flag); @@ -217,10 +217,10 @@ fn call_contract_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![21.into(), 2.into()], retdata: vec![42.into()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 24, ..Default::default() - }), + }, ..Default::default() }, CallInfo { @@ -239,10 +239,10 @@ fn call_contract_syscall() { ]] .into_iter() .collect(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 63, ..Default::default() - }), + }, ..Default::default() }, CallInfo { @@ -256,10 +256,10 @@ fn call_contract_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![], retdata: vec![2222.into()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 26, ..Default::default() - }), + }, ..Default::default() }, ], @@ -709,11 +709,11 @@ fn library_call_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![21.into(), 2.into()], retdata: vec![42.into()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 24, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }), + }, ..Default::default() }, CallInfo { @@ -732,11 +732,11 @@ fn library_call_syscall() { ]] .into_iter() .collect(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 63, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }), + }, ..Default::default() }, CallInfo { @@ -750,11 +750,11 @@ fn library_call_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![], retdata: vec![1111.into()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 26, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }), + }, ..Default::default() }, ], @@ -804,10 +804,10 @@ fn library_call_l1_handler_syscall() { .into_iter() .collect(), storage_read_values: vec![0.into()], - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 40, ..Default::default() - }), + }, ..Default::default() }], [], @@ -949,11 +949,11 @@ fn deploy_with_constructor_syscall() { entry_point_selector: Some(entry_point_selector), entry_point_type: Some(EntryPointType::Constructor), calldata: [550.into()].to_vec(), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 40, n_memory_holes: 0, ..Default::default() - }), + }, accessed_storage_keys: HashSet::<[u8; 32]>::from([[ 2, 63, 76, 85, 114, 157, 43, 172, 36, 175, 107, 126, 158, 121, 114, 77, 194, 27, 162, 147, 169, 199, 107, 53, 94, 246, 206, 221, 169, 114, 215, 255, @@ -1030,10 +1030,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![], storage_read_values: vec![0.into()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 40, ..Default::default() - }), + }, ..Default::default() }, // Invoke storage_var_and_constructor.cairo mult_constant function @@ -1055,10 +1055,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![(constructor_constant.clone() * Felt252::new(4))], storage_read_values: vec![constructor_constant.clone()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 52, ..Default::default() - }), + }, ..Default::default() }, // Invoke storage_var_and_constructor.cairo set_constant function @@ -1080,10 +1080,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![], storage_read_values: vec![constructor_constant], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 40, ..Default::default() - }), + }, ..Default::default() }, // Invoke storage_var_and_constructor.cairo get_constant function @@ -1105,10 +1105,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![new_constant.clone()], storage_read_values: vec![new_constant.clone()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: Some(ExecutionResources { + execution_resources: ExecutionResources { n_steps: 46, ..Default::default() - }), + }, ..Default::default() } ], @@ -1219,7 +1219,6 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), - CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1324,7 +1323,6 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), - CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1427,7 +1425,6 @@ fn deploy_cairo1_and_invoke() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), - CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); From 2b9d94fb610fbc662880490ff452c331335ad3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Calv=C3=ADn=20Garc=C3=ADa?= Date: Mon, 13 Nov 2023 22:33:07 +0100 Subject: [PATCH 48/56] Update contract caches (#1117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove `serde_json_pythonic`. (#1047) * Remove `serde_json_pythonic`. * Fix JSON formatter on `deprecated_contract_class.rs`. * Fix hash JSON formatter (non-ascii support). * Add unwrap reasoning comment. * Add debug logging. (#1018) * Add `tracing` and update dependencies. * Configure the example to use tracing logging (and make it work again). * Add tracing logging. * Add error logging. * Fix error logging. * Reduce the amount of spam logged. * Update `README.md`. * Fix `Makefile` dependencies. * Remove `Debug` trait dependency. * Update `Cargo.lock` after merge. * Fix warnings. * Fix formatting. --------- Co-authored-by: Esteve Soler Arderiu * fmt and improvements * Fix skip validate (#1053) * update version * fix skip validation for invoke txs * run fmt * fix clippy suggestion * simplify a bit the execute_tx function variants * Add documentation to transaction/fee module (#889) * added comments to src/transaction/fee.rs * added return and error comments --------- Co-authored-by: fannyguthmann Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Co-authored-by: Juan Bono * Add comments to origin/Document-transactionl1_handler module (#888) * added comments to origin/Document-transactionl1_handler-module * modified comments * Test multi syscall (#687) * create multy syscall * remove the replace syscall, it failed because the contract adress didn't match * added library call_syscall * wip * wip * wip * wip * work in progress * remove .sjon files from starknet_programs * finished implemented all the syscalls * reorder code, create one call to syscall * fix pull bug * Update tests/multi_syscall_test.rs Co-authored-by: Matías Ignacio González * Update starknet_programs/cairo1/multi_syscall_test.cairo Co-authored-by: Matías Ignacio González * Update starknet_programs/cairo1/contract_a.cairo Co-authored-by: Matías Ignacio González * Update tests/multi_syscall_test.rs Co-authored-by: Matías Ignacio González * added test syscall for deploy * make format changes * corrected make clippy error * get_caller_address and get_contract_address return a adress * failed of get_contract_address * failed of get_contract_address * wip * modify the selector entrypoint_selector to be function specific * wip * wip * wip * add input to cairo functions * coorect format problem * wip * wip * wip * remove format problem * Fix sierra class hash calculation (#886) * reproduce bug * use pythonic formatter * rename test * fix test * cargo fmt * Fail with an Err transactions whose calculated fee exceed `max_fee` (#892) * Make tx fail when actual_fee exceeds max_fee * Changed test * Formatting * Fix logic * Leave fail only without charging * Change test * Fix test broken by better fee calc * Fixed test fee * Update fee on test_deploy_account * Remove comment --------- Co-authored-by: Juan Bono * Fix test_get_nonce_at (#910) * Fix test_get_nonce_at * Rely on another contract * fix get_sorted_events bug (#912) * fix get_sorted_events bug * fmt * fix clippy --------- Co-authored-by: Estéfano Bargas * Added documentations to syscalls/deprecated_syscall_handler module (#883) * added comments to file syscalls/deprecated_syscall_handler-module' * Update src/syscalls/deprecated_syscall_handler.rs Co-authored-by: Matías Ignacio González * Update src/syscalls/deprecated_syscall_handler.rs Co-authored-by: Matías Ignacio González --------- Co-authored-by: fannyguthmann Co-authored-by: Juan Bono Co-authored-by: Matías Ignacio González * wip * Modify the tests * fixed clippy errors --------- Co-authored-by: fannyguthmann Co-authored-by: Matías Ignacio González Co-authored-by: SantiagoPittella Co-authored-by: Juan Bono Co-authored-by: Estéfano Bargas * Parse internal calls (#915) * Added comments to core/contract_address module (#900) Co-authored-by: fannyguthmann * Add more transaction tests and fee investigation (#914) * add function for getting tx and refactor tests * improve imports * separe tests into 2 groups * fix test * add comments * format * cargo clippy * add details to every test * add fee discrepancy to test doc * cargo fmt * improve imports * added safety element --------- Co-authored-by: fannyguthmann Co-authored-by: Matías Ignacio González Co-authored-by: SantiagoPittella Co-authored-by: Juan Bono Co-authored-by: Estéfano Bargas Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> * remove transactionalstatereader as it is not needed as-is (#1054) * Fix test (or try to) * Revert "Fix test (or try to)" This reverts commit 423052f341165bb23b473c9231aa68560fb46568. * Implement Clone for CachedState * Fix conflict in Makefile + run clippy-fix * Remove empty line * fmt * Remove unwraps * Add clone_for_testing * Remove clones * Add cairo native (#943) * Added cairo native flag * Added cairo_native as dependency * Partial progress * Progress * Partial progress * Point to newly created branch on cairo native * Use updated version of cairo native and make test pass * Run test with storage_write and storage_read with cairo native * Tidy up code * Start unhardcoding stuff * Handle return values * Tidy up code a little * Added sierra programs cache * Add impl for emit_event and send_l1_message * Fix tests * Install LLVM on CI * Test * Test CI * Fix lint step * Save work in progress * Unhardcode calldata and entry point * Unhardcode more stuff * Fix test * Add basic implementation for call_contract * Add call to get_name to integration test * Make call_contract impl compile * Fix test * Pass the correct amount of builtins for every function * Improve test legibility * Write call_contract test skeleton * Finish writing test, still bugs to fix * implement get_execution_info, make increase_allowance work * More debugging * Basic test for call_contract working * More progress on testing ERC20 * More progress on test * Add caller and callee contracts * Fix call_contract test after merge * Fix callee address in tests * Polish some details * Remove use_cairo_native from TransactionExecutionContext * Write test skeleton * Add test contracts * Fix tests * Readd deleted contracts * Echo contract test passing * Update cairo compiler to version 2.2.0 * Calling another contract with events test is passing * Fix failing tests * Remove internal_calls field TODO in CallInfo returned by native_execute * Add event_emitter contract * Add cairo vm execution to the erc20 test for comparison * Add simple implementation for panics in native execution * Add some documentation in code * Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs * Add event_emitter contract * Remove print * Remove comments * Move native syscall handler to its own file * Add felt decode to string when program panics * Make cairo native an optional dependency behind a feature * Move execution result to cairo native * Add a README section explaining how to setup cairo native * Fix some clippy issues * Fix test compilation * CI test * Revert "CI test" This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d. * CI test * Test * Test * Address comment about multiple cfgs * Remove unnecessary clone * Test * Test * Switch to special workflow for native integration tests * Fix workflow * Fix stuff after merge. * Fix clippy warnings. * Fix after merge. * Fix comments. * Fix `Makefile`. * Remove unused import. * Use transactional state. * update cairo native to llvm 17 and remove nightly requirement * update ci * upd ci * try to fix ci * use ubuntu on native * try to fix ci * not needed? * fix ci * update cairo native * fix nightly usage * try to fix ci * dont need a transactional state reader, simply clone the state reader * try to fix ci * format * fix again * fix if * values * force rebuild * make cache track cairo 2 version to trigger rebuilds * try no restore key * update readme * fix tests on ci * update cairo native commit * fix more tests on ci * fix cairo native interface * try ci without cache * setup rustup home * make param passing to cairo native not obscure * try * try again * remove large packages * remove large dirs * remove android too * polly is needed * needs sudo * fix cov * fix test for now * format * cleanup ci file * use pyenv if available * nightly not needed in readme * add .sierra as generated to gitattributes * fix gitattributes * add casm too --------- Co-authored-by: Javier Chatruc Co-authored-by: Mariano Nicolini Co-authored-by: Esteve Soler Arderiu Co-authored-by: Edgar Luque * add test to check cairo 2 account contract deploy panic failing properly (#1045) * add test for account contract execution with panic * clippy * update cairo native to latest revision, u128 gas, mut self (#1082) Co-authored-by: Juan Bono * Fix `get_execution_info` syscall (#1081) * Mark read-only segments * Move call * Remove debug prints * Remove fn * Add test case * Add comment * Restore newlines * Add function comment * Fix test values * Undo changes to makefile * Undo changes to makefile * clippy * cairo-native: implement testing syscalls (#1084) * cleanup erc20 test (#1087) * Fix `get_onchain_data_segment_length` (#1085) * Fix get_onchain_data_segment_length * Update test values * Update test values * fmt --------- Co-authored-by: Juan Bono * Check that running a declare v1 yields a higher fee than simulating it without validation (#1076) * Reorder DeployAccount::apply * Revert "Reorder DeployAccount::apply" This reverts commit 11b0c39cd9cdd92f5211930e9f36f3840a978ae9. * Add test * Add test * clippy + fmt --------- Co-authored-by: Juan Bono * implement display and debug trait for Address (#1080) * implement display and debug trait for Address * hexa fmt * Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072) * Add recursive library call test * Add test programs * Change base changes * Add recursive test for call_contract * fmt + clippy * Add test for 100 contract calls * clippy + fmt * Update test values --------- Co-authored-by: Juan Bono * Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096) * Fix get_onchain_data_segment_length * Update test values * Update test values * fmt * Fix/Refactor `State::count actual storage changes` (#1086) * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Fix bug in `From for CompiledClass` implementation (#1090) * Fix bug in CompiledClass * Add tests --------- Co-authored-by: Juan Bono * fmt * Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104) * Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Fix get_onchain_data_segment_length * Add StorageChangesCount struct * Update test values * Update test values * fmt * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Add test case with declare * Deserialize Declare transactions * Create blockifier Declare transaction * Fix/Refactor `State::count actual storage changes` (#1086) * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Fix bug in `From for CompiledClass` implementation (#1090) * Fix bug in CompiledClass * Add tests * fetch class hash from the next block in declare tx * Return an error if a class_hash is not declared + add tests for declare tx * Fix error msg * Add support for DeclareV0-1 in sir_tests * Make Sierra class optional in declare v2 + other changes * Add support for DeclareV2 * Uncomment test * fix * Use new_with_sierra_class_hash_and_tx_hash * use CompiledClassHash instead of CompiledClass where applicatble * Handle nonce in declare v2 + run fmt * Set casm class before counting state changes in declare v2 * Changes * Make sierra class hash non-optional * fix + clippy * Use state_reader instead of creating a state to fetch the next block s contract classes * Add removed test * Update test values --------- Co-authored-by: Juan Bono * Execute `L1Handler` transactions using the `RpcState` (#1103) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Fix get_onchain_data_segment_length * Add StorageChangesCount struct * Update test values * Update test values * fmt * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Add test case with declare * Deserialize Declare transactions * Create blockifier Declare transaction * Fix/Refactor `State::count actual storage changes` (#1086) * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089) * Add test case * Fix get_onchain_data_segment_length * Debug setup * Add StorageChangesCount struct * Use StorageChangesCount struct in state method * Fix implicated code * Update doc * Update test values * Rename method for consistency * Add note comment * Remove hardcoded contract address * Remove txt files * Remove dbg prints * Remove dbg prints * Format * Restore blockifier version * Restore tests * Restore newlines * Restore newlines * Remove txt file * fmt * Fix bug in `From for CompiledClass` implementation (#1090) * Fix bug in CompiledClass * Add tests * fetch class hash from the next block in declare tx * Return an error if a class_hash is not declared + add tests for declare tx * Fix error msg * Add support for DeclareV0-1 in sir_tests * Make Sierra class optional in declare v2 + other changes * Add support for DeclareV2 * Uncomment test * fix * Use new_with_sierra_class_hash_and_tx_hash * use CompiledClassHash instead of CompiledClass where applicatble * Handle nonce in declare v2 + run fmt * Set casm class before counting state changes in declare v2 * Changes * Make sierra class hash non-optional * fix + clippy * Use state_reader instead of creating a state to fetch the next block s contract classes * Add removed test * Update test values * Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState * Add L1Handler to blockifier_tests::execute_tx * Add blockifier test case * Add L1Handler to sir_tests::execute_tx * Add one more test case * fmt --------- Co-authored-by: Juan Bono * Added a usage target to makefile (#1069) * Added a usage target to makefile * Fixed typo * Implement `NativeSyscallHandler::deploy` (#1106) * wip * Minor improvements + add test * Improve make clippy * Clippy + fmt * Update error messages * Add failure flag test * Fix typo * Apply suggestions + run formatter * Add llvm setup so we can run clippy with `cairo-native` feature * Fix * Remove todo * Use a proper class_hash * Fix test assertion --------- Co-authored-by: Juan Bono * update cairo native to use gas consumed (#1102) * update cairo native to use gas consumed * gas consumed * update native rev * fix gas consumed * remove comments * fixes --------- Co-authored-by: Juan Bono * Fix cairo-native feature-gated code * clippy --------- Co-authored-by: MrAzteca Co-authored-by: Esteve Soler Arderiu Co-authored-by: juanbono Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com> Co-authored-by: fannyguthmann Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com> Co-authored-by: Matías Ignacio González Co-authored-by: SantiagoPittella Co-authored-by: Estéfano Bargas Co-authored-by: Edgar Co-authored-by: Federica Co-authored-by: ElFantasma Co-authored-by: Javier Chatruc Co-authored-by: Mariano Nicolini Co-authored-by: Esteve Soler Arderiu Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com> Co-authored-by: Iñaki Garay --- .gitattributes | 2 + .github/workflows/rust-tests.yml | 297 +- Cargo.lock | 1276 ++++- Cargo.toml | 39 +- Makefile | 52 +- README.md | 20 +- bench/internals.rs | 8 +- cairo_programs/erc20.sierra | 5012 +++++++++++++++++ cairo_programs/wallet.sierra | 1430 +++++ cli/src/main.rs | 2 +- examples/contract_execution/main.rs | 9 + examples/lru_cache/main.rs | 2 +- fuzzer/src/main.rs | 2 +- rpc_state_reader/Cargo.toml | 2 +- rpc_state_reader/src/lib.rs | 43 +- rpc_state_reader/src/rpc_state.rs | 26 +- rpc_state_reader/src/utils.rs | 20 +- rpc_state_reader/tests/blockifier_tests.rs | 134 +- rpc_state_reader/tests/sir_tests.rs | 223 +- rust-toolchain | 2 +- .../contract_address/casm_contract_address.rs | 12 +- .../deprecated_contract_address.rs | 2 +- .../sierra_contract_address.rs | 77 +- src/core/errors/state_errors.rs | 2 + src/definitions/constants.rs | 8 +- src/execution/execution_entry_point.rs | 254 +- src/execution/gas_usage.rs | 49 +- src/execution/mod.rs | 13 +- src/lib.rs | 140 +- .../api/contract_classes/compiled_class.rs | 3 +- src/state/cached_state.rs | 269 +- src/state/mod.rs | 12 +- src/state/state_api.rs | 27 +- src/state/state_cache.rs | 35 +- .../business_logic_syscall_handler.rs | 137 +- ...precated_business_logic_syscall_handler.rs | 5 +- src/syscalls/deprecated_syscall_handler.rs | 2 +- src/syscalls/mod.rs | 2 + src/syscalls/native_syscall_handler.rs | 576 ++ src/syscalls/syscall_handler.rs | 2 +- src/transaction/declare.rs | 156 +- src/transaction/declare_v2.rs | 58 +- src/transaction/deploy.rs | 23 +- src/transaction/deploy_account.rs | 53 +- src/transaction/error.rs | 2 + src/transaction/fee.rs | 14 +- src/transaction/invoke_function.rs | 33 +- src/transaction/l1_handler.rs | 57 +- src/transaction/mod.rs | 1 + src/transaction/verify_version.rs | 8 +- src/utils.rs | 54 +- .../cairo1/square_root_recursive.cairo | 24 + starknet_programs/cairo1/wallet_wrapper.cairo | 9 + starknet_programs/cairo2/account_panic.cairo | 148 + starknet_programs/cairo2/callee.cairo | 22 + starknet_programs/cairo2/caller.cairo | 19 + starknet_programs/cairo2/deploy.cairo | 8 +- starknet_programs/cairo2/echo.cairo | 17 + starknet_programs/cairo2/echo_caller.cairo | 20 + starknet_programs/cairo2/erc20.cairo | 2 +- starknet_programs/cairo2/event_emitter.cairo | 30 + .../cairo2/hello_world_account.cairo | 2 +- .../cairo2/square_root_recursive.cairo | 37 + starknet_programs/cairo2/wallet_wrapper.cairo | 14 +- ...9bd7409f07591f0a04f539bdf56693eaaf3.sierra | 687 +++ ...46e7e79464ad52ecdad80079ddfe486ca5eef.casm | 1429 +++++ ...171713f0e5229a084989d3894c171c160ace2.casm | 524 ++ ...16c42fa9b87c812dc398e49b57bf77930629f.casm | 1097 ++++ ...4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm | 755 +++ ...fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm | 557 ++ ...f33d879f790e202eb2c4b8622005c12252641.casm | 476 ++ .../raw_contract_classes/fibonacci.sierra | 373 ++ tests/account_panic.rs | 117 + tests/cairo_1_syscalls.rs | 593 +- tests/cairo_native.rs | 1001 ++++ tests/complex_contracts/amm_contracts/amm.rs | 20 +- .../amm_contracts/amm_proxy.rs | 40 +- tests/complex_contracts/nft/erc721.rs | 32 +- tests/deploy_account.rs | 26 +- tests/fibonacci.rs | 12 +- tests/increase_balance.rs | 4 +- tests/internals.rs | 122 +- tests/storage.rs | 4 +- tests/syscalls.rs | 53 +- 84 files changed, 17879 insertions(+), 1082 deletions(-) create mode 100644 .gitattributes create mode 100644 cairo_programs/erc20.sierra create mode 100644 cairo_programs/wallet.sierra create mode 100644 src/syscalls/native_syscall_handler.rs create mode 100644 starknet_programs/cairo1/square_root_recursive.cairo create mode 100644 starknet_programs/cairo2/account_panic.cairo create mode 100644 starknet_programs/cairo2/callee.cairo create mode 100644 starknet_programs/cairo2/caller.cairo create mode 100644 starknet_programs/cairo2/echo.cairo create mode 100644 starknet_programs/cairo2/echo_caller.cairo create mode 100644 starknet_programs/cairo2/event_emitter.cairo create mode 100644 starknet_programs/cairo2/square_root_recursive.cairo create mode 100644 starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra create mode 100644 starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm create mode 100644 starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm create mode 100644 starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm create mode 100644 starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm create mode 100644 starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm create mode 100644 starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm create mode 100644 starknet_programs/raw_contract_classes/fibonacci.sierra create mode 100644 tests/account_panic.rs create mode 100644 tests/cairo_native.rs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..6630a6678 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.sierra linguist-generated +*.casm linguist-generated diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index c1bea663e..52d2dfe0e 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -9,211 +9,121 @@ on: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: 1.70.0 - CAIRO_PROGRAMS_PATH: | - cairo_programs/**/*.casm - cairo_programs/**/*.sierra - cairo_programs/**/*.json - starknet_programs/**/*.casm - starknet_programs/**/*.sierra - starknet_programs/**/*.json - !starknet_programs/raw_contract_classes/* + RUST_TOOLCHAIN: '1.72.1' jobs: - build-programs: - strategy: - matrix: - program-target: [ - compile-cairo, - compile-starknet, - compile-cairo-1-casm, - compile-cairo-1-sierra, - compile-cairo-2-casm, - compile-cairo-2-sierra, - ] - name: Build Cairo programs - runs-on: ubuntu-22.04 + build: + name: Build with release profile + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 + - name: Install Rust $RUST_TOOLCHAIN + uses: dtolnay/rust-toolchain@master with: - fetch-depth: 0 - - - name: Fetch from cache - uses: actions/cache@v3 - id: cache-programs - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: ${{ matrix.program-target }}-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - restore-keys: ${{ matrix.program-target }}-cache- - - # This is not pretty, but we need `make` to see the compiled programs are - # actually newer than the sources, otherwise it will try to rebuild them - - name: Restore timestamps - uses: chetan/git-restore-mtime-action@v1 - + toolchain: $RUST_TOOLCHAIN + components: rustfmt, clippy - name: Python3 Build - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} uses: actions/setup-python@v4 with: python-version: '3.9' cache: 'pip' - - - name: Install deps - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} - run: make deps - - - name: Build programs - if: ${{ steps.cache-programs.outputs.cache-hit != 'true' }} - run: make -j ${{ matrix.program-target }} - - # NOTE: used to reduce the amount of cache steps we need in later jobs - # TODO: remove this cache once the workflow finishes - merge-caches: - name: Merge Cairo programs cache - runs-on: ubuntu-22.04 - needs: build-programs - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Fetch from cache (compile-cairo) - uses: actions/cache/restore@v3 - id: cache-programs - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-starknet) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-starknet-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-1-casm) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-1-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-1-sierra) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-1-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-2-casm) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-2-casm-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-2-sierra) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Fetch from cache (compile-cairo-2-sierra) - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: compile-cairo-2-sierra-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - - - name: Merge caches - uses: actions/cache/save@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - - build: - name: Build with release profile - needs: merge-caches - runs-on: ubuntu-22.04 - steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Checkout - uses: actions/checkout@v3 - - name: Fetch programs - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true + - name: Install deps + run: make deps - name: Build - run: cargo build --release --workspace + run: make build lint: name: Lint with fmt and clippy - needs: merge-caches - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest + env: + MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ + TABLEGEN_170_PREFIX: /usr/lib/llvm-17/ steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - name: Install Rust $RUST_TOOLCHAIN + uses: dtolnay/rust-toolchain@master + with: + toolchain: $RUST_TOOLCHAIN + components: rustfmt, clippy + - name: Python3 Build + uses: actions/setup-python@v4 with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt, clippy + python-version: '3.9' + cache: 'pip' - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Checkout - uses: actions/checkout@v3 - - name: Fetch programs - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - + - name: check and free hdd space left + run: | + echo "Listing 20 largest packages" + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 + df -h + sudo apt-get update + sudo apt-get remove -y '^llvm-.*' + sudo apt-get remove -y 'php.*' + sudo apt-get remove -y '^dotnet-.*' + sudo apt-get remove -y '^temurin-.*' + sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel + sudo apt-get autoremove -y + sudo apt-get clean + df -h + echo "Removing large directories" + # deleting 15GB + sudo rm -rf /usr/share/dotnet/ + sudo rm -rf /usr/local/lib/android + df -h + - name: add llvm deb repository + uses: myci-actions/add-deb-repo@10 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools + - name: Install deps + run: make deps - name: Format run: cargo fmt --all -- --check - name: Run clippy - run: cargo clippy --workspace --all-targets -- -D warnings + run: make clippy tests: env: INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} + MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/ + TABLEGEN_170_PREFIX: /usr/lib/llvm-17/ strategy: fail-fast: false matrix: - target: [ test-cairo-1, test-cairo-2, test-doctests ] + target: [ test-cairo-1, test-cairo-2, test-doctests, test-cairo-native ] name: Run tests - needs: merge-caches - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - name: Install Rust - uses: dtolnay/rust-toolchain@stable + - name: Checkout + uses: actions/checkout@v3 + - name: Install Rust $RUST_TOOLCHAIN + uses: dtolnay/rust-toolchain@master + with: + toolchain: $RUST_TOOLCHAIN + components: rustfmt, clippy + - name: Python3 Build + uses: actions/setup-python@v4 with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt, clippy + python-version: '3.9' + cache: 'pip' - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Checkout - uses: actions/checkout@v3 - - name: Fetch programs - uses: actions/cache/restore@v3 - with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true - + - name: Install deps + run: make deps + - name: Install testing tools # TODO: remove `if` when nextest adds doctests support if: ${{ matrix.target != 'test-doctests' }} @@ -221,28 +131,47 @@ jobs: with: tool: cargo-nextest@0.9.49 + - name: check and free hdd space left + run: | + echo "Listing 20 largest packages" + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 + df -h + sudo apt-get update + sudo apt-get remove -y '^llvm-.*' + sudo apt-get remove -y 'php.*' + sudo apt-get remove -y '^dotnet-.*' + sudo apt-get remove -y '^temurin-.*' + sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel + sudo apt-get autoremove -y + sudo apt-get clean + df -h + echo "Removing large directories" + # deleting 15GB + sudo rm -rf /usr/share/dotnet/ + sudo rm -rf /usr/local/lib/android + df -h + - name: add llvm deb repository + uses: myci-actions/add-deb-repo@10 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools - name: Run tests (${{ matrix.target }}) run: make ${{ matrix.target }} coverage: - needs: merge-caches name: Generate and upload coverage report - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Install Rust - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - - name: Set nightly as default - run: rustup default nightly - - name: Install testing tools - uses: taiki-e/install-action@v2 + - name: Install Rust nightly + uses: dtolnay/rust-toolchain@master with: - tool: cargo-nextest@0.9.49,cargo-llvm-cov + toolchain: nightly - uses: Swatinem/rust-cache@v2 with: @@ -255,13 +184,17 @@ jobs: path: lcov.info key: coverage-cache-${{ github.sha }} - - name: Fetch programs - if: steps.restore-report.outputs.cache-hit != 'true' - uses: actions/cache/restore@v3 + - name: Python3 Build + uses: actions/setup-python@v4 with: - path: ${{ env.CAIRO_PROGRAMS_PATH }} - key: all-programs-cache-${{ hashFiles('cairo_programs/**/*.cairo', 'starknet_programs/**/*.cairo') }} - fail-on-cache-miss: true + python-version: '3.9' + cache: 'pip' + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Install deps + run: make deps - name: Generate coverage report if: steps.restore-report.outputs.cache-hit != 'true' diff --git a/Cargo.lock b/Cargo.lock index c53120744..6d46e8782 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash 0.8.3", - "base64 0.21.3", + "base64 0.21.4", "bitflags 2.4.0", "brotli", "bytes", @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -103,7 +103,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.3", + "socket2 0.5.4", "tokio", "tracing", ] @@ -133,7 +133,7 @@ dependencies = [ "impl-more", "pin-project-lite", "rustls", - "rustls-webpki 0.101.4", + "rustls-webpki", "tokio", "tokio-util", "tracing", @@ -184,7 +184,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2 0.5.3", + "socket2 0.5.4", "time", "url", ] @@ -198,7 +198,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -252,9 +252,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.5" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -295,11 +295,17 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -311,15 +317,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -335,9 +341,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys", @@ -368,7 +374,7 @@ dependencies = [ "derivative", "hashbrown 0.13.2", "itertools 0.10.5", - "num-traits 0.2.16", + "num-traits 0.2.17", "zeroize", ] @@ -386,7 +392,7 @@ dependencies = [ "digest", "itertools 0.10.5", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "paste", "rustc_version", "zeroize", @@ -409,7 +415,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "proc-macro2", "quote", "syn 1.0.109", @@ -479,7 +485,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", ] @@ -512,7 +518,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -545,7 +551,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "base64 0.21.3", + "base64 0.21.4", "bytes", "cfg-if", "cookie", @@ -589,9 +595,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bigdecimal" @@ -601,7 +607,16 @@ checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", + "serde", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ "serde", ] @@ -614,6 +629,52 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.4.0", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.38", + "which", +] + +[[package]] +name = "bindgen" +version = "0.68.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" +dependencies = [ + "bitflags 2.4.0", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.38", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -684,7 +745,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "phf", "serde", "serde_json", @@ -698,9 +759,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.3.4" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -709,9 +770,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "da74e2b81409b1b743f8f0c62cc6254afefb8b8e50bbfe3735550f7aeefa3448" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -719,9 +780,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -731,15 +792,15 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bytestring" @@ -795,7 +856,7 @@ dependencies = [ "lazy_static", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde", ] @@ -808,7 +869,7 @@ dependencies = [ "cairo-lang-utils", "indoc", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "parity-scale-codec", "parity-scale-codec-derive", "schemars", @@ -863,7 +924,7 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "salsa", "smol_str", @@ -890,7 +951,7 @@ checksum = "c35dddbc63b2a4870891cc74498726aa32bfaa518596352f9bb101411cc4c584" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", ] @@ -924,11 +985,11 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "salsa", "smol_str", @@ -949,7 +1010,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "salsa", "smol_str", "unescaper", @@ -983,7 +1044,7 @@ checksum = "170838817fc33ddb65e0a9480526df0b226b148a0fca0a5cd7071be4c6683157" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1032,7 +1093,7 @@ dependencies = [ "keccak", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "salsa", "thiserror", ] @@ -1056,7 +1117,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "salsa", "smol_str", @@ -1076,7 +1137,7 @@ dependencies = [ "lalrpop", "lalrpop-util", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "regex", "salsa", "serde", @@ -1132,7 +1193,7 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", "once_cell", @@ -1158,7 +1219,7 @@ dependencies = [ "itertools 0.11.0", "log", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "thiserror", ] @@ -1204,7 +1265,7 @@ dependencies = [ "log", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "serde", "serde_json", @@ -1223,7 +1284,7 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "num-bigint", - "num-traits 0.2.16", + "num-traits 0.2.17", "salsa", "smol_str", "thiserror", @@ -1246,16 +1307,63 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f974b6e859f0b09c0f13ec8188c96e9e8bbb5da04214f911dbb5bcda67cb812b" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "parity-scale-codec", "schemars", "serde", ] +[[package]] +name = "cairo-native" +version = "0.1.0" +source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" +dependencies = [ + "bumpalo", + "cairo-felt", + "cairo-lang-compiler", + "cairo-lang-defs", + "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-sierra", + "cairo-lang-sierra-ap-change", + "cairo-lang-sierra-gas", + "cairo-lang-sierra-generator", + "cairo-lang-starknet", + "cairo-lang-utils", + "cairo-native-runtime", + "cc", + "clap", + "id-arena", + "itertools 0.11.0", + "lazy_static", + "libc", + "melior", + "mlir-sys", + "num-bigint", + "serde", + "serde_json", + "thiserror", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cairo-native-runtime" +version = "0.1.0" +source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" +dependencies = [ + "cairo-felt", + "cairo-lang-runner", + "libc", + "starknet-crypto 0.6.0", + "starknet-curve 0.4.0", +] + [[package]] name = "cairo-vm" version = "0.8.7" @@ -1265,13 +1373,13 @@ dependencies = [ "anyhow", "ark-ff", "ark-std", - "bincode", + "bincode 2.0.0-rc.3", "bitvec", "cairo-felt", "cairo-lang-casm", "cairo-lang-starknet", "generic-array", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "hex", "keccak", "lazy_static", @@ -1280,7 +1388,7 @@ dependencies = [ "num-bigint", "num-integer", "num-prime", - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", "serde", "serde_json", @@ -1290,6 +1398,12 @@ dependencies = [ "thiserror-no-std", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -1300,6 +1414,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -1308,17 +1431,44 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde", "windows-targets", ] +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cipher" version = "0.4.4" @@ -1329,11 +1479,22 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" -version = "4.4.2" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" +checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" dependencies = [ "clap_builder", "clap_derive", @@ -1341,14 +1502,15 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", + "terminal_size", ] [[package]] @@ -1360,7 +1522,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1386,6 +1548,25 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "comrak" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "482aa5695bca086022be453c700a40c02893f1ba7098a2c88351de55341ae894" +dependencies = [ + "clap", + "entities", + "memchr", + "once_cell", + "regex", + "shell-words", + "slug", + "syntect", + "typed-arena", + "unicode_categories", + "xdg", +] + [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -1418,6 +1599,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -1448,6 +1639,66 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "is-terminal", + "itertools 0.10.5", + "num-traits 0.2.17", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + [[package]] name = "crossbeam-utils" version = "0.8.16" @@ -1465,9 +1716,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array", "subtle", @@ -1486,12 +1737,12 @@ dependencies = [ [[package]] name = "ctor" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" +checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1548,7 +1799,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1570,7 +1821,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1585,6 +1836,19 @@ dependencies = [ "ordered-float", ] +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.1", + "lock_api", + "once_cell", + "parking_lot_core 0.9.8", +] + [[package]] name = "deranged" version = "0.3.8" @@ -1618,6 +1882,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deunicode" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" + [[package]] name = "diff" version = "0.1.13" @@ -1664,9 +1934,9 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dyn-clone" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "either" @@ -1692,6 +1962,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "entities" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca" + [[package]] name = "equivalent" version = "1.0.1" @@ -1700,25 +1976,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "eth-keystore" version = "0.5.0" @@ -1768,11 +2033,21 @@ dependencies = [ "uint", ] +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fixed-hash" @@ -1867,7 +2142,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -1903,7 +2178,7 @@ version = "0.4.0" dependencies = [ "cairo-vm", "honggfuzz", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde_json", "starknet_api", "starknet_in_rust", @@ -1912,9 +2187,9 @@ dependencies = [ [[package]] name = "genco" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6973ce8518068a71d404f428f6a5b563088545546a6bd8f9c0a7f2608149bc8a" +checksum = "c4fd234893ffe9cf5b81224ebb1d21bbe2eeb94d95bac3ea25c97cba7293304d" dependencies = [ "genco-macros", "relative-path", @@ -1923,13 +2198,13 @@ dependencies = [ [[package]] name = "genco-macros" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2c778cf01917d0fbed53900259d6604a421fab4916a2e738856ead9f1d926a" +checksum = "8e1c8cd3de2f32ee05ba2adaa90f8d0c354ffa0adeb2d186978d7ae70e5025e9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] @@ -1973,11 +2248,17 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "good_lp" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7f3b0e0de4e671b6ffc1274b153a9394cb58bf04ee67505b0cb9915513115f" +checksum = "fa124423ded10046a849fa0ae9747c541895557f1af177e0890b09879e7e9e7d" dependencies = [ "fnv", "minilp", @@ -2002,6 +2283,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.12.3" @@ -2022,9 +2309,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ "ahash 0.8.3", "allocator-api2", @@ -2048,9 +2335,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -2067,6 +2354,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + [[package]] name = "honggfuzz" version = "0.5.55" @@ -2268,20 +2564,20 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "serde", ] [[package]] name = "indoc" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "inout" @@ -2385,7 +2681,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax", + "regex-syntax 0.7.5", "string_cache", "term", "tiny-keccak", @@ -2416,37 +2712,67 @@ dependencies = [ "spin", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" + +[[package]] +name = "libloading" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] [[package]] name = "libmimalloc-sys" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25d058a81af0d1c22d7a1c948576bee6d673f7af3c0f35564abd6c81122f513d" +checksum = "3979b5c37ece694f1f5e51e7ecc871fdb0f517ed04ee45f88d15d6d553cb9664" dependencies = [ "cc", "libc", ] [[package]] -name = "linux-raw-sys" -version = "0.4.5" +name = "line-wrap" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" - +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" + [[package]] name = "local-channel" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" +checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" dependencies = [ "futures-core", "futures-sink", - "futures-util", "local-waker", ] @@ -2487,7 +2813,16 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.14.0", + "hashbrown 0.14.1", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", ] [[package]] @@ -2499,11 +2834,41 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "melior" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91ea0e9e00979f692a52fb127a2d352e358535168dece6fd4e7948fd7714db5" +dependencies = [ + "criterion", + "dashmap", + "melior-macro", + "mlir-sys", + "once_cell", +] + +[[package]] +name = "melior-macro" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef4083994160cca85418ff2099183160787db26ab4ef5840bcf73472f678590" +dependencies = [ + "comrak", + "convert_case 0.6.0", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.38", + "tblgen", + "unindent", +] + [[package]] name = "memchr" -version = "2.6.2" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" @@ -2514,11 +2879,20 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "mimalloc" -version = "0.1.38" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972e5f23f6716f62665760b0f4cbf592576a80c7b879ba9beaafc0e558894127" +checksum = "fa01922b5ea280a911e323e4d2fd24b7fe5cc4042e0d2cda3c40775cdc4bdc9c" dependencies = [ "libmimalloc-sys", ] @@ -2566,6 +2940,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "mlir-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5e19a5391ed2759fd9060f538330b9b89191e7b13503d7499a4f9580af6699a" +dependencies = [ + "bindgen 0.68.1", +] + [[package]] name = "ndarray" version = "0.13.1" @@ -2575,7 +2958,7 @@ dependencies = [ "matrixmultiply", "num-complex", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rawpointer", ] @@ -2595,6 +2978,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -2603,7 +2996,7 @@ checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", "serde", ] @@ -2615,7 +3008,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ "autocfg", - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] @@ -2625,7 +3018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] @@ -2636,7 +3029,7 @@ checksum = "64a5fe11d4135c3bcdf3a95b18b194afa9608a5f6ff034f5d857bc9a27fb0119" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] @@ -2651,7 +3044,7 @@ dependencies = [ "num-bigint", "num-integer", "num-modular", - "num-traits 0.2.16", + "num-traits 0.2.17", "rand", ] @@ -2661,23 +3054,23 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "num-traits 0.2.16", + "num-traits 0.2.17", ] [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] [[package]] name = "object" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -2688,6 +3081,28 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "oorandom" version = "11.1.3" @@ -2700,9 +3115,15 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" dependencies = [ - "num-traits 0.2.16", + "num-traits 0.2.17", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parity-scale-codec" version = "3.6.4" @@ -2798,6 +3219,12 @@ dependencies = [ "digest", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2811,7 +3238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.0", + "indexmap 2.0.2", ] [[package]] @@ -2844,7 +3271,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -2889,6 +3316,48 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "plist" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" +dependencies = [ + "base64 0.21.4", + "indexmap 1.9.3", + "line-wrap", + "quick-xml", + "serde", + "time", +] + +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits 0.2.17", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2921,6 +3390,16 @@ dependencies = [ "pretty_assertions", ] +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn 2.0.38", +] + [[package]] name = "primitive-types" version = "0.12.1" @@ -2970,13 +3449,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.33" @@ -3028,6 +3516,26 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -3059,33 +3567,54 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.4" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.1", + "regex-syntax 0.8.0", ] [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.0", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "regex-syntax" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" + [[package]] name = "relative-path" version = "1.9.0" @@ -3094,11 +3623,11 @@ checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" [[package]] name = "reqwest" -version = "0.11.20" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -3120,6 +3649,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-rustls", "tower-service", @@ -3127,7 +3657,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.25.2", + "webpki-roots", "winreg", ] @@ -3217,9 +3747,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ "bitflags 2.4.0", "errno", @@ -3236,7 +3766,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki 0.101.4", + "rustls-webpki", "sct", ] @@ -3246,24 +3776,14 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", ] [[package]] name = "rustls-webpki" -version = "0.100.2" +version = "0.101.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" -dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" dependencies = [ "ring", "untrusted", @@ -3281,6 +3801,12 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "salsa" version = "0.16.1" @@ -3319,11 +3845,20 @@ dependencies = [ "cipher", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schemars" -version = "0.8.13" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" dependencies = [ "dyn-clone", "indexmap 1.9.3", @@ -3334,9 +3869,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.13" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" dependencies = [ "proc-macro2", "quote", @@ -3374,9 +3909,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" @@ -3395,7 +3930,7 @@ checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -3411,9 +3946,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -3474,11 +4009,11 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_json", "serde_with_macros 3.3.0", @@ -3494,7 +4029,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -3506,14 +4041,14 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] name = "sha1" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", @@ -3522,9 +4057,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.7" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -3541,6 +4076,27 @@ dependencies = [ "keccak", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3565,11 +4121,20 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +dependencies = [ + "deunicode", +] + [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smol_str" @@ -3592,9 +4157,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys", @@ -3625,7 +4190,7 @@ checksum = "8fcb61961b91757a9bc2d11549067445b2f921bd957f53710db35449767a1ba3" dependencies = [ "starknet-accounts", "starknet-contract", - "starknet-core", + "starknet-core 0.5.1", "starknet-crypto 0.6.0", "starknet-ff", "starknet-macros", @@ -3640,7 +4205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "111ed887e4db14f0df1f909905e7737e4730770c8ed70997b58a71d5d940daac" dependencies = [ "async-trait", - "starknet-core", + "starknet-core 0.5.1", "starknet-providers", "starknet-signers", "thiserror", @@ -3656,7 +4221,7 @@ dependencies = [ "serde_json", "serde_with 2.3.3", "starknet-accounts", - "starknet-core", + "starknet-core 0.5.1", "starknet-providers", "thiserror", ] @@ -3667,7 +4232,25 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91f89c79b641618de8aa9668d74c6b6634659ceca311c6318a35c025f9d4d969" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", + "flate2", + "hex", + "serde", + "serde_json", + "serde_json_pythonic", + "serde_with 2.3.3", + "sha3", + "starknet-crypto 0.6.0", + "starknet-ff", +] + +[[package]] +name = "starknet-core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14139b1c39bdc2f1e663c12090ff5108fe50ebe62c09e15e32988dfaf445a7e4" +dependencies = [ + "base64 0.21.4", "flate2", "hex", "serde", @@ -3690,7 +4273,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -3710,7 +4293,7 @@ dependencies = [ "hmac", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "rfc6979", "sha2", "starknet-crypto-codegen", @@ -3727,7 +4310,7 @@ checksum = "af6527b845423542c8a16e060ea1bc43f67229848e7cd4c4d80be994a84220ce" dependencies = [ "starknet-curve 0.4.0", "starknet-ff", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -3765,12 +4348,12 @@ dependencies = [ [[package]] name = "starknet-macros" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a5865ee0ed22ade86bdf45e7c09c5641f1c59ccae12c21ecde535b2b6bf64a" +checksum = "ef846b6bb48fc8c3e9a2aa9b5b037414f04a908d9db56493a3ae69a857eb2506" dependencies = [ - "starknet-core", - "syn 2.0.29", + "starknet-core 0.6.1", + "syn 2.0.38", ] [[package]] @@ -3788,7 +4371,7 @@ dependencies = [ "serde", "serde_json", "serde_with 2.3.3", - "starknet-core", + "starknet-core 0.5.1", "thiserror", "url", ] @@ -3804,7 +4387,7 @@ dependencies = [ "clap", "coverage-helper", "mimalloc", - "num-traits 0.2.16", + "num-traits 0.2.17", "serde", "starknet_in_rust", ] @@ -3820,7 +4403,7 @@ dependencies = [ "crypto-bigint", "eth-keystore", "rand", - "starknet-core", + "starknet-core 0.5.1", "starknet-crypto 0.6.0", "thiserror", ] @@ -3849,12 +4432,13 @@ version = "0.4.0" dependencies = [ "anyhow", "assert_matches", - "base64 0.21.3", + "base64 0.21.4", "cairo-lang-casm", "cairo-lang-runner", "cairo-lang-sierra", "cairo-lang-starknet", "cairo-lang-utils", + "cairo-native", "cairo-vm", "coverage-helper", "flate2", @@ -3866,7 +4450,7 @@ dependencies = [ "mimalloc", "num-bigint", "num-integer", - "num-traits 0.2.16", + "num-traits 0.2.17", "once_cell", "pretty_assertions_sorted", "serde", @@ -3877,6 +4461,8 @@ dependencies = [ "starknet-crypto 0.5.1", "starknet_api", "thiserror", + "tracing", + "tracing-subscriber", ] [[package]] @@ -3942,21 +4528,76 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syntect" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" +dependencies = [ + "bincode 1.3.3", + "bitflags 1.3.2", + "fancy-regex", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax 0.7.5", + "serde", + "serde_json", + "thiserror", + "walkdir", + "yaml-rust", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tblgen" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d19c09266feb8b16718d1183044d14703a0b4b59e55ce8beb4d6e21dd066b1b" +dependencies = [ + "bindgen 0.66.1", + "cc", + "paste", + "thiserror", +] + [[package]] name = "tempfile" version = "3.8.0" @@ -3981,59 +4622,69 @@ dependencies = [ "winapi", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys", +] + [[package]] name = "test-case" -version = "3.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a1d6e7bde536b0412f20765b76e921028059adfd1b90d8974d33fd3c91b25df" +checksum = "c8f1e820b7f1d95a0cdbf97a5df9de10e1be731983ab943e56703ac1b8e9d425" dependencies = [ "test-case-macros", ] [[package]] name = "test-case-core" -version = "3.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d10394d5d1e27794f772b6fc854c7e91a2dc26e2cbf807ad523370c2a59c0cee" +checksum = "54c25e2cb8f5fcd7318157634e8838aa6f7e4715c96637f969fabaccd1ef5462" dependencies = [ "cfg-if", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", ] [[package]] name = "test-case-macros" -version = "3.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb9a44b1c6a54c1ba58b152797739dba2a83ca74e18168a68c980eb142f9404" +checksum = "37cfd7bbc88a0104e304229fba519bdc45501a30b760fb72240342f1289ad257" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.38", "test-case-core", ] [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -4056,6 +4707,16 @@ dependencies = [ "thiserror-impl-no-std", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.26" @@ -4093,6 +4754,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -4110,9 +4781,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ "backtrace", "bytes", @@ -4121,7 +4792,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.4", "tokio-macros", "windows-sys", ] @@ -4134,7 +4805,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] @@ -4149,9 +4820,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" dependencies = [ "bytes", "futures-core", @@ -4163,9 +4834,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -4184,11 +4855,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "serde", "serde_spanned", "toml_datetime", @@ -4210,9 +4881,21 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -4220,6 +4903,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -4228,11 +4941,17 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uint" @@ -4263,9 +4982,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -4288,6 +5007,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + [[package]] name = "untrusted" version = "0.7.1" @@ -4296,20 +5027,20 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "ureq" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b11c96ac7ee530603dcdf68ed1557050f374ce55a5a07193ebf8cbc9f8927e9" +checksum = "f5ccd538d4a604753ebc2f17cd9946e89b77bf87f6a8e2309667c6f2e87855e3" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "flate2", "log", "once_cell", "rustls", - "rustls-webpki 0.100.2", + "rustls-webpki", "serde", "serde_json", "url", - "webpki-roots 0.23.1", + "webpki-roots", ] [[package]] @@ -4345,12 +5076,28 @@ dependencies = [ "serde", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -4387,7 +5134,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -4421,7 +5168,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4444,18 +5191,21 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.23.1" +version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.2", -] +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" [[package]] -name = "webpki-roots" -version = "0.25.2" +name = "which" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] [[package]] name = "winapi" @@ -4473,6 +5223,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -4556,9 +5315,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" dependencies = [ "memchr", ] @@ -4582,6 +5341,12 @@ dependencies = [ "tap", ] +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" + [[package]] name = "xshell" version = "0.2.5" @@ -4597,6 +5362,15 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yansi" version = "0.5.1" @@ -4620,7 +5394,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.38", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ccb77a306..c4b08bf43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,54 +15,57 @@ metrics = [] members = ["cli", "fuzzer", "rpc_state_reader"] [workspace.dependencies] +cairo-lang-casm = "2.2.0" +cairo-lang-runner = "2.2.0" +cairo-lang-sierra = "2.2.0" +cairo-lang-starknet = "2.2.0" +cairo-lang-utils = "2.2.0" cairo-vm = { version = "0.8.5", features = ["cairo-1-hints"] } -starknet_api = "0.4.1" num-traits = "0.2.15" starknet = "0.5.0" +starknet_api = "0.4.1" thiserror = "1.0.32" -cairo-lang-starknet = "2.1.0-rc4" -cairo-lang-casm = "2.1.0-rc4" -cairo-lang-runner = "2.1.0-rc4" -cairo-lang-sierra = "2.1.0-rc4" -cairo-lang-utils = "2.1.0-rc4" [dependencies] -cairo-lang-starknet = { workspace = true } +anyhow = "1.0.66" +base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } cairo-lang-casm = { workspace = true } cairo-lang-runner = { workspace = true } cairo-lang-sierra = { workspace = true } +cairo-lang-starknet = { workspace = true } cairo-lang-utils = { workspace = true } +cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "03cd09ba3e51852da2234fb32a74056787abba8e", optional = true } cairo-vm = { workspace = true, features = ["cairo-1-hints"] } +flate2 = "1.0.25" getset = "0.1.2" +hex = "0.4.3" +# TODO: Replace with sha3. We should look how to integrate it correctly to calculate sn_keccak +keccak = "0.1.3" lazy_static = "1.4.0" +mimalloc = { version = "0.1.29", default-features = false, optional = true } num-bigint = { version = "0.4", features = ["serde"] } num-integer = "0.1.45" num-traits = { workspace = true } +once_cell = "1.17.1" +sha3 = "0.10.1" serde = { version = "1.0.152", features = ["derive"] } serde_json = { version = "1.0", features = [ "arbitrary_precision", "raw_value", ] } -sha3 = "0.10.1" -# TODO: Replace with sha3. We should look how to integrate it correctly to calculate sn_keccak -keccak = "0.1.3" +serde_json_pythonic = "0.1.2" +starknet = { workspace = true } starknet_api = { workspace = true } starknet-crypto = "0.5.1" thiserror = { workspace = true } -mimalloc = { version = "0.1.29", default-features = false, optional = true } -hex = "0.4.3" -anyhow = "1.0.66" -once_cell = "1.17.1" -starknet = { workspace = true } -base64 = { version = "0.21.0", default-features = false, features = ["alloc"] } -flate2 = "1.0.25" -serde_json_pythonic = "0.1.2" +tracing = "0.1.37" [dev-dependencies] assert_matches = "1.5.0" coverage-helper = "0.2.0" lru = "0.11.0" pretty_assertions_sorted = "1.2.3" +tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } [[bench]] path = "bench/internals.rs" diff --git a/Makefile b/Makefile index 689a4695b..61183ab26 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \ +.PHONY: usage build check clean clippy compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra \ compile-cairo-2-casm compile-cairo-2-sierra coverage deps test heaptrack check-python-version export PATH:=$(shell pyenv root)/shims:$(PATH) @@ -10,7 +10,6 @@ ifeq ($(OS), Darwin) export LDFLAGS += -L/opt/homebrew/opt/gmp/lib endif - CAIRO_SOURCES=$(wildcard cairo_programs/*.cairo) CAIRO_TARGETS=$(patsubst %.cairo,%.json,$(CAIRO_SOURCES)) CAIRO_ABI_TARGETS=$(patsubst %.cairo,%_abi.json,$(CAIRO_SOURCES)) @@ -28,6 +27,24 @@ STARKNET_SIERRA_COMPILE_CAIRO_1:=cairo1/bin/starknet-sierra-compile STARKNET_COMPILE_CAIRO_2:=cairo2/bin/starknet-compile STARKNET_SIERRA_COMPILE_CAIRO_2:=cairo2/bin/starknet-sierra-compile +usage: + @echo 'Usage:' + @echo ' build: Builds the Rust code' + @echo ' check: Runs cargo check' + @echo ' deps: Installs dependencies' + @echo ' deps-macos: Installs depedencies for MacOS' + @echo ' clean: Cleans all build artifacts' + @echo ' clippy: Runs clippy' + @echo ' test: Runs all tests' + @echo ' test-cairo-1: Runs the Cairo 1 tests' + @echo ' test-cairo-2: Runs the Cairo 2 tests' + @echo ' test-doctests: Runs the doctests' + @echo ' coverage: Runs everything necessary to generate the coverage report' + @echo ' coverage-report: Just generates the coverage report' + @echo ' heaptrack: Runs the heaptrack script' + @echo ' flamegraph: Runs cargo flamegraph' + @echo ' benchmark: Runs the benchmarks scripts' + # # VENV rules. # @@ -98,7 +115,7 @@ CAIRO_2_COMPILED_SIERRA_CONTRACTS:=$(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.ca CAIRO_2_COMPILED_CASM_CONTRACTS:= $(patsubst $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra, $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm, $(CAIRO_2_COMPILED_SIERRA_CONTRACTS)) $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.cairo - $(STARKNET_COMPILE_CAIRO_2) $< $@ + $(STARKNET_COMPILE_CAIRO_2) --single-file $< $@ --replace-ids $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra $(STARKNET_SIERRA_COMPILE_CAIRO_2) --add-pythonic-hints $< $@ @@ -106,8 +123,7 @@ $(CAIRO_2_CONTRACTS_TEST_DIR)/%.casm: $(CAIRO_2_CONTRACTS_TEST_DIR)/%.sierra compile-cairo-2-sierra: $(CAIRO_2_COMPILED_SIERRA_CONTRACTS) compile-cairo-2-casm: $(CAIRO_2_COMPILED_CASM_CONTRACTS) - -CAIRO_2_VERSION=2.0.1 +CAIRO_2_VERSION=2.2.0 cairo-repo-2-dir = cairo2 cairo-repo-2-dir-macos = cairo2-macos @@ -133,20 +149,21 @@ cairo-%-macos.tar: cairo-%.tar: curl -L -o "$@" "https://github.com/starkware-libs/cairo/releases/download/v$*/release-x86_64-unknown-linux-musl.tar.gz" - # ================= # Normal rules. # ================= -build: compile-cairo compile-starknet +build: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo build --release --workspace -check: compile-cairo compile-starknet +check: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo check --workspace --all-targets deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler cargo install flamegraph --version 0.6.2 cargo install cargo-llvm-cov --version 0.5.14 + -pyenv && pyenv install -s pypy3.9-7.3.9 + -pyenv && pyenv install -s 3.9.15 python3.9 -m venv starknet-venv . starknet-venv/bin/activate && $(MAKE) deps-venv cargo install cargo-nextest --version 0.9.49 @@ -154,6 +171,8 @@ deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-compiler-macos cargo install flamegraph --version 0.6.2 cargo install cargo-llvm-cov --version 0.5.14 + -pyenv install -s pypy3.9-7.3.9 + -pyenv install -s 3.9.15 python3.9 -m venv starknet-venv . starknet-venv/bin/activate && $(MAKE) deps-venv cargo install cargo-nextest @@ -173,8 +192,8 @@ clean: -rm -rf cairo2/ -rm -rf cairo-*.tar -clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm - cargo clippy --workspace --all-targets -- -D warnings +clippy: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo clippy --workspace --all-targets --all-features -- -D warnings test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra echo "Cairo1 tests" @@ -182,11 +201,14 @@ test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra echo "Cairo2 tests" $(MAKE) test-cairo-2 -test-cairo-1: - cargo nextest run --workspace --all-targets --features=cairo_1_tests +test-cairo-1: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo nextest run --workspace --all-targets --features=cairo_1_tests,metrics + +test-cairo-2: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo nextest run --workspace --all-targets --features=metrics -test-cairo-2: - cargo nextest run --workspace --all-targets +test-cairo-native: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra + cargo nextest run --workspace --test cairo_native --features=cairo-native test-doctests: cargo test --workspace --doc @@ -194,7 +216,7 @@ test-doctests: coverage: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-2-casm $(MAKE) coverage-report -coverage-report: +coverage-report: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo +nightly llvm-cov nextest --lcov --ignore-filename-regex 'main.rs' --output-path lcov.info --release heaptrack: diff --git a/README.md b/README.md index b90b9f1e5..43ce64184 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ It makes use of [cairo-vm](https://github.com/lambdaclass/cairo-vm), the Rust im ### Installation +If you run `make` on it's own it will print out the main targets and their description. + Run the following make targets to have a working environment (if in Mac or if you encounter an error, see the subsection below): #### Linux (x86-64) @@ -98,7 +100,19 @@ In Mac you'll also need to tell the script where to find the gmp lib: export CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib ``` +### Cairo Native support + +Starknet in Rust can be integrated with [Cairo Native](https://github.com/lambdaclass/cairo_native), which makes the execution of sierra programs possible through native machine code. To use it, the following needs to be setup: + +- LLVM `17` needs to be installed and the `MLIR_SYS_170_PREFIX` and `TABLEGEN_170_PREFIX` environment variable needs to point to said installation. In macOS, run + ``` + brew install llvm@17 + export MLIR_SYS_170_PREFIX=/opt/homebrew/opt/llvm@17 + export TABLEGEN_170_PREFIX=/opt/homebrew/opt/llvm@17 + ``` + and you're set. +Afterwards, compiling with the feature flag `cairo-native` will enable native execution. You can check out some example test code that uses it under `tests/cairo_native.rs`. ## 🚀 Usage @@ -109,7 +123,6 @@ You can find a tutorial on running contracts [here](/examples/contract_execution ### Using the CLI You can find an example on how to use the CLI [here](/docs/CLI_USAGE_EXAMPLE.md) - ### Customization #### Contract class cache behavior @@ -153,6 +166,11 @@ cache.extend(state1.state.drain_private_contract_class_cache()); cache.extend(state2.state.drain_private_contract_class_cache()); ``` +#### Logging configuration + +This project uses the [`tracing`](https://crates.io/crates/tracing) crate as a library. Check out +its documentation for more information. + ### Testing [Add an Infura API key.](#rpc-state-reader) diff --git a/bench/internals.rs b/bench/internals.rs index abb10cd2e..bc64f8075 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -81,7 +81,7 @@ fn deploy_account() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut state_copy = state.clone(); + let mut state_copy = state.clone_for_testing(); let class_hash = *CLASS_HASH_BYTES; let signature = SIGNATURE.clone(); scope(|| { @@ -116,7 +116,7 @@ fn declare() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut cloned_state = state.clone(); + let mut cloned_state = state.clone_for_testing(); let class = CONTRACT_CLASS.clone(); let address = CONTRACT_ADDRESS.clone(); scope(|| { @@ -158,7 +158,7 @@ fn deploy() { let block_context = &Default::default(); for _ in 0..RUNS { - let mut state_copy = state.clone(); + let mut state_copy = state.clone_for_testing(); let salt = felt_str!( "2669425616857739096022668060305620640217901643963991674344872184515580705509" ); @@ -213,7 +213,7 @@ fn invoke() { let _deploy_exec_info = deploy.execute(&mut state, block_context).unwrap(); for _ in 0..RUNS { - let mut state_copy = state.clone(); + let mut state_copy = state.clone_for_testing(); let address = CONTRACT_ADDRESS.clone(); let selector = VALIDATE_ENTRY_POINT_SELECTOR.clone(); let signature = SIGNATURE.clone(); diff --git a/cairo_programs/erc20.sierra b/cairo_programs/erc20.sierra new file mode 100644 index 000000000..d7a57bf24 --- /dev/null +++ b/cairo_programs/erc20.sierra @@ -0,0 +1,5012 @@ +type RangeCheck = RangeCheck; +type GasBuiltin = GasBuiltin; +type felt252 = felt252; +type Array = Array; +type Snapshot> = Snapshot>; +type core::array::Span:: = Struct>>; +type u32 = u32; +type core::panics::Panic = Struct; +type Tuple> = Struct>; +type Tuple> = Struct>; +type core::panics::PanicResult::<(core::array::Span::,)> = Enum>, Tuple>>; +type System = System; +type BuiltinCosts = BuiltinCosts; +type erc20::erc20::erc_20::name::ContractState = Struct; +type erc20::erc20::erc_20::symbol::ContractState = Struct; +type erc20::erc20::erc_20::decimals::ContractState = Struct; +type erc20::erc20::erc_20::total_supply::ContractState = Struct; +type erc20::erc20::erc_20::balances::ContractState = Struct; +type erc20::erc20::erc_20::allowances::ContractState = Struct; +type erc20::erc20::erc_20::ContractState = Struct; +type Tuple = Struct; +type core::panics::PanicResult::<(core::felt252,)> = Enum, Tuple>>; +type Unit = Struct; +type u8 = u8; +type Tuple = Struct; +type core::panics::PanicResult::<(core::integer::u8,)> = Enum, Tuple>>; +type u128 = u128; +type core::integer::u256 = Struct; +type Tuple = Struct; +type core::panics::PanicResult::<(core::integer::u256,)> = Enum, Tuple>>; +type ContractAddress = ContractAddress; +type core::option::Option:: = Enum; +type Pedersen = Pedersen; +type core::option::Option:: = Enum; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())> = Enum, Tuple>>; +type core::option::Option:: = Enum; +type core::option::Option:: = Enum; +type Tuple = Struct; +type core::option::Option:: = Enum; +type Tuple = Struct; +type core::panics::PanicResult::<(core::starknet::contract_address::ContractAddress,)> = Enum, Tuple>>; +type Box = Box; +type core::option::Option::> = Enum, Unit>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::name::ContractState, ())> = Enum, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::symbol::ContractState, ())> = Enum, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::decimals::ContractState, ())> = Enum, Tuple>>; +type NonZero = NonZero; +type core::bool = Enum; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::total_supply::ContractState, ())> = Enum, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::balances::ContractState, ())> = Enum, Tuple>>; +type erc20::erc20::erc_20::Transfer = Struct; +type erc20::erc20::erc_20::Approval = Struct; +type erc20::erc20::erc_20::Event = Enum; +type StorageBaseAddress = StorageBaseAddress; +type StorageAddress = StorageAddress; +type core::result::Result::> = Enum>; +type core::result::Result::> = Enum>; +type Tuple>> = Struct>>; +type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; +type core::result::Result::> = Enum>; +type Tuple>> = Struct>>; +type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; +type u64 = u64; +type core::starknet::info::BlockInfo = Struct; +type Box = Box; +type core::starknet::info::TxInfo = Struct, felt252, felt252, felt252>; +type Box = Box; +type core::starknet::info::ExecutionInfo = Struct, Box, ContractAddress, ContractAddress, felt252>; +type Box = Box; +type Tuple> = Struct>; +type core::panics::PanicResult::<(core::box::Box::,)> = Enum>, Tuple>>; +type Tuple = Struct; +type core::panics::PanicResult::<(erc20::erc20::erc_20::allowances::ContractState, ())> = Enum, Tuple>>; +type core::result::Result::<(), core::array::Array::> = Enum>; +type Tuple = Struct; +type core::panics::PanicResult::<((),)> = Enum, Tuple>>; +type core::result::Result::> = Enum>; +type Tuple>> = Struct>>; +type core::panics::PanicResult::<(core::result::Result::>,)> = Enum>>, Tuple>>; +type core::result::Result::, core::array::Array::> = Enum, Array>; +type Tuple = Struct; +type Tuple = Struct; + +libfunc revoke_ap_tracking = revoke_ap_tracking; +libfunc withdraw_gas = withdraw_gas; +libfunc branch_align = branch_align; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc array_len = array_len; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc u32_const<0> = u32_const<0>; +libfunc rename = rename; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc u32_eq = u32_eq; +libfunc array_new = array_new; +libfunc felt252_const<7733229381460288120802334208475838166080759535023995805565484692595> = felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>; +libfunc store_temp = store_temp; +libfunc array_append = array_append; +libfunc struct_construct = struct_construct; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 1> = enum_init,)>, 1>; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc store_temp,)>> = store_temp,)>>; +libfunc get_builtin_costs = get_builtin_costs; +libfunc store_temp = store_temp; +libfunc withdraw_gas_all = withdraw_gas_all; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc struct_construct = struct_construct; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp> = store_temp>; +libfunc function_call = function_call; +libfunc drop = drop; +libfunc snapshot_take> = snapshot_take>; +libfunc drop> = drop>; +libfunc struct_construct> = struct_construct>; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 0> = enum_init,)>, 0>; +libfunc felt252_const<375233589013918064796019> = felt252_const<375233589013918064796019>; +libfunc drop> = drop>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc store_temp> = store_temp>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc drop> = drop>; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917>; +libfunc felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916> = felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916>; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop = drop; +libfunc drop = drop; +libfunc drop = drop; +libfunc drop = drop; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc rename = rename; +libfunc struct_construct = struct_construct; +libfunc store_temp = store_temp; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc rename = rename; +libfunc u8_to_felt252 = u8_to_felt252; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop = drop; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc rename> = rename>; +libfunc rename = rename; +libfunc contract_address_try_from_felt252 = contract_address_try_from_felt252; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc store_temp = store_temp; +libfunc store_temp> = store_temp>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_construct = struct_construct; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc function_call = function_call; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc dup = dup; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc snapshot_take = snapshot_take; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc array_snapshot_pop_front = array_snapshot_pop_front; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc store_temp>> = store_temp>>; +libfunc jump = jump; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc enum_match>> = enum_match>>; +libfunc unbox = unbox; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc contract_address_to_felt252 = contract_address_to_felt252; +libfunc felt252_const<0> = felt252_const<0>; +libfunc felt252_sub = felt252_sub; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc felt252_is_zero = felt252_is_zero; +libfunc enum_init = enum_init; +libfunc store_temp = store_temp; +libfunc drop> = drop>; +libfunc enum_init = enum_init; +libfunc bool_not_impl = bool_not_impl; +libfunc enum_match = enum_match; +libfunc felt252_const<7300388948442106731950660484798539862217172507820428101544021685107> = felt252_const<7300388948442106731950660484798539862217172507820428101544021685107>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc contract_address_const<0> = contract_address_const<0>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct = struct_construct; +libfunc enum_init = enum_init; +libfunc store_temp = store_temp; +libfunc function_call>> = function_call>>; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336> = storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>; +libfunc storage_address_from_base = storage_address_from_base; +libfunc store_temp = store_temp; +libfunc storage_read_syscall = storage_read_syscall; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc rename>> = rename>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028> = storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>; +libfunc storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321> = storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>; +libfunc store_temp = store_temp; +libfunc function_call = function_call; +libfunc enum_match>,)>> = enum_match>,)>>; +libfunc struct_deconstruct>>> = struct_deconstruct>>>; +libfunc store_temp>> = store_temp>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646> = storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>; +libfunc function_call = function_call; +libfunc enum_match>,)>> = enum_match>,)>>; +libfunc struct_deconstruct>>> = struct_deconstruct>>>; +libfunc store_temp>> = store_temp>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc rename = rename; +libfunc u128_to_felt252 = u128_to_felt252; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc enum_match,)>> = enum_match,)>>; +libfunc struct_deconstruct>> = struct_deconstruct>>; +libfunc unbox = unbox; +libfunc struct_deconstruct = struct_deconstruct; +libfunc drop> = drop>; +libfunc drop> = drop>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc felt252_const<25936191677694277552149992725516921697451103245639728> = felt252_const<25936191677694277552149992725516921697451103245639728>; +libfunc felt252_const<395754877894504967531585582359572169455970492464> = felt252_const<395754877894504967531585582359572169455970492464>; +libfunc snapshot_take = snapshot_take; +libfunc store_temp = store_temp; +libfunc function_call> = function_call>; +libfunc u128_const<340282366920938463463374607431768211455> = u128_const<340282366920938463463374607431768211455>; +libfunc snapshot_take = snapshot_take; +libfunc u128_eq = u128_eq; +libfunc felt252_const<101313248740993271302566317381896466254801065025584> = felt252_const<101313248740993271302566317381896466254801065025584>; +libfunc function_call = function_call; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct = struct_construct; +libfunc store_temp = store_temp; +libfunc function_call> = function_call>; +libfunc function_call = function_call; +libfunc felt252_const<39879774624079483812136948410799859986295> = felt252_const<39879774624079483812136948410799859986295>; +libfunc function_call = function_call; +libfunc felt252_const<39879774624085075084607933104993585622903> = felt252_const<39879774624085075084607933104993585622903>; +libfunc u8_try_from_felt252 = u8_try_from_felt252; +libfunc rename = rename; +libfunc rename> = rename>; +libfunc snapshot_take = snapshot_take; +libfunc storage_write_syscall = storage_write_syscall; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc store_temp>> = store_temp>>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc rename>> = rename>>; +libfunc function_call::unwrap_syscall> = function_call::unwrap_syscall>; +libfunc enum_match> = enum_match>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc snapshot_take = snapshot_take; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc snapshot_take = snapshot_take; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc snapshot_take = snapshot_take; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call::into> = function_call::into>; +libfunc snapshot_take = snapshot_take; +libfunc drop = drop; +libfunc function_call = function_call; +libfunc emit_event_syscall = emit_event_syscall; +libfunc enum_match>> = enum_match>>; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct>>> = struct_construct>>>; +libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; +libfunc store_temp>,)>> = store_temp>,)>>; +libfunc felt252_const<110930490496575599150170734222081291576> = felt252_const<110930490496575599150170734222081291576>; +libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc enum_match>> = enum_match>>; +libfunc dup = dup; +libfunc dup = dup; +libfunc function_call = function_call; +libfunc enum_match>,)>> = enum_match>,)>>; +libfunc struct_deconstruct>>> = struct_deconstruct>>>; +libfunc enum_match>> = enum_match>>; +libfunc u8_const<1> = u8_const<1>; +libfunc storage_address_from_base_and_offset = storage_address_from_base_and_offset; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct>>> = struct_construct>>>; +libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; +libfunc store_temp>,)>> = store_temp>,)>>; +libfunc felt252_const<476442828812030857794232422692155113556837216824> = felt252_const<476442828812030857794232422692155113556837216824>; +libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc drop = drop; +libfunc enum_match>> = enum_match>>; +libfunc felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564> = felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564>; +libfunc function_call = function_call; +libfunc storage_base_address_from_felt252 = storage_base_address_from_felt252; +libfunc felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719> = felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719>; +libfunc function_call::hash> = function_call::hash>; +libfunc u128s_from_felt252 = u128s_from_felt252; +libfunc rename> = rename>; +libfunc get_execution_info_syscall = get_execution_info_syscall; +libfunc enum_init, core::array::Array::>, 0> = enum_init, core::array::Array::>, 0>; +libfunc store_temp, core::array::Array::>> = store_temp, core::array::Array::>>; +libfunc enum_init, core::array::Array::>, 1> = enum_init, core::array::Array::>, 1>; +libfunc rename, core::array::Array::>> = rename, core::array::Array::>>; +libfunc function_call>::unwrap_syscall> = function_call>::unwrap_syscall>; +libfunc struct_construct>> = struct_construct>>; +libfunc enum_init,)>, 0> = enum_init,)>, 0>; +libfunc store_temp,)>> = store_temp,)>>; +libfunc enum_init,)>, 1> = enum_init,)>, 1>; +libfunc function_call = function_call; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc function_call = function_call; +libfunc function_call = function_call; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc function_call = function_call; +libfunc enum_match>> = enum_match>>; +libfunc struct_construct> = struct_construct>; +libfunc enum_init, 0> = enum_init, 0>; +libfunc store_temp> = store_temp>; +libfunc enum_init, 1> = enum_init, 1>; +libfunc enum_match = enum_match; +libfunc felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697> = felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697>; +libfunc function_call = function_call; +libfunc felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999> = felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999>; +libfunc function_call = function_call; +libfunc enum_init>, 0> = enum_init>, 0>; +libfunc struct_construct>>> = struct_construct>>>; +libfunc enum_init>,)>, 0> = enum_init>,)>, 0>; +libfunc store_temp>,)>> = store_temp>,)>>; +libfunc enum_init>,)>, 1> = enum_init>,)>, 1>; +libfunc enum_init>, 1> = enum_init>, 1>; +libfunc pedersen = pedersen; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc rename = rename; +libfunc enum_match, core::array::Array::>> = enum_match, core::array::Array::>>; +libfunc enum_init = enum_init; +libfunc u128_overflowing_add = u128_overflowing_add; +libfunc struct_construct> = struct_construct>; +libfunc store_temp> = store_temp>; +libfunc struct_deconstruct> = struct_deconstruct>; +libfunc struct_construct> = struct_construct>; +libfunc store_temp> = store_temp>; +libfunc u128_const<1> = u128_const<1>; +libfunc drop = drop; +libfunc rename> = rename>; +libfunc u128_overflowing_sub = u128_overflowing_sub; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc function_call = function_call; +libfunc dup = dup; +libfunc struct_deconstruct = struct_deconstruct; +libfunc rename = rename; + +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 87([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 28() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 74([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([29]) -> ([44]); +store_temp([2]) -> ([45]); +store_temp([40]) -> ([46]); +function_call([44], [45], [46]) -> ([41], [42], [43]); +store_temp([28]) -> ([28]); +enum_match>([43]) { fallthrough([47]) 67([48]) }; +branch_align() -> (); +array_new() -> ([49]); +struct_deconstruct>([47]) -> ([50]); +snapshot_take([50]) -> ([51], [52]); +drop([51]) -> (); +store_temp([52]) -> ([55]); +store_temp>([49]) -> ([56]); +function_call([55], [56]) -> ([53], [54]); +drop([54]) -> (); +snapshot_take>([53]) -> ([57], [58]); +drop>([57]) -> (); +struct_construct>([58]) -> ([59]); +struct_construct>>([59]) -> ([60]); +enum_init,)>, 0>([60]) -> ([61]); +store_temp([28]) -> ([62]); +store_temp([41]) -> ([63]); +store_temp([42]) -> ([64]); +store_temp,)>>([61]) -> ([65]); +return([62], [63], [64], [65]); +branch_align() -> (); +enum_init,)>, 1>([48]) -> ([66]); +store_temp([28]) -> ([67]); +store_temp([41]) -> ([68]); +store_temp([42]) -> ([69]); +store_temp,)>>([66]) -> ([70]); +return([67], [68], [69], [70]); +branch_align() -> (); +array_new() -> ([71]); +felt252_const<375233589013918064796019>() -> ([72]); +store_temp([72]) -> ([72]); +array_append([71], [72]) -> ([73]); +struct_construct() -> ([74]); +struct_construct>>([74], [73]) -> ([75]); +enum_init,)>, 1>([75]) -> ([76]); +store_temp([30]) -> ([77]); +store_temp([31]) -> ([78]); +store_temp([2]) -> ([79]); +store_temp,)>>([76]) -> ([80]); +return([77], [78], [79], [80]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([81]); +felt252_const<375233589013918064796019>() -> ([82]); +store_temp([82]) -> ([82]); +array_append([81], [82]) -> ([83]); +struct_construct() -> ([84]); +struct_construct>>([84], [83]) -> ([85]); +enum_init,)>, 1>([85]) -> ([86]); +store_temp([6]) -> ([87]); +store_temp([7]) -> ([88]); +store_temp([2]) -> ([89]); +store_temp,)>>([86]) -> ([90]); +return([87], [88], [89], [90]); +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 188([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 129() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 175([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([29]) -> ([44]); +store_temp([2]) -> ([45]); +store_temp([40]) -> ([46]); +function_call([44], [45], [46]) -> ([41], [42], [43]); +store_temp([28]) -> ([28]); +enum_match>([43]) { fallthrough([47]) 168([48]) }; +branch_align() -> (); +array_new() -> ([49]); +struct_deconstruct>([47]) -> ([50]); +snapshot_take([50]) -> ([51], [52]); +drop([51]) -> (); +store_temp([52]) -> ([55]); +store_temp>([49]) -> ([56]); +function_call([55], [56]) -> ([53], [54]); +drop([54]) -> (); +snapshot_take>([53]) -> ([57], [58]); +drop>([57]) -> (); +struct_construct>([58]) -> ([59]); +struct_construct>>([59]) -> ([60]); +enum_init,)>, 0>([60]) -> ([61]); +store_temp([28]) -> ([62]); +store_temp([41]) -> ([63]); +store_temp([42]) -> ([64]); +store_temp,)>>([61]) -> ([65]); +return([62], [63], [64], [65]); +branch_align() -> (); +enum_init,)>, 1>([48]) -> ([66]); +store_temp([28]) -> ([67]); +store_temp([41]) -> ([68]); +store_temp([42]) -> ([69]); +store_temp,)>>([66]) -> ([70]); +return([67], [68], [69], [70]); +branch_align() -> (); +array_new() -> ([71]); +felt252_const<375233589013918064796019>() -> ([72]); +store_temp([72]) -> ([72]); +array_append([71], [72]) -> ([73]); +struct_construct() -> ([74]); +struct_construct>>([74], [73]) -> ([75]); +enum_init,)>, 1>([75]) -> ([76]); +store_temp([30]) -> ([77]); +store_temp([31]) -> ([78]); +store_temp([2]) -> ([79]); +store_temp,)>>([76]) -> ([80]); +return([77], [78], [79], [80]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([81]); +felt252_const<375233589013918064796019>() -> ([82]); +store_temp([82]) -> ([82]); +array_append([81], [82]) -> ([83]); +struct_construct() -> ([84]); +struct_construct>>([84], [83]) -> ([85]); +enum_init,)>, 1>([85]) -> ([86]); +store_temp([6]) -> ([87]); +store_temp([7]) -> ([88]); +store_temp([2]) -> ([89]); +store_temp,)>>([86]) -> ([90]); +return([87], [88], [89], [90]); +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 289([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 230() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 276([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([28]) -> ([45]); +store_temp([29]) -> ([46]); +store_temp([2]) -> ([47]); +store_temp([40]) -> ([48]); +function_call([45], [46], [47], [48]) -> ([41], [42], [43], [44]); +enum_match>([44]) { fallthrough([49]) 269([50]) }; +branch_align() -> (); +array_new() -> ([51]); +struct_deconstruct>([49]) -> ([52]); +snapshot_take([52]) -> ([53], [54]); +drop([53]) -> (); +store_temp([54]) -> ([57]); +store_temp>([51]) -> ([58]); +function_call([57], [58]) -> ([55], [56]); +drop([56]) -> (); +snapshot_take>([55]) -> ([59], [60]); +drop>([59]) -> (); +struct_construct>([60]) -> ([61]); +struct_construct>>([61]) -> ([62]); +enum_init,)>, 0>([62]) -> ([63]); +store_temp([41]) -> ([64]); +store_temp([42]) -> ([65]); +store_temp([43]) -> ([66]); +store_temp,)>>([63]) -> ([67]); +return([64], [65], [66], [67]); +branch_align() -> (); +enum_init,)>, 1>([50]) -> ([68]); +store_temp([41]) -> ([69]); +store_temp([42]) -> ([70]); +store_temp([43]) -> ([71]); +store_temp,)>>([68]) -> ([72]); +return([69], [70], [71], [72]); +branch_align() -> (); +array_new() -> ([73]); +felt252_const<375233589013918064796019>() -> ([74]); +store_temp([74]) -> ([74]); +array_append([73], [74]) -> ([75]); +struct_construct() -> ([76]); +struct_construct>>([76], [75]) -> ([77]); +enum_init,)>, 1>([77]) -> ([78]); +store_temp([30]) -> ([79]); +store_temp([31]) -> ([80]); +store_temp([2]) -> ([81]); +store_temp,)>>([78]) -> ([82]); +return([79], [80], [81], [82]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([83]); +felt252_const<375233589013918064796019>() -> ([84]); +store_temp([84]) -> ([84]); +array_append([83], [84]) -> ([85]); +struct_construct() -> ([86]); +struct_construct>>([86], [85]) -> ([87]); +enum_init,)>, 1>([87]) -> ([88]); +store_temp([6]) -> ([89]); +store_temp([7]) -> ([90]); +store_temp([2]) -> ([91]); +store_temp,)>>([88]) -> ([92]); +return([89], [90], [91], [92]); +revoke_ap_tracking() -> (); +withdraw_gas([0], [1]) { fallthrough([4], [5]) 390([6], [7]) }; +branch_align() -> (); +struct_deconstruct>([3]) -> ([8]); +array_len([8]) -> ([9]); +snapshot_take([9]) -> ([10], [11]); +drop([10]) -> (); +u32_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +store_temp([15]) -> ([15]); +store_temp([4]) -> ([4]); +u32_eq([15], [16]) { fallthrough() 331() }; +branch_align() -> (); +array_new() -> ([17]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([18]); +store_temp([18]) -> ([18]); +array_append([17], [18]) -> ([19]); +struct_construct() -> ([20]); +struct_construct>>([20], [19]) -> ([21]); +enum_init,)>, 1>([21]) -> ([22]); +store_temp([4]) -> ([23]); +store_temp([5]) -> ([24]); +store_temp([2]) -> ([25]); +store_temp,)>>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +get_builtin_costs() -> ([27]); +store_temp([27]) -> ([27]); +withdraw_gas_all([4], [5], [27]) { fallthrough([28], [29]) 377([30], [31]) }; +branch_align() -> (); +struct_construct() -> ([32]); +struct_construct() -> ([33]); +struct_construct() -> ([34]); +struct_construct() -> ([35]); +struct_construct() -> ([36]); +struct_construct() -> ([37]); +struct_construct([32], [33], [34], [35], [36], [37]) -> ([38]); +snapshot_take([38]) -> ([39], [40]); +drop([39]) -> (); +store_temp([28]) -> ([45]); +store_temp([29]) -> ([46]); +store_temp([2]) -> ([47]); +store_temp([40]) -> ([48]); +function_call([45], [46], [47], [48]) -> ([41], [42], [43], [44]); +enum_match>([44]) { fallthrough([49]) 370([50]) }; +branch_align() -> (); +array_new() -> ([51]); +struct_deconstruct>([49]) -> ([52]); +snapshot_take([52]) -> ([53], [54]); +drop([53]) -> (); +store_temp([54]) -> ([57]); +store_temp>([51]) -> ([58]); +function_call([57], [58]) -> ([55], [56]); +drop([56]) -> (); +snapshot_take>([55]) -> ([59], [60]); +drop>([59]) -> (); +struct_construct>([60]) -> ([61]); +struct_construct>>([61]) -> ([62]); +enum_init,)>, 0>([62]) -> ([63]); +store_temp([41]) -> ([64]); +store_temp([42]) -> ([65]); +store_temp([43]) -> ([66]); +store_temp,)>>([63]) -> ([67]); +return([64], [65], [66], [67]); +branch_align() -> (); +enum_init,)>, 1>([50]) -> ([68]); +store_temp([41]) -> ([69]); +store_temp([42]) -> ([70]); +store_temp([43]) -> ([71]); +store_temp,)>>([68]) -> ([72]); +return([69], [70], [71], [72]); +branch_align() -> (); +array_new() -> ([73]); +felt252_const<375233589013918064796019>() -> ([74]); +store_temp([74]) -> ([74]); +array_append([73], [74]) -> ([75]); +struct_construct() -> ([76]); +struct_construct>>([76], [75]) -> ([77]); +enum_init,)>, 1>([77]) -> ([78]); +store_temp([30]) -> ([79]); +store_temp([31]) -> ([80]); +store_temp([2]) -> ([81]); +store_temp,)>>([78]) -> ([82]); +return([79], [80], [81], [82]); +branch_align() -> (); +drop>([3]) -> (); +array_new() -> ([83]); +felt252_const<375233589013918064796019>() -> ([84]); +store_temp([84]) -> ([84]); +array_append([83], [84]) -> ([85]); +struct_construct() -> ([86]); +struct_construct>>([86], [85]) -> ([87]); +enum_init,)>, 1>([87]) -> ([88]); +store_temp([6]) -> ([89]); +store_temp([7]) -> ([90]); +store_temp([2]) -> ([91]); +store_temp,)>>([88]) -> ([92]); +return([89], [90], [91], [92]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 519([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 503([15]) }; +branch_align() -> (); +struct_deconstruct>([10]) -> ([16]); +array_len([16]) -> ([17]); +snapshot_take([17]) -> ([18], [19]); +drop([18]) -> (); +u32_const<0>() -> ([20]); +snapshot_take([20]) -> ([21], [22]); +drop([21]) -> (); +rename([19]) -> ([23]); +rename([22]) -> ([24]); +store_temp([23]) -> ([23]); +u32_eq([23], [24]) { fallthrough() 438() }; +branch_align() -> (); +drop([14]) -> (); +array_new() -> ([25]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([26]); +store_temp([26]) -> ([26]); +array_append([25], [26]) -> ([27]); +struct_construct() -> ([28]); +struct_construct>>([28], [27]) -> ([29]); +enum_init,)>, 1>([29]) -> ([30]); +store_temp([0]) -> ([31]); +store_temp([9]) -> ([32]); +store_temp([6]) -> ([33]); +store_temp([3]) -> ([34]); +store_temp,)>>([30]) -> ([35]); +return([31], [32], [33], [34], [35]); +branch_align() -> (); +get_builtin_costs() -> ([36]); +store_temp([36]) -> ([36]); +withdraw_gas_all([9], [6], [36]) { fallthrough([37], [38]) 488([39], [40]) }; +branch_align() -> (); +struct_construct() -> ([41]); +struct_construct() -> ([42]); +struct_construct() -> ([43]); +struct_construct() -> ([44]); +struct_construct() -> ([45]); +struct_construct() -> ([46]); +struct_construct([41], [42], [43], [44], [45], [46]) -> ([47]); +snapshot_take([47]) -> ([48], [49]); +drop([48]) -> (); +store_temp([37]) -> ([55]); +store_temp([38]) -> ([56]); +store_temp([0]) -> ([57]); +store_temp([3]) -> ([58]); +store_temp([49]) -> ([59]); +store_temp([14]) -> ([60]); +function_call([55], [56], [57], [58], [59], [60]) -> ([50], [51], [52], [53], [54]); +enum_match>([54]) { fallthrough([61]) 480([62]) }; +branch_align() -> (); +array_new() -> ([63]); +struct_deconstruct>([61]) -> ([64]); +snapshot_take([64]) -> ([65], [66]); +drop([65]) -> (); +store_temp([66]) -> ([69]); +store_temp>([63]) -> ([70]); +function_call([69], [70]) -> ([67], [68]); +drop([68]) -> (); +snapshot_take>([67]) -> ([71], [72]); +drop>([71]) -> (); +struct_construct>([72]) -> ([73]); +struct_construct>>([73]) -> ([74]); +enum_init,)>, 0>([74]) -> ([75]); +store_temp([52]) -> ([76]); +store_temp([50]) -> ([77]); +store_temp([51]) -> ([78]); +store_temp([53]) -> ([79]); +store_temp,)>>([75]) -> ([80]); +return([76], [77], [78], [79], [80]); +branch_align() -> (); +enum_init,)>, 1>([62]) -> ([81]); +store_temp([52]) -> ([82]); +store_temp([50]) -> ([83]); +store_temp([51]) -> ([84]); +store_temp([53]) -> ([85]); +store_temp,)>>([81]) -> ([86]); +return([82], [83], [84], [85], [86]); +branch_align() -> (); +drop([14]) -> (); +array_new() -> ([87]); +felt252_const<375233589013918064796019>() -> ([88]); +store_temp([88]) -> ([88]); +array_append([87], [88]) -> ([89]); +struct_construct() -> ([90]); +struct_construct>>([90], [89]) -> ([91]); +enum_init,)>, 1>([91]) -> ([92]); +store_temp([0]) -> ([93]); +store_temp([39]) -> ([94]); +store_temp([40]) -> ([95]); +store_temp([3]) -> ([96]); +store_temp,)>>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([98]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([99]); +store_temp([99]) -> ([99]); +array_append([98], [99]) -> ([100]); +struct_construct() -> ([101]); +struct_construct>>([101], [100]) -> ([102]); +enum_init,)>, 1>([102]) -> ([103]); +store_temp([0]) -> ([104]); +store_temp([9]) -> ([105]); +store_temp([6]) -> ([106]); +store_temp([3]) -> ([107]); +store_temp,)>>([103]) -> ([108]); +return([104], [105], [106], [107], [108]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([109]); +felt252_const<375233589013918064796019>() -> ([110]); +store_temp([110]) -> ([110]); +array_append([109], [110]) -> ([111]); +struct_construct() -> ([112]); +struct_construct>>([112], [111]) -> ([113]); +enum_init,)>, 1>([113]) -> ([114]); +store_temp([0]) -> ([115]); +store_temp([7]) -> ([116]); +store_temp([8]) -> ([117]); +store_temp([3]) -> ([118]); +store_temp,)>>([114]) -> ([119]); +return([115], [116], [117], [118], [119]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 674([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 658([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 641([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 574() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 625([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +snapshot_take([54]) -> ([55], [56]); +drop([55]) -> (); +store_temp([44]) -> ([62]); +store_temp([45]) -> ([63]); +store_temp([0]) -> ([64]); +store_temp([3]) -> ([65]); +store_temp([56]) -> ([66]); +store_temp([14]) -> ([67]); +store_temp([21]) -> ([68]); +function_call([62], [63], [64], [65], [66], [67], [68]) -> ([57], [58], [59], [60], [61]); +enum_match>([61]) { fallthrough([69]) 617([70]) }; +branch_align() -> (); +array_new() -> ([71]); +struct_deconstruct>([69]) -> ([72]); +snapshot_take([72]) -> ([73], [74]); +drop([73]) -> (); +store_temp([74]) -> ([77]); +store_temp>([71]) -> ([78]); +function_call([77], [78]) -> ([75], [76]); +drop([76]) -> (); +snapshot_take>([75]) -> ([79], [80]); +drop>([79]) -> (); +struct_construct>([80]) -> ([81]); +struct_construct>>([81]) -> ([82]); +enum_init,)>, 0>([82]) -> ([83]); +store_temp([59]) -> ([84]); +store_temp([57]) -> ([85]); +store_temp([58]) -> ([86]); +store_temp([60]) -> ([87]); +store_temp,)>>([83]) -> ([88]); +return([84], [85], [86], [87], [88]); +branch_align() -> (); +enum_init,)>, 1>([70]) -> ([89]); +store_temp([59]) -> ([90]); +store_temp([57]) -> ([91]); +store_temp([58]) -> ([92]); +store_temp([60]) -> ([93]); +store_temp,)>>([89]) -> ([94]); +return([90], [91], [92], [93], [94]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([95]); +felt252_const<375233589013918064796019>() -> ([96]); +store_temp([96]) -> ([96]); +array_append([95], [96]) -> ([97]); +struct_construct() -> ([98]); +struct_construct>>([98], [97]) -> ([99]); +enum_init,)>, 1>([99]) -> ([100]); +store_temp([0]) -> ([101]); +store_temp([46]) -> ([102]); +store_temp([47]) -> ([103]); +store_temp([3]) -> ([104]); +store_temp,)>>([100]) -> ([105]); +return([101], [102], [103], [104], [105]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([106]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([107]); +store_temp([107]) -> ([107]); +array_append([106], [107]) -> ([108]); +struct_construct() -> ([109]); +struct_construct>>([109], [108]) -> ([110]); +enum_init,)>, 1>([110]) -> ([111]); +store_temp([0]) -> ([112]); +store_temp([16]) -> ([113]); +store_temp([6]) -> ([114]); +store_temp([3]) -> ([115]); +store_temp,)>>([111]) -> ([116]); +return([112], [113], [114], [115], [116]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([117]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([118]); +store_temp([118]) -> ([118]); +array_append([117], [118]) -> ([119]); +struct_construct() -> ([120]); +struct_construct>>([120], [119]) -> ([121]); +enum_init,)>, 1>([121]) -> ([122]); +store_temp([0]) -> ([123]); +store_temp([9]) -> ([124]); +store_temp([6]) -> ([125]); +store_temp([3]) -> ([126]); +store_temp,)>>([122]) -> ([127]); +return([123], [124], [125], [126], [127]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([128]); +felt252_const<375233589013918064796019>() -> ([129]); +store_temp([129]) -> ([129]); +array_append([128], [129]) -> ([130]); +struct_construct() -> ([131]); +struct_construct>>([131], [130]) -> ([132]); +enum_init,)>, 1>([132]) -> ([133]); +store_temp([0]) -> ([134]); +store_temp([7]) -> ([135]); +store_temp([8]) -> ([136]); +store_temp([3]) -> ([137]); +store_temp,)>>([133]) -> ([138]); +return([134], [135], [136], [137], [138]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 821([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 805([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 788([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 729() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 772([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 764([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 994([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 978([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 961([22]) }; +branch_align() -> (); +store_temp([16]) -> ([26]); +store_temp>([17]) -> ([27]); +function_call([26], [27]) -> ([23], [24], [25]); +enum_match>([25]) { fallthrough([28]) 943([29]) }; +branch_align() -> (); +struct_deconstruct>([24]) -> ([30]); +array_len([30]) -> ([31]); +snapshot_take([31]) -> ([32], [33]); +drop([32]) -> (); +u32_const<0>() -> ([34]); +snapshot_take([34]) -> ([35], [36]); +drop([35]) -> (); +rename([33]) -> ([37]); +rename([36]) -> ([38]); +store_temp([37]) -> ([37]); +u32_eq([37], [38]) { fallthrough() 882() }; +branch_align() -> (); +drop([28]) -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([39]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([40]); +store_temp([40]) -> ([40]); +array_append([39], [40]) -> ([41]); +struct_construct() -> ([42]); +struct_construct>>([42], [41]) -> ([43]); +enum_init,)>, 1>([43]) -> ([44]); +store_temp([0]) -> ([45]); +store_temp([23]) -> ([46]); +store_temp([6]) -> ([47]); +store_temp([3]) -> ([48]); +store_temp,)>>([44]) -> ([49]); +return([45], [46], [47], [48], [49]); +branch_align() -> (); +get_builtin_costs() -> ([50]); +store_temp([50]) -> ([50]); +withdraw_gas_all([23], [6], [50]) { fallthrough([51], [52]) 926([53], [54]) }; +branch_align() -> (); +struct_construct() -> ([55]); +struct_construct() -> ([56]); +struct_construct() -> ([57]); +struct_construct() -> ([58]); +struct_construct() -> ([59]); +struct_construct() -> ([60]); +struct_construct([55], [56], [57], [58], [59], [60]) -> ([61]); +store_temp([51]) -> ([67]); +store_temp([52]) -> ([68]); +store_temp([0]) -> ([69]); +store_temp([3]) -> ([70]); +store_temp([61]) -> ([71]); +store_temp([14]) -> ([72]); +store_temp([21]) -> ([73]); +store_temp([28]) -> ([74]); +function_call([67], [68], [69], [70], [71], [72], [73], [74]) -> ([62], [63], [64], [65], [66]); +enum_match>([66]) { fallthrough([75]) 918([76]) }; +branch_align() -> (); +drop>([75]) -> (); +array_new() -> ([77]); +snapshot_take>([77]) -> ([78], [79]); +drop>([78]) -> (); +struct_construct>([79]) -> ([80]); +struct_construct>>([80]) -> ([81]); +enum_init,)>, 0>([81]) -> ([82]); +store_temp([64]) -> ([83]); +store_temp([62]) -> ([84]); +store_temp([63]) -> ([85]); +store_temp([65]) -> ([86]); +store_temp,)>>([82]) -> ([87]); +return([83], [84], [85], [86], [87]); +branch_align() -> (); +enum_init,)>, 1>([76]) -> ([88]); +store_temp([64]) -> ([89]); +store_temp([62]) -> ([90]); +store_temp([63]) -> ([91]); +store_temp([65]) -> ([92]); +store_temp,)>>([88]) -> ([93]); +return([89], [90], [91], [92], [93]); +branch_align() -> (); +drop([28]) -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([94]); +felt252_const<375233589013918064796019>() -> ([95]); +store_temp([95]) -> ([95]); +array_append([94], [95]) -> ([96]); +struct_construct() -> ([97]); +struct_construct>>([97], [96]) -> ([98]); +enum_init,)>, 1>([98]) -> ([99]); +store_temp([0]) -> ([100]); +store_temp([53]) -> ([101]); +store_temp([54]) -> ([102]); +store_temp([3]) -> ([103]); +store_temp,)>>([99]) -> ([104]); +return([100], [101], [102], [103], [104]); +branch_align() -> (); +drop([29]) -> (); +drop>([24]) -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([105]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>() -> ([106]); +store_temp([106]) -> ([106]); +array_append([105], [106]) -> ([107]); +struct_construct() -> ([108]); +struct_construct>>([108], [107]) -> ([109]); +enum_init,)>, 1>([109]) -> ([110]); +store_temp([0]) -> ([111]); +store_temp([23]) -> ([112]); +store_temp([6]) -> ([113]); +store_temp([3]) -> ([114]); +store_temp,)>>([110]) -> ([115]); +return([111], [112], [113], [114], [115]); +branch_align() -> (); +drop([22]) -> (); +drop([14]) -> (); +drop>([17]) -> (); +array_new() -> ([116]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([117]); +store_temp([117]) -> ([117]); +array_append([116], [117]) -> ([118]); +struct_construct() -> ([119]); +struct_construct>>([119], [118]) -> ([120]); +enum_init,)>, 1>([120]) -> ([121]); +store_temp([0]) -> ([122]); +store_temp([16]) -> ([123]); +store_temp([6]) -> ([124]); +store_temp([3]) -> ([125]); +store_temp,)>>([121]) -> ([126]); +return([122], [123], [124], [125], [126]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([127]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([128]); +store_temp([128]) -> ([128]); +array_append([127], [128]) -> ([129]); +struct_construct() -> ([130]); +struct_construct>>([130], [129]) -> ([131]); +enum_init,)>, 1>([131]) -> ([132]); +store_temp([0]) -> ([133]); +store_temp([9]) -> ([134]); +store_temp([6]) -> ([135]); +store_temp([3]) -> ([136]); +store_temp,)>>([132]) -> ([137]); +return([133], [134], [135], [136], [137]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([138]); +felt252_const<375233589013918064796019>() -> ([139]); +store_temp([139]) -> ([139]); +array_append([138], [139]) -> ([140]); +struct_construct() -> ([141]); +struct_construct>>([141], [140]) -> ([142]); +enum_init,)>, 1>([142]) -> ([143]); +store_temp([0]) -> ([144]); +store_temp([7]) -> ([145]); +store_temp([8]) -> ([146]); +store_temp([3]) -> ([147]); +store_temp,)>>([143]) -> ([148]); +return([144], [145], [146], [147], [148]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1141([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1125([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 1108([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 1049() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1092([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 1084([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1288([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1272([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 1255([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 1196() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1239([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 1231([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1435([7], [8]) }; +branch_align() -> (); +store_temp([5]) -> ([12]); +store_temp>([4]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1419([15]) }; +branch_align() -> (); +store_temp([9]) -> ([19]); +store_temp>([10]) -> ([20]); +function_call([19], [20]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([21]) 1402([22]) }; +branch_align() -> (); +struct_deconstruct>([17]) -> ([23]); +array_len([23]) -> ([24]); +snapshot_take([24]) -> ([25], [26]); +drop([25]) -> (); +u32_const<0>() -> ([27]); +snapshot_take([27]) -> ([28], [29]); +drop([28]) -> (); +rename([26]) -> ([30]); +rename([29]) -> ([31]); +store_temp([30]) -> ([30]); +u32_eq([30], [31]) { fallthrough() 1343() }; +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([32]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([33]); +store_temp([33]) -> ([33]); +array_append([32], [33]) -> ([34]); +struct_construct() -> ([35]); +struct_construct>>([35], [34]) -> ([36]); +enum_init,)>, 1>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([16]) -> ([39]); +store_temp([6]) -> ([40]); +store_temp([3]) -> ([41]); +store_temp,)>>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +branch_align() -> (); +get_builtin_costs() -> ([43]); +store_temp([43]) -> ([43]); +withdraw_gas_all([16], [6], [43]) { fallthrough([44], [45]) 1386([46], [47]) }; +branch_align() -> (); +struct_construct() -> ([48]); +struct_construct() -> ([49]); +struct_construct() -> ([50]); +struct_construct() -> ([51]); +struct_construct() -> ([52]); +struct_construct() -> ([53]); +struct_construct([48], [49], [50], [51], [52], [53]) -> ([54]); +store_temp([44]) -> ([60]); +store_temp([45]) -> ([61]); +store_temp([0]) -> ([62]); +store_temp([3]) -> ([63]); +store_temp([54]) -> ([64]); +store_temp([14]) -> ([65]); +store_temp([21]) -> ([66]); +function_call([60], [61], [62], [63], [64], [65], [66]) -> ([55], [56], [57], [58], [59]); +enum_match>([59]) { fallthrough([67]) 1378([68]) }; +branch_align() -> (); +drop>([67]) -> (); +array_new() -> ([69]); +snapshot_take>([69]) -> ([70], [71]); +drop>([70]) -> (); +struct_construct>([71]) -> ([72]); +struct_construct>>([72]) -> ([73]); +enum_init,)>, 0>([73]) -> ([74]); +store_temp([57]) -> ([75]); +store_temp([55]) -> ([76]); +store_temp([56]) -> ([77]); +store_temp([58]) -> ([78]); +store_temp,)>>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +enum_init,)>, 1>([68]) -> ([80]); +store_temp([57]) -> ([81]); +store_temp([55]) -> ([82]); +store_temp([56]) -> ([83]); +store_temp([58]) -> ([84]); +store_temp,)>>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([21]) -> (); +drop([14]) -> (); +array_new() -> ([86]); +felt252_const<375233589013918064796019>() -> ([87]); +store_temp([87]) -> ([87]); +array_append([86], [87]) -> ([88]); +struct_construct() -> ([89]); +struct_construct>>([89], [88]) -> ([90]); +enum_init,)>, 1>([90]) -> ([91]); +store_temp([0]) -> ([92]); +store_temp([46]) -> ([93]); +store_temp([47]) -> ([94]); +store_temp([3]) -> ([95]); +store_temp,)>>([91]) -> ([96]); +return([92], [93], [94], [95], [96]); +branch_align() -> (); +drop([22]) -> (); +drop>([17]) -> (); +drop([14]) -> (); +array_new() -> ([97]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([98]); +store_temp([98]) -> ([98]); +array_append([97], [98]) -> ([99]); +struct_construct() -> ([100]); +struct_construct>>([100], [99]) -> ([101]); +enum_init,)>, 1>([101]) -> ([102]); +store_temp([0]) -> ([103]); +store_temp([16]) -> ([104]); +store_temp([6]) -> ([105]); +store_temp([3]) -> ([106]); +store_temp,)>>([102]) -> ([107]); +return([103], [104], [105], [106], [107]); +branch_align() -> (); +drop([15]) -> (); +drop>([10]) -> (); +array_new() -> ([108]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([109]); +store_temp([109]) -> ([109]); +array_append([108], [109]) -> ([110]); +struct_construct() -> ([111]); +struct_construct>>([111], [110]) -> ([112]); +enum_init,)>, 1>([112]) -> ([113]); +store_temp([0]) -> ([114]); +store_temp([9]) -> ([115]); +store_temp([6]) -> ([116]); +store_temp([3]) -> ([117]); +store_temp,)>>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([119]); +felt252_const<375233589013918064796019>() -> ([120]); +store_temp([120]) -> ([120]); +array_append([119], [120]) -> ([121]); +struct_construct() -> ([122]); +struct_construct>>([122], [121]) -> ([123]); +enum_init,)>, 1>([123]) -> ([124]); +store_temp([0]) -> ([125]); +store_temp([7]) -> ([126]); +store_temp([8]) -> ([127]); +store_temp([3]) -> ([128]); +store_temp,)>>([124]) -> ([129]); +return([125], [126], [127], [128], [129]); +revoke_ap_tracking() -> (); +withdraw_gas([1], [2]) { fallthrough([5], [6]) 1662([7], [8]) }; +branch_align() -> (); +store_temp>([4]) -> ([11]); +function_call([11]) -> ([9], [10]); +store_temp([5]) -> ([5]); +enum_match>([10]) { fallthrough([12]) 1646([13]) }; +branch_align() -> (); +store_temp>([9]) -> ([16]); +function_call([16]) -> ([14], [15]); +enum_match>([15]) { fallthrough([17]) 1629([18]) }; +branch_align() -> (); +store_temp([5]) -> ([22]); +store_temp>([14]) -> ([23]); +function_call([22], [23]) -> ([19], [20], [21]); +enum_match>([21]) { fallthrough([24]) 1611([25]) }; +branch_align() -> (); +store_temp([19]) -> ([29]); +store_temp>([20]) -> ([30]); +function_call([29], [30]) -> ([26], [27], [28]); +enum_match>([28]) { fallthrough([31]) 1592([32]) }; +branch_align() -> (); +store_temp([26]) -> ([36]); +store_temp>([27]) -> ([37]); +function_call([36], [37]) -> ([33], [34], [35]); +enum_match>([35]) { fallthrough([38]) 1572([39]) }; +branch_align() -> (); +struct_deconstruct>([34]) -> ([40]); +array_len([40]) -> ([41]); +snapshot_take([41]) -> ([42], [43]); +drop([42]) -> (); +u32_const<0>() -> ([44]); +snapshot_take([44]) -> ([45], [46]); +drop([45]) -> (); +rename([43]) -> ([47]); +rename([46]) -> ([48]); +store_temp([47]) -> ([47]); +u32_eq([47], [48]) { fallthrough() 1507() }; +branch_align() -> (); +drop([38]) -> (); +drop([31]) -> (); +drop([24]) -> (); +drop([17]) -> (); +drop([12]) -> (); +array_new() -> ([49]); +felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>() -> ([50]); +store_temp([50]) -> ([50]); +array_append([49], [50]) -> ([51]); +struct_construct() -> ([52]); +struct_construct>>([52], [51]) -> ([53]); +enum_init,)>, 1>([53]) -> ([54]); +store_temp([0]) -> ([55]); +store_temp([33]) -> ([56]); +store_temp([6]) -> ([57]); +store_temp([3]) -> ([58]); +store_temp,)>>([54]) -> ([59]); +return([55], [56], [57], [58], [59]); +branch_align() -> (); +get_builtin_costs() -> ([60]); +store_temp([60]) -> ([60]); +withdraw_gas_all([33], [6], [60]) { fallthrough([61], [62]) 1553([63], [64]) }; +branch_align() -> (); +struct_construct() -> ([65]); +struct_construct() -> ([66]); +struct_construct() -> ([67]); +struct_construct() -> ([68]); +struct_construct() -> ([69]); +struct_construct() -> ([70]); +struct_construct([65], [66], [67], [68], [69], [70]) -> ([71]); +store_temp([61]) -> ([77]); +store_temp([62]) -> ([78]); +store_temp([0]) -> ([79]); +store_temp([3]) -> ([80]); +store_temp([71]) -> ([81]); +store_temp([12]) -> ([82]); +store_temp([17]) -> ([83]); +store_temp([24]) -> ([84]); +store_temp([31]) -> ([85]); +store_temp([38]) -> ([86]); +function_call([77], [78], [79], [80], [81], [82], [83], [84], [85], [86]) -> ([72], [73], [74], [75], [76]); +enum_match>([76]) { fallthrough([87]) 1545([88]) }; +branch_align() -> (); +drop>([87]) -> (); +array_new() -> ([89]); +snapshot_take>([89]) -> ([90], [91]); +drop>([90]) -> (); +struct_construct>([91]) -> ([92]); +struct_construct>>([92]) -> ([93]); +enum_init,)>, 0>([93]) -> ([94]); +store_temp([74]) -> ([95]); +store_temp([72]) -> ([96]); +store_temp([73]) -> ([97]); +store_temp([75]) -> ([98]); +store_temp,)>>([94]) -> ([99]); +return([95], [96], [97], [98], [99]); +branch_align() -> (); +enum_init,)>, 1>([88]) -> ([100]); +store_temp([74]) -> ([101]); +store_temp([72]) -> ([102]); +store_temp([73]) -> ([103]); +store_temp([75]) -> ([104]); +store_temp,)>>([100]) -> ([105]); +return([101], [102], [103], [104], [105]); +branch_align() -> (); +drop([38]) -> (); +drop([31]) -> (); +drop([24]) -> (); +drop([17]) -> (); +drop([12]) -> (); +array_new() -> ([106]); +felt252_const<375233589013918064796019>() -> ([107]); +store_temp([107]) -> ([107]); +array_append([106], [107]) -> ([108]); +struct_construct() -> ([109]); +struct_construct>>([109], [108]) -> ([110]); +enum_init,)>, 1>([110]) -> ([111]); +store_temp([0]) -> ([112]); +store_temp([63]) -> ([113]); +store_temp([64]) -> ([114]); +store_temp([3]) -> ([115]); +store_temp,)>>([111]) -> ([116]); +return([112], [113], [114], [115], [116]); +branch_align() -> (); +drop([39]) -> (); +drop>([34]) -> (); +drop([31]) -> (); +drop([24]) -> (); +drop([17]) -> (); +drop([12]) -> (); +array_new() -> ([117]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492917>() -> ([118]); +store_temp([118]) -> ([118]); +array_append([117], [118]) -> ([119]); +struct_construct() -> ([120]); +struct_construct>>([120], [119]) -> ([121]); +enum_init,)>, 1>([121]) -> ([122]); +store_temp([0]) -> ([123]); +store_temp([33]) -> ([124]); +store_temp([6]) -> ([125]); +store_temp([3]) -> ([126]); +store_temp,)>>([122]) -> ([127]); +return([123], [124], [125], [126], [127]); +branch_align() -> (); +drop([32]) -> (); +drop([17]) -> (); +drop([12]) -> (); +drop([24]) -> (); +drop>([27]) -> (); +array_new() -> ([128]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492916>() -> ([129]); +store_temp([129]) -> ([129]); +array_append([128], [129]) -> ([130]); +struct_construct() -> ([131]); +struct_construct>>([131], [130]) -> ([132]); +enum_init,)>, 1>([132]) -> ([133]); +store_temp([0]) -> ([134]); +store_temp([26]) -> ([135]); +store_temp([6]) -> ([136]); +store_temp([3]) -> ([137]); +store_temp,)>>([133]) -> ([138]); +return([134], [135], [136], [137], [138]); +branch_align() -> (); +drop([25]) -> (); +drop([17]) -> (); +drop([12]) -> (); +drop>([20]) -> (); +array_new() -> ([139]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492915>() -> ([140]); +store_temp([140]) -> ([140]); +array_append([139], [140]) -> ([141]); +struct_construct() -> ([142]); +struct_construct>>([142], [141]) -> ([143]); +enum_init,)>, 1>([143]) -> ([144]); +store_temp([0]) -> ([145]); +store_temp([19]) -> ([146]); +store_temp([6]) -> ([147]); +store_temp([3]) -> ([148]); +store_temp,)>>([144]) -> ([149]); +return([145], [146], [147], [148], [149]); +branch_align() -> (); +drop([18]) -> (); +drop([12]) -> (); +drop>([14]) -> (); +array_new() -> ([150]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492914>() -> ([151]); +store_temp([151]) -> ([151]); +array_append([150], [151]) -> ([152]); +struct_construct() -> ([153]); +struct_construct>>([153], [152]) -> ([154]); +enum_init,)>, 1>([154]) -> ([155]); +store_temp([0]) -> ([156]); +store_temp([5]) -> ([157]); +store_temp([6]) -> ([158]); +store_temp([3]) -> ([159]); +store_temp,)>>([155]) -> ([160]); +return([156], [157], [158], [159], [160]); +branch_align() -> (); +drop([13]) -> (); +drop>([9]) -> (); +array_new() -> ([161]); +felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>() -> ([162]); +store_temp([162]) -> ([162]); +array_append([161], [162]) -> ([163]); +struct_construct() -> ([164]); +struct_construct>>([164], [163]) -> ([165]); +enum_init,)>, 1>([165]) -> ([166]); +store_temp([0]) -> ([167]); +store_temp([5]) -> ([168]); +store_temp([6]) -> ([169]); +store_temp([3]) -> ([170]); +store_temp,)>>([166]) -> ([171]); +return([167], [168], [169], [170], [171]); +branch_align() -> (); +drop>([4]) -> (); +array_new() -> ([172]); +felt252_const<375233589013918064796019>() -> ([173]); +store_temp([173]) -> ([173]); +array_append([172], [173]) -> ([174]); +struct_construct() -> ([175]); +struct_construct>>([175], [174]) -> ([176]); +enum_init,)>, 1>([176]) -> ([177]); +store_temp([0]) -> ([178]); +store_temp([7]) -> ([179]); +store_temp([8]) -> ([180]); +store_temp([3]) -> ([181]); +store_temp,)>>([177]) -> ([182]); +return([178], [179], [180], [181], [182]); +struct_deconstruct([2]) -> ([3], [4], [5], [6], [7], [8]); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +drop([7]) -> (); +drop([8]) -> (); +store_temp([0]) -> ([12]); +store_temp([1]) -> ([13]); +store_temp([3]) -> ([14]); +function_call([12], [13], [14]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([15]) 1696([16]) }; +branch_align() -> (); +struct_deconstruct>([15]) -> ([17]); +struct_construct>([17]) -> ([18]); +enum_init, 0>([18]) -> ([19]); +store_temp([9]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp>([19]) -> ([22]); +return([20], [21], [22]); +branch_align() -> (); +enum_init, 1>([16]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([10]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +rename([0]) -> ([2]); +array_append([1], [2]) -> ([3]); +struct_construct() -> ([4]); +store_temp>([3]) -> ([5]); +store_temp([4]) -> ([6]); +return([5], [6]); +struct_deconstruct([2]) -> ([3], [4], [5], [6], [7], [8]); +drop([3]) -> (); +drop([5]) -> (); +drop([6]) -> (); +drop([7]) -> (); +drop([8]) -> (); +store_temp([0]) -> ([12]); +store_temp([1]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([12], [13], [14]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([15]) 1727([16]) }; +branch_align() -> (); +struct_deconstruct>([15]) -> ([17]); +struct_construct>([17]) -> ([18]); +enum_init, 0>([18]) -> ([19]); +store_temp([9]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp>([19]) -> ([22]); +return([20], [21], [22]); +branch_align() -> (); +enum_init, 1>([16]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([10]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +struct_deconstruct([3]) -> ([4], [5], [6], [7], [8], [9]); +drop([4]) -> (); +drop([5]) -> (); +drop([7]) -> (); +drop([8]) -> (); +drop([9]) -> (); +store_temp([0]) -> ([14]); +store_temp([1]) -> ([15]); +store_temp([2]) -> ([16]); +store_temp([6]) -> ([17]); +function_call([14], [15], [16], [17]) -> ([10], [11], [12], [13]); +enum_match>([13]) { fallthrough([18]) 1754([19]) }; +branch_align() -> (); +struct_deconstruct>([18]) -> ([20]); +struct_construct>([20]) -> ([21]); +enum_init, 0>([21]) -> ([22]); +store_temp([10]) -> ([23]); +store_temp([11]) -> ([24]); +store_temp([12]) -> ([25]); +store_temp>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +enum_init, 1>([19]) -> ([27]); +store_temp([10]) -> ([28]); +store_temp([11]) -> ([29]); +store_temp([12]) -> ([30]); +store_temp>([27]) -> ([31]); +return([28], [29], [30], [31]); +rename([0]) -> ([2]); +u8_to_felt252([2]) -> ([3]); +snapshot_take([3]) -> ([4], [5]); +drop([4]) -> (); +store_temp([5]) -> ([8]); +store_temp>([1]) -> ([9]); +function_call([8], [9]) -> ([6], [7]); +drop([7]) -> (); +struct_construct() -> ([10]); +store_temp>([6]) -> ([11]); +store_temp([10]) -> ([12]); +return([11], [12]); +struct_deconstruct([3]) -> ([4], [5], [6], [7], [8], [9]); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +drop([8]) -> (); +drop([9]) -> (); +store_temp([0]) -> ([14]); +store_temp([1]) -> ([15]); +store_temp([2]) -> ([16]); +store_temp([7]) -> ([17]); +function_call([14], [15], [16], [17]) -> ([10], [11], [12], [13]); +enum_match>([13]) { fallthrough([18]) 1794([19]) }; +branch_align() -> (); +struct_deconstruct>([18]) -> ([20]); +struct_construct>([20]) -> ([21]); +enum_init, 0>([21]) -> ([22]); +store_temp([10]) -> ([23]); +store_temp([11]) -> ([24]); +store_temp([12]) -> ([25]); +store_temp>([22]) -> ([26]); +return([23], [24], [25], [26]); +branch_align() -> (); +enum_init, 1>([19]) -> ([27]); +store_temp([10]) -> ([28]); +store_temp([11]) -> ([29]); +store_temp([12]) -> ([30]); +store_temp>([27]) -> ([31]); +return([28], [29], [30], [31]); +dup([0]) -> ([0], [2]); +struct_deconstruct([2]) -> ([3], [4]); +drop([4]) -> (); +store_temp([3]) -> ([7]); +store_temp>([1]) -> ([8]); +function_call([7], [8]) -> ([5], [6]); +drop([6]) -> (); +struct_deconstruct([0]) -> ([9], [10]); +drop([9]) -> (); +store_temp([10]) -> ([13]); +store_temp>([5]) -> ([14]); +function_call([13], [14]) -> ([11], [12]); +rename>([11]) -> ([15]); +rename([12]) -> ([16]); +return([15], [16]); +store_temp>([1]) -> ([4]); +function_call([4]) -> ([2], [3]); +enum_match>([3]) { fallthrough([5]) 1834([6]) }; +branch_align() -> (); +contract_address_try_from_felt252([0], [5]) { fallthrough([7], [8]) 1827([9]) }; +branch_align() -> (); +enum_init, 0>([8]) -> ([10]); +store_temp([7]) -> ([11]); +store_temp>([2]) -> ([12]); +store_temp>([10]) -> ([13]); +return([11], [12], [13]); +branch_align() -> (); +struct_construct() -> ([14]); +enum_init, 1>([14]) -> ([15]); +store_temp([9]) -> ([16]); +store_temp>([2]) -> ([17]); +store_temp>([15]) -> ([18]); +return([16], [17], [18]); +branch_align() -> (); +enum_init, 1>([6]) -> ([19]); +store_temp([0]) -> ([20]); +store_temp>([2]) -> ([21]); +store_temp>([19]) -> ([22]); +return([20], [21], [22]); +struct_deconstruct([4]) -> ([6], [7], [8], [9], [10], [11]); +drop([6]) -> (); +drop([7]) -> (); +drop([8]) -> (); +drop([9]) -> (); +drop([11]) -> (); +store_temp([0]) -> ([17]); +store_temp([1]) -> ([18]); +store_temp([2]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp([5]) -> ([22]); +function_call([17], [18], [19], [20], [21], [22]) -> ([12], [13], [14], [15], [16]); +enum_match>([16]) { fallthrough([23]) 1864([24]) }; +branch_align() -> (); +struct_deconstruct>([23]) -> ([25]); +struct_construct>([25]) -> ([26]); +enum_init, 0>([26]) -> ([27]); +store_temp([12]) -> ([28]); +store_temp([13]) -> ([29]); +store_temp([14]) -> ([30]); +store_temp([15]) -> ([31]); +store_temp>([27]) -> ([32]); +return([28], [29], [30], [31], [32]); +branch_align() -> (); +enum_init, 1>([24]) -> ([33]); +store_temp([12]) -> ([34]); +store_temp([13]) -> ([35]); +store_temp([14]) -> ([36]); +store_temp([15]) -> ([37]); +store_temp>([33]) -> ([38]); +return([34], [35], [36], [37], [38]); +struct_deconstruct([4]) -> ([7], [8], [9], [10], [11], [12]); +drop([7]) -> (); +drop([8]) -> (); +drop([9]) -> (); +drop([10]) -> (); +drop([11]) -> (); +struct_construct>([5], [6]) -> ([13]); +store_temp([0]) -> ([19]); +store_temp([1]) -> ([20]); +store_temp([2]) -> ([21]); +store_temp([3]) -> ([22]); +store_temp([12]) -> ([23]); +store_temp>([13]) -> ([24]); +function_call([19], [20], [21], [22], [23], [24]) -> ([14], [15], [16], [17], [18]); +enum_match>([18]) { fallthrough([25]) 1897([26]) }; +branch_align() -> (); +struct_deconstruct>([25]) -> ([27]); +struct_construct>([27]) -> ([28]); +enum_init, 0>([28]) -> ([29]); +store_temp([14]) -> ([30]); +store_temp([15]) -> ([31]); +store_temp([16]) -> ([32]); +store_temp([17]) -> ([33]); +store_temp>([29]) -> ([34]); +return([30], [31], [32], [33], [34]); +branch_align() -> (); +enum_init, 1>([26]) -> ([35]); +store_temp([14]) -> ([36]); +store_temp([15]) -> ([37]); +store_temp([16]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp>([35]) -> ([40]); +return([36], [37], [38], [39], [40]); +store_temp([0]) -> ([5]); +store_temp>([1]) -> ([6]); +function_call([5], [6]) -> ([2], [3], [4]); +enum_match>([4]) { fallthrough([7]) 1928([8]) }; +branch_align() -> (); +store_temp([2]) -> ([12]); +store_temp>([3]) -> ([13]); +function_call([12], [13]) -> ([9], [10], [11]); +enum_match>([11]) { fallthrough([14]) 1921([15]) }; +branch_align() -> (); +struct_construct([7], [14]) -> ([16]); +enum_init, 0>([16]) -> ([17]); +store_temp([9]) -> ([18]); +store_temp>([10]) -> ([19]); +store_temp>([17]) -> ([20]); +return([18], [19], [20]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([15]) -> ([21]); +store_temp([9]) -> ([22]); +store_temp>([10]) -> ([23]); +store_temp>([21]) -> ([24]); +return([22], [23], [24]); +branch_align() -> (); +enum_init, 1>([8]) -> ([25]); +store_temp([2]) -> ([26]); +store_temp>([3]) -> ([27]); +store_temp>([25]) -> ([28]); +return([26], [27], [28]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 1970([13]) }; +branch_align() -> (); +struct_deconstruct>([12]) -> ([14]); +store_temp([0]) -> ([20]); +store_temp([7]) -> ([21]); +store_temp([2]) -> ([22]); +store_temp([8]) -> ([23]); +store_temp([4]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp([5]) -> ([26]); +store_temp([6]) -> ([27]); +function_call([20], [21], [22], [23], [24], [25], [26], [27]) -> ([15], [16], [17], [18], [19]); +enum_match>([19]) { fallthrough([28]) 1962([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30], [31]); +drop([31]) -> (); +struct_construct() -> ([32]); +struct_construct>([30], [32]) -> ([33]); +enum_init, 0>([33]) -> ([34]); +store_temp([15]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp([17]) -> ([37]); +store_temp([18]) -> ([38]); +store_temp>([34]) -> ([39]); +return([35], [36], [37], [38], [39]); +branch_align() -> (); +enum_init, 1>([29]) -> ([40]); +store_temp([15]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp([17]) -> ([43]); +store_temp([18]) -> ([44]); +store_temp>([40]) -> ([45]); +return([41], [42], [43], [44], [45]); +branch_align() -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +enum_init, 1>([13]) -> ([46]); +store_temp([0]) -> ([47]); +store_temp([7]) -> ([48]); +store_temp([2]) -> ([49]); +store_temp([8]) -> ([50]); +store_temp>([46]) -> ([51]); +return([47], [48], [49], [50], [51]); +store_temp([1]) -> ([11]); +store_temp([3]) -> ([12]); +function_call([11], [12]) -> ([8], [9], [10]); +enum_match>([10]) { fallthrough([13]) 2043([14]) }; +branch_align() -> (); +struct_deconstruct>([13]) -> ([15]); +store_temp([0]) -> ([21]); +store_temp([8]) -> ([22]); +store_temp([2]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([4]) -> ([25]); +dup([5]) -> ([5], [26]); +store_temp([26]) -> ([26]); +store_temp([15]) -> ([27]); +dup([7]) -> ([7], [28]); +store_temp([28]) -> ([28]); +function_call([21], [22], [23], [24], [25], [26], [27], [28]) -> ([16], [17], [18], [19], [20]); +enum_match>([20]) { fallthrough([29]) 2032([30]) }; +branch_align() -> (); +struct_deconstruct>([29]) -> ([31], [32]); +drop([32]) -> (); +store_temp([16]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp([18]) -> ([40]); +store_temp([19]) -> ([41]); +store_temp([31]) -> ([42]); +store_temp([5]) -> ([43]); +store_temp([6]) -> ([44]); +store_temp([7]) -> ([45]); +function_call([38], [39], [40], [41], [42], [43], [44], [45]) -> ([33], [34], [35], [36], [37]); +enum_match>([37]) { fallthrough([46]) 2024([47]) }; +branch_align() -> (); +struct_deconstruct>([46]) -> ([48], [49]); +drop([49]) -> (); +struct_construct() -> ([50]); +struct_construct>([48], [50]) -> ([51]); +enum_init, 0>([51]) -> ([52]); +store_temp([33]) -> ([53]); +store_temp([34]) -> ([54]); +store_temp([35]) -> ([55]); +store_temp([36]) -> ([56]); +store_temp>([52]) -> ([57]); +return([53], [54], [55], [56], [57]); +branch_align() -> (); +enum_init, 1>([47]) -> ([58]); +store_temp([33]) -> ([59]); +store_temp([34]) -> ([60]); +store_temp([35]) -> ([61]); +store_temp([36]) -> ([62]); +store_temp>([58]) -> ([63]); +return([59], [60], [61], [62], [63]); +branch_align() -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +enum_init, 1>([30]) -> ([64]); +store_temp([16]) -> ([65]); +store_temp([17]) -> ([66]); +store_temp([18]) -> ([67]); +store_temp([19]) -> ([68]); +store_temp>([64]) -> ([69]); +return([65], [66], [67], [68], [69]); +branch_align() -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +enum_init, 1>([14]) -> ([70]); +store_temp([0]) -> ([71]); +store_temp([8]) -> ([72]); +store_temp([2]) -> ([73]); +store_temp([9]) -> ([74]); +store_temp>([70]) -> ([75]); +return([71], [72], [73], [74], [75]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 2091([13]) }; +branch_align() -> (); +struct_deconstruct>([12]) -> ([14]); +store_temp([0]) -> ([20]); +store_temp([7]) -> ([21]); +store_temp([2]) -> ([22]); +store_temp([8]) -> ([23]); +store_temp([4]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp([5]) -> ([26]); +store_temp([6]) -> ([27]); +function_call([20], [21], [22], [23], [24], [25], [26], [27]) -> ([15], [16], [17], [18], [19]); +enum_match>([19]) { fallthrough([28]) 2083([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30], [31]); +drop([31]) -> (); +struct_construct() -> ([32]); +struct_construct>([30], [32]) -> ([33]); +enum_init, 0>([33]) -> ([34]); +store_temp([15]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp([17]) -> ([37]); +store_temp([18]) -> ([38]); +store_temp>([34]) -> ([39]); +return([35], [36], [37], [38], [39]); +branch_align() -> (); +enum_init, 1>([29]) -> ([40]); +store_temp([15]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp([17]) -> ([43]); +store_temp([18]) -> ([44]); +store_temp>([40]) -> ([45]); +return([41], [42], [43], [44], [45]); +branch_align() -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +enum_init, 1>([13]) -> ([46]); +store_temp([0]) -> ([47]); +store_temp([7]) -> ([48]); +store_temp([2]) -> ([49]); +store_temp([8]) -> ([50]); +store_temp>([46]) -> ([51]); +return([47], [48], [49], [50], [51]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 2194([13]) }; +branch_align() -> (); +struct_deconstruct([4]) -> ([14], [15], [16], [17], [18], [19]); +snapshot_take([19]) -> ([20], [21]); +struct_deconstruct>([12]) -> ([22]); +dup([22]) -> ([22], [23]); +dup([5]) -> ([5], [24]); +struct_construct>([23], [24]) -> ([25]); +store_temp([0]) -> ([31]); +store_temp([7]) -> ([32]); +store_temp([2]) -> ([33]); +store_temp([8]) -> ([34]); +store_temp([21]) -> ([35]); +store_temp>([25]) -> ([36]); +function_call([31], [32], [33], [34], [35], [36]) -> ([26], [27], [28], [29], [30]); +enum_match>([30]) { fallthrough([37]) 2177([38]) }; +branch_align() -> (); +struct_deconstruct>([37]) -> ([39]); +store_temp([26]) -> ([42]); +store_temp([39]) -> ([43]); +store_temp([6]) -> ([44]); +function_call([42], [43], [44]) -> ([40], [41]); +enum_match>([41]) { fallthrough([45]) 2161([46]) }; +branch_align() -> (); +struct_deconstruct>([45]) -> ([47]); +struct_construct([14], [15], [16], [17], [18], [20]) -> ([48]); +store_temp([40]) -> ([54]); +store_temp([27]) -> ([55]); +store_temp([28]) -> ([56]); +store_temp([29]) -> ([57]); +store_temp([48]) -> ([58]); +store_temp([22]) -> ([59]); +store_temp([5]) -> ([60]); +store_temp([47]) -> ([61]); +function_call([54], [55], [56], [57], [58], [59], [60], [61]) -> ([49], [50], [51], [52], [53]); +enum_match>([53]) { fallthrough([62]) 2153([63]) }; +branch_align() -> (); +struct_deconstruct>([62]) -> ([64], [65]); +drop([65]) -> (); +struct_construct() -> ([66]); +struct_construct>([64], [66]) -> ([67]); +enum_init, 0>([67]) -> ([68]); +store_temp([49]) -> ([69]); +store_temp([50]) -> ([70]); +store_temp([51]) -> ([71]); +store_temp([52]) -> ([72]); +store_temp>([68]) -> ([73]); +return([69], [70], [71], [72], [73]); +branch_align() -> (); +enum_init, 1>([63]) -> ([74]); +store_temp([49]) -> ([75]); +store_temp([50]) -> ([76]); +store_temp([51]) -> ([77]); +store_temp([52]) -> ([78]); +store_temp>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([15]) -> (); +enum_init, 1>([46]) -> ([80]); +store_temp([40]) -> ([81]); +store_temp([27]) -> ([82]); +store_temp([28]) -> ([83]); +store_temp([29]) -> ([84]); +store_temp>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([15]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([6]) -> (); +enum_init, 1>([38]) -> ([86]); +store_temp([26]) -> ([87]); +store_temp([27]) -> ([88]); +store_temp([28]) -> ([89]); +store_temp([29]) -> ([90]); +store_temp>([86]) -> ([91]); +return([87], [88], [89], [90], [91]); +branch_align() -> (); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +enum_init, 1>([13]) -> ([92]); +store_temp([0]) -> ([93]); +store_temp([7]) -> ([94]); +store_temp([2]) -> ([95]); +store_temp([8]) -> ([96]); +store_temp>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +store_temp([1]) -> ([10]); +store_temp([3]) -> ([11]); +function_call([10], [11]) -> ([7], [8], [9]); +enum_match>([9]) { fallthrough([12]) 2297([13]) }; +branch_align() -> (); +struct_deconstruct([4]) -> ([14], [15], [16], [17], [18], [19]); +snapshot_take([19]) -> ([20], [21]); +struct_deconstruct>([12]) -> ([22]); +dup([22]) -> ([22], [23]); +dup([5]) -> ([5], [24]); +struct_construct>([23], [24]) -> ([25]); +store_temp([0]) -> ([31]); +store_temp([7]) -> ([32]); +store_temp([2]) -> ([33]); +store_temp([8]) -> ([34]); +store_temp([21]) -> ([35]); +store_temp>([25]) -> ([36]); +function_call([31], [32], [33], [34], [35], [36]) -> ([26], [27], [28], [29], [30]); +enum_match>([30]) { fallthrough([37]) 2280([38]) }; +branch_align() -> (); +struct_deconstruct>([37]) -> ([39]); +store_temp([26]) -> ([42]); +store_temp([39]) -> ([43]); +store_temp([6]) -> ([44]); +function_call([42], [43], [44]) -> ([40], [41]); +enum_match>([41]) { fallthrough([45]) 2264([46]) }; +branch_align() -> (); +struct_deconstruct>([45]) -> ([47]); +struct_construct([14], [15], [16], [17], [18], [20]) -> ([48]); +store_temp([40]) -> ([54]); +store_temp([27]) -> ([55]); +store_temp([28]) -> ([56]); +store_temp([29]) -> ([57]); +store_temp([48]) -> ([58]); +store_temp([22]) -> ([59]); +store_temp([5]) -> ([60]); +store_temp([47]) -> ([61]); +function_call([54], [55], [56], [57], [58], [59], [60], [61]) -> ([49], [50], [51], [52], [53]); +enum_match>([53]) { fallthrough([62]) 2256([63]) }; +branch_align() -> (); +struct_deconstruct>([62]) -> ([64], [65]); +drop([65]) -> (); +struct_construct() -> ([66]); +struct_construct>([64], [66]) -> ([67]); +enum_init, 0>([67]) -> ([68]); +store_temp([49]) -> ([69]); +store_temp([50]) -> ([70]); +store_temp([51]) -> ([71]); +store_temp([52]) -> ([72]); +store_temp>([68]) -> ([73]); +return([69], [70], [71], [72], [73]); +branch_align() -> (); +enum_init, 1>([63]) -> ([74]); +store_temp([49]) -> ([75]); +store_temp([50]) -> ([76]); +store_temp([51]) -> ([77]); +store_temp([52]) -> ([78]); +store_temp>([74]) -> ([79]); +return([75], [76], [77], [78], [79]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([15]) -> (); +enum_init, 1>([46]) -> ([80]); +store_temp([40]) -> ([81]); +store_temp([27]) -> ([82]); +store_temp([28]) -> ([83]); +store_temp([29]) -> ([84]); +store_temp>([80]) -> ([85]); +return([81], [82], [83], [84], [85]); +branch_align() -> (); +drop([14]) -> (); +drop([5]) -> (); +drop([22]) -> (); +drop([15]) -> (); +drop([20]) -> (); +drop([18]) -> (); +drop([17]) -> (); +drop([16]) -> (); +drop([6]) -> (); +enum_init, 1>([38]) -> ([86]); +store_temp([26]) -> ([87]); +store_temp([27]) -> ([88]); +store_temp([28]) -> ([89]); +store_temp([29]) -> ([90]); +store_temp>([86]) -> ([91]); +return([87], [88], [89], [90], [91]); +branch_align() -> (); +drop([4]) -> (); +drop([5]) -> (); +drop([6]) -> (); +enum_init, 1>([13]) -> ([92]); +store_temp([0]) -> ([93]); +store_temp([7]) -> ([94]); +store_temp([2]) -> ([95]); +store_temp([8]) -> ([96]); +store_temp>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +struct_deconstruct>([0]) -> ([1]); +array_snapshot_pop_front([1]) { fallthrough([2], [3]) 2315([4]) }; +branch_align() -> (); +enum_init>, 0>([3]) -> ([5]); +store_temp>>([2]) -> ([6]); +store_temp>>([5]) -> ([7]); +jump() { 2320() }; +branch_align() -> (); +struct_construct() -> ([8]); +enum_init>, 1>([8]) -> ([9]); +store_temp>>([4]) -> ([6]); +store_temp>>([9]) -> ([7]); +struct_construct>([6]) -> ([10]); +store_temp>([10]) -> ([10]); +enum_match>>([7]) { fallthrough([11]) 2330([12]) }; +branch_align() -> (); +unbox([11]) -> ([13]); +rename([13]) -> ([14]); +enum_init, 0>([14]) -> ([15]); +store_temp>([10]) -> ([16]); +store_temp>([15]) -> ([17]); +return([16], [17]); +branch_align() -> (); +drop([12]) -> (); +struct_construct() -> ([18]); +enum_init, 1>([18]) -> ([19]); +store_temp>([10]) -> ([20]); +store_temp>([19]) -> ([21]); +return([20], [21]); +struct_deconstruct>([1]) -> ([2]); +array_snapshot_pop_front([2]) { fallthrough([3], [4]) 2344([5]) }; +branch_align() -> (); +enum_init>, 0>([4]) -> ([6]); +store_temp>>([3]) -> ([7]); +store_temp>>([6]) -> ([8]); +jump() { 2349() }; +branch_align() -> (); +struct_construct() -> ([9]); +enum_init>, 1>([9]) -> ([10]); +store_temp>>([5]) -> ([7]); +store_temp>>([10]) -> ([8]); +struct_construct>([7]) -> ([11]); +store_temp>([11]) -> ([11]); +enum_match>>([8]) { fallthrough([12]) 2371([13]) }; +branch_align() -> (); +unbox([12]) -> ([14]); +rename([14]) -> ([15]); +store_temp([0]) -> ([18]); +store_temp([15]) -> ([19]); +function_call([18], [19]) -> ([16], [17]); +enum_match>([17]) { fallthrough([20]) 2365([21]) }; +branch_align() -> (); +enum_init, 0>([20]) -> ([22]); +store_temp([16]) -> ([23]); +store_temp>([11]) -> ([24]); +store_temp>([22]) -> ([25]); +return([23], [24], [25]); +branch_align() -> (); +enum_init, 1>([21]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp>([11]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([13]) -> (); +struct_construct() -> ([30]); +enum_init, 1>([30]) -> ([31]); +store_temp([0]) -> ([32]); +store_temp>([11]) -> ([33]); +store_temp>([31]) -> ([34]); +return([32], [33], [34]); +struct_deconstruct([4]) -> ([10], [11], [12], [13], [14], [15]); +store_temp([1]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp([5]) -> ([22]); +function_call([19], [20], [21], [22]) -> ([16], [17], [18]); +enum_match>([18]) { fallthrough([23]) 2572([24]) }; +branch_align() -> (); +store_temp([16]) -> ([28]); +store_temp([17]) -> ([29]); +store_temp([11]) -> ([30]); +store_temp([6]) -> ([31]); +function_call([28], [29], [30], [31]) -> ([25], [26], [27]); +enum_match>([27]) { fallthrough([32]) 2556([33]) }; +branch_align() -> (); +store_temp([25]) -> ([37]); +store_temp([26]) -> ([38]); +store_temp([12]) -> ([39]); +store_temp([7]) -> ([40]); +function_call([37], [38], [39], [40]) -> ([34], [35], [36]); +enum_match>([36]) { fallthrough([41]) 2541([42]) }; +branch_align() -> (); +dup([9]) -> ([9], [44]); +contract_address_to_felt252([44]) -> ([43]); +snapshot_take([43]) -> ([45], [46]); +drop([45]) -> (); +felt252_const<0>() -> ([47]); +snapshot_take([47]) -> ([48], [49]); +drop([48]) -> (); +rename([46]) -> ([50]); +rename([49]) -> ([51]); +felt252_sub([50], [51]) -> ([52]); +struct_deconstruct>([23]) -> ([53], [54]); +drop([54]) -> (); +struct_deconstruct>([32]) -> ([55], [56]); +drop([56]) -> (); +struct_deconstruct>([41]) -> ([57], [58]); +drop([58]) -> (); +store_temp([52]) -> ([52]); +felt252_is_zero([52]) { fallthrough() 2424([59]) }; +branch_align() -> (); +struct_construct() -> ([60]); +enum_init([60]) -> ([61]); +store_temp([61]) -> ([62]); +jump() { 2429() }; +branch_align() -> (); +drop>([59]) -> (); +struct_construct() -> ([63]); +enum_init([63]) -> ([64]); +store_temp([64]) -> ([62]); +bool_not_impl([62]) -> ([65]); +store_temp([65]) -> ([65]); +enum_match([65]) { fallthrough([66]) 2455([67]) }; +branch_align() -> (); +drop([66]) -> (); +drop([9]) -> (); +drop([55]) -> (); +drop([53]) -> (); +drop([8]) -> (); +drop([57]) -> (); +drop([15]) -> (); +drop([14]) -> (); +drop([13]) -> (); +array_new() -> ([68]); +felt252_const<7300388948442106731950660484798539862217172507820428101544021685107>() -> ([69]); +store_temp([69]) -> ([69]); +array_append([68], [69]) -> ([70]); +struct_construct() -> ([71]); +struct_construct>>([71], [70]) -> ([72]); +enum_init, 1>([72]) -> ([73]); +store_temp([0]) -> ([74]); +store_temp([34]) -> ([75]); +store_temp([2]) -> ([76]); +store_temp([35]) -> ([77]); +store_temp>([73]) -> ([78]); +return([74], [75], [76], [77], [78]); +branch_align() -> (); +drop([67]) -> (); +store_temp([34]) -> ([82]); +store_temp([35]) -> ([83]); +store_temp([13]) -> ([84]); +dup([8]) -> ([8], [85]); +store_temp([85]) -> ([85]); +function_call([82], [83], [84], [85]) -> ([79], [80], [81]); +enum_match>([81]) { fallthrough([86]) 2526([87]) }; +branch_align() -> (); +store_temp([0]) -> ([93]); +store_temp([79]) -> ([94]); +store_temp([2]) -> ([95]); +store_temp([80]) -> ([96]); +store_temp([14]) -> ([97]); +dup([9]) -> ([9], [98]); +store_temp([98]) -> ([98]); +dup([8]) -> ([8], [99]); +store_temp([99]) -> ([99]); +function_call([93], [94], [95], [96], [97], [98], [99]) -> ([88], [89], [90], [91], [92]); +enum_match>([92]) { fallthrough([100]) 2511([101]) }; +branch_align() -> (); +contract_address_const<0>() -> ([102]); +struct_deconstruct>([86]) -> ([103], [104]); +drop([104]) -> (); +struct_deconstruct>([100]) -> ([105], [106]); +drop([106]) -> (); +struct_construct([102], [9], [8]) -> ([107]); +enum_init([107]) -> ([108]); +struct_construct([53], [55], [57], [103], [105], [15]) -> ([109]); +store_temp([89]) -> ([113]); +store_temp([91]) -> ([114]); +store_temp([109]) -> ([115]); +store_temp([108]) -> ([116]); +function_call>>([113], [114], [115], [116]) -> ([110], [111], [112]); +enum_match>([112]) { fallthrough([117]) 2503([118]) }; +branch_align() -> (); +struct_deconstruct>([117]) -> ([119], [120]); +drop([120]) -> (); +struct_construct() -> ([121]); +struct_construct>([119], [121]) -> ([122]); +enum_init, 0>([122]) -> ([123]); +store_temp([88]) -> ([124]); +store_temp([110]) -> ([125]); +store_temp([90]) -> ([126]); +store_temp([111]) -> ([127]); +store_temp>([123]) -> ([128]); +return([124], [125], [126], [127], [128]); +branch_align() -> (); +enum_init, 1>([118]) -> ([129]); +store_temp([88]) -> ([130]); +store_temp([110]) -> ([131]); +store_temp([90]) -> ([132]); +store_temp([111]) -> ([133]); +store_temp>([129]) -> ([134]); +return([130], [131], [132], [133], [134]); +branch_align() -> (); +drop([53]) -> (); +drop([15]) -> (); +drop>([86]) -> (); +drop([9]) -> (); +drop([57]) -> (); +drop([55]) -> (); +drop([8]) -> (); +enum_init, 1>([101]) -> ([135]); +store_temp([88]) -> ([136]); +store_temp([89]) -> ([137]); +store_temp([90]) -> ([138]); +store_temp([91]) -> ([139]); +store_temp>([135]) -> ([140]); +return([136], [137], [138], [139], [140]); +branch_align() -> (); +drop([9]) -> (); +drop([55]) -> (); +drop([53]) -> (); +drop([8]) -> (); +drop([57]) -> (); +drop([15]) -> (); +drop([14]) -> (); +enum_init, 1>([87]) -> ([141]); +store_temp([0]) -> ([142]); +store_temp([79]) -> ([143]); +store_temp([2]) -> ([144]); +store_temp([80]) -> ([145]); +store_temp>([141]) -> ([146]); +return([142], [143], [144], [145], [146]); +branch_align() -> (); +drop([9]) -> (); +drop([13]) -> (); +drop>([32]) -> (); +drop([8]) -> (); +drop>([23]) -> (); +drop([15]) -> (); +drop([14]) -> (); +enum_init, 1>([42]) -> ([147]); +store_temp([0]) -> ([148]); +store_temp([34]) -> ([149]); +store_temp([2]) -> ([150]); +store_temp([35]) -> ([151]); +store_temp>([147]) -> ([152]); +return([148], [149], [150], [151], [152]); +branch_align() -> (); +drop([14]) -> (); +drop([15]) -> (); +drop([9]) -> (); +drop([13]) -> (); +drop([8]) -> (); +drop>([23]) -> (); +drop([7]) -> (); +drop([12]) -> (); +enum_init, 1>([33]) -> ([153]); +store_temp([0]) -> ([154]); +store_temp([25]) -> ([155]); +store_temp([2]) -> ([156]); +store_temp([26]) -> ([157]); +store_temp>([153]) -> ([158]); +return([154], [155], [156], [157], [158]); +branch_align() -> (); +drop([14]) -> (); +drop([15]) -> (); +drop([9]) -> (); +drop([13]) -> (); +drop([12]) -> (); +drop([8]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([11]) -> (); +enum_init, 1>([24]) -> ([159]); +store_temp([0]) -> ([160]); +store_temp([16]) -> ([161]); +store_temp([2]) -> ([162]); +store_temp([17]) -> ([163]); +store_temp>([159]) -> ([164]); +return([160], [161], [162], [163], [164]); +drop([2]) -> (); +storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>() -> ([3]); +storage_address_from_base([3]) -> ([4]); +u32_const<0>() -> ([5]); +store_temp([5]) -> ([5]); +store_temp([4]) -> ([4]); +storage_read_syscall([0], [1], [5], [4]) { fallthrough([6], [7], [8]) 2602([9], [10], [11]) }; +branch_align() -> (); +enum_init>, 0>([8]) -> ([12]); +store_temp([6]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>>([12]) -> ([15]); +jump() { 2607() }; +branch_align() -> (); +enum_init>, 1>([11]) -> ([16]); +store_temp([9]) -> ([13]); +store_temp([10]) -> ([14]); +store_temp>>([16]) -> ([15]); +rename>>([15]) -> ([18]); +function_call::unwrap_syscall>([18]) -> ([17]); +enum_match>([17]) { fallthrough([19]) 2618([20]) }; +branch_align() -> (); +struct_deconstruct>([19]) -> ([21]); +struct_construct>([21]) -> ([22]); +enum_init, 0>([22]) -> ([23]); +store_temp([13]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +branch_align() -> (); +enum_init, 1>([20]) -> ([27]); +store_temp([13]) -> ([28]); +store_temp([14]) -> ([29]); +store_temp>([27]) -> ([30]); +return([28], [29], [30]); +drop([2]) -> (); +storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>() -> ([3]); +storage_address_from_base([3]) -> ([4]); +u32_const<0>() -> ([5]); +store_temp([5]) -> ([5]); +store_temp([4]) -> ([4]); +storage_read_syscall([0], [1], [5], [4]) { fallthrough([6], [7], [8]) 2637([9], [10], [11]) }; +branch_align() -> (); +enum_init>, 0>([8]) -> ([12]); +store_temp([6]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>>([12]) -> ([15]); +jump() { 2642() }; +branch_align() -> (); +enum_init>, 1>([11]) -> ([16]); +store_temp([9]) -> ([13]); +store_temp([10]) -> ([14]); +store_temp>>([16]) -> ([15]); +rename>>([15]) -> ([18]); +function_call::unwrap_syscall>([18]) -> ([17]); +enum_match>([17]) { fallthrough([19]) 2653([20]) }; +branch_align() -> (); +struct_deconstruct>([19]) -> ([21]); +struct_construct>([21]) -> ([22]); +enum_init, 0>([22]) -> ([23]); +store_temp([13]) -> ([24]); +store_temp([14]) -> ([25]); +store_temp>([23]) -> ([26]); +return([24], [25], [26]); +branch_align() -> (); +enum_init, 1>([20]) -> ([27]); +store_temp([13]) -> ([28]); +store_temp([14]) -> ([29]); +store_temp>([27]) -> ([30]); +return([28], [29], [30]); +drop([3]) -> (); +storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>() -> ([4]); +u32_const<0>() -> ([5]); +store_temp([0]) -> ([10]); +store_temp([1]) -> ([11]); +store_temp([2]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([10], [11], [12], [13], [14]) -> ([6], [7], [8], [9]); +enum_match>,)>>([9]) { fallthrough([15]) 2690([16]) }; +branch_align() -> (); +struct_deconstruct>>>([15]) -> ([17]); +store_temp>>([17]) -> ([19]); +function_call::unwrap_syscall>([19]) -> ([18]); +enum_match>([18]) { fallthrough([20]) 2683([21]) }; +branch_align() -> (); +struct_deconstruct>([20]) -> ([22]); +struct_construct>([22]) -> ([23]); +enum_init, 0>([23]) -> ([24]); +store_temp([6]) -> ([25]); +store_temp([7]) -> ([26]); +store_temp([8]) -> ([27]); +store_temp>([24]) -> ([28]); +return([25], [26], [27], [28]); +branch_align() -> (); +enum_init, 1>([21]) -> ([29]); +store_temp([6]) -> ([30]); +store_temp([7]) -> ([31]); +store_temp([8]) -> ([32]); +store_temp>([29]) -> ([33]); +return([30], [31], [32], [33]); +branch_align() -> (); +enum_init, 1>([16]) -> ([34]); +store_temp([6]) -> ([35]); +store_temp([7]) -> ([36]); +store_temp([8]) -> ([37]); +store_temp>([34]) -> ([38]); +return([35], [36], [37], [38]); +drop([3]) -> (); +storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>() -> ([4]); +u32_const<0>() -> ([5]); +store_temp([0]) -> ([10]); +store_temp([1]) -> ([11]); +store_temp([2]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([10], [11], [12], [13], [14]) -> ([6], [7], [8], [9]); +enum_match>,)>>([9]) { fallthrough([15]) 2728([16]) }; +branch_align() -> (); +struct_deconstruct>>>([15]) -> ([17]); +store_temp>>([17]) -> ([19]); +function_call::unwrap_syscall>([19]) -> ([18]); +enum_match>([18]) { fallthrough([20]) 2721([21]) }; +branch_align() -> (); +struct_deconstruct>([20]) -> ([22]); +struct_construct>([22]) -> ([23]); +enum_init, 0>([23]) -> ([24]); +store_temp([6]) -> ([25]); +store_temp([7]) -> ([26]); +store_temp([8]) -> ([27]); +store_temp>([24]) -> ([28]); +return([25], [26], [27], [28]); +branch_align() -> (); +enum_init, 1>([21]) -> ([29]); +store_temp([6]) -> ([30]); +store_temp([7]) -> ([31]); +store_temp([8]) -> ([32]); +store_temp>([29]) -> ([33]); +return([30], [31], [32], [33]); +branch_align() -> (); +enum_init, 1>([16]) -> ([34]); +store_temp([6]) -> ([35]); +store_temp([7]) -> ([36]); +store_temp([8]) -> ([37]); +store_temp>([34]) -> ([38]); +return([35], [36], [37], [38]); +rename([0]) -> ([2]); +u128_to_felt252([2]) -> ([3]); +snapshot_take([3]) -> ([4], [5]); +drop([4]) -> (); +store_temp([5]) -> ([8]); +store_temp>([1]) -> ([9]); +function_call([8], [9]) -> ([6], [7]); +drop([7]) -> (); +struct_construct() -> ([10]); +store_temp>([6]) -> ([11]); +store_temp([10]) -> ([12]); +return([11], [12]); +store_temp([0]) -> ([9]); +store_temp([2]) -> ([10]); +store_temp([4]) -> ([11]); +store_temp([5]) -> ([12]); +function_call([9], [10], [11], [12]) -> ([6], [7], [8]); +u32_const<0>() -> ([13]); +store_temp([6]) -> ([18]); +store_temp([1]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([13]) -> ([21]); +store_temp([8]) -> ([22]); +function_call([18], [19], [20], [21], [22]) -> ([14], [15], [16], [17]); +enum_match>,)>>([17]) { fallthrough([23]) 2783([24]) }; +branch_align() -> (); +struct_deconstruct>>>([23]) -> ([25]); +store_temp>>([25]) -> ([27]); +function_call::unwrap_syscall>([27]) -> ([26]); +enum_match>([26]) { fallthrough([28]) 2775([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30]); +struct_construct>([30]) -> ([31]); +enum_init, 0>([31]) -> ([32]); +store_temp([14]) -> ([33]); +store_temp([15]) -> ([34]); +store_temp([7]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +enum_init, 1>([29]) -> ([38]); +store_temp([14]) -> ([39]); +store_temp([15]) -> ([40]); +store_temp([7]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp>([38]) -> ([43]); +return([39], [40], [41], [42], [43]); +branch_align() -> (); +enum_init, 1>([24]) -> ([44]); +store_temp([14]) -> ([45]); +store_temp([15]) -> ([46]); +store_temp([7]) -> ([47]); +store_temp([16]) -> ([48]); +store_temp>([44]) -> ([49]); +return([45], [46], [47], [48], [49]); +store_temp([0]) -> ([9]); +store_temp([2]) -> ([10]); +store_temp([4]) -> ([11]); +store_temp>([5]) -> ([12]); +function_call([9], [10], [11], [12]) -> ([6], [7], [8]); +u32_const<0>() -> ([13]); +store_temp([6]) -> ([18]); +store_temp([1]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp([13]) -> ([21]); +store_temp([8]) -> ([22]); +function_call([18], [19], [20], [21], [22]) -> ([14], [15], [16], [17]); +enum_match>,)>>([17]) { fallthrough([23]) 2827([24]) }; +branch_align() -> (); +struct_deconstruct>>>([23]) -> ([25]); +store_temp>>([25]) -> ([27]); +function_call::unwrap_syscall>([27]) -> ([26]); +enum_match>([26]) { fallthrough([28]) 2819([29]) }; +branch_align() -> (); +struct_deconstruct>([28]) -> ([30]); +struct_construct>([30]) -> ([31]); +enum_init, 0>([31]) -> ([32]); +store_temp([14]) -> ([33]); +store_temp([15]) -> ([34]); +store_temp([7]) -> ([35]); +store_temp([16]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +enum_init, 1>([29]) -> ([38]); +store_temp([14]) -> ([39]); +store_temp([15]) -> ([40]); +store_temp([7]) -> ([41]); +store_temp([16]) -> ([42]); +store_temp>([38]) -> ([43]); +return([39], [40], [41], [42], [43]); +branch_align() -> (); +enum_init, 1>([24]) -> ([44]); +store_temp([14]) -> ([45]); +store_temp([15]) -> ([46]); +store_temp([7]) -> ([47]); +store_temp([16]) -> ([48]); +store_temp>([44]) -> ([49]); +return([45], [46], [47], [48], [49]); +struct_deconstruct>([1]) -> ([2]); +array_snapshot_pop_front([2]) { fallthrough([3], [4]) 2842([5]) }; +branch_align() -> (); +enum_init>, 0>([4]) -> ([6]); +store_temp>>([3]) -> ([7]); +store_temp>>([6]) -> ([8]); +jump() { 2847() }; +branch_align() -> (); +struct_construct() -> ([9]); +enum_init>, 1>([9]) -> ([10]); +store_temp>>([5]) -> ([7]); +store_temp>>([10]) -> ([8]); +struct_construct>([7]) -> ([11]); +store_temp>([11]) -> ([11]); +enum_match>>([8]) { fallthrough([12]) 2869([13]) }; +branch_align() -> (); +unbox([12]) -> ([14]); +rename([14]) -> ([15]); +store_temp([0]) -> ([18]); +store_temp([15]) -> ([19]); +function_call([18], [19]) -> ([16], [17]); +enum_match>([17]) { fallthrough([20]) 2863([21]) }; +branch_align() -> (); +enum_init, 0>([20]) -> ([22]); +store_temp([16]) -> ([23]); +store_temp>([11]) -> ([24]); +store_temp>([22]) -> ([25]); +return([23], [24], [25]); +branch_align() -> (); +enum_init, 1>([21]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp>([11]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([13]) -> (); +struct_construct() -> ([30]); +enum_init, 1>([30]) -> ([31]); +store_temp([0]) -> ([32]); +store_temp>([11]) -> ([33]); +store_temp>([31]) -> ([34]); +return([32], [33], [34]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +function_call([5], [6]) -> ([2], [3], [4]); +enum_match,)>>([4]) { fallthrough([7]) 2895([8]) }; +branch_align() -> (); +struct_deconstruct>>([7]) -> ([9]); +unbox([9]) -> ([10]); +struct_deconstruct([10]) -> ([11], [12], [13], [14], [15]); +drop>([11]) -> (); +drop>([12]) -> (); +drop([14]) -> (); +drop([15]) -> (); +struct_construct>([13]) -> ([16]); +enum_init, 0>([16]) -> ([17]); +store_temp([2]) -> ([18]); +store_temp([3]) -> ([19]); +store_temp>([17]) -> ([20]); +return([18], [19], [20]); +branch_align() -> (); +enum_init, 1>([8]) -> ([21]); +store_temp([2]) -> ([22]); +store_temp([3]) -> ([23]); +store_temp>([21]) -> ([24]); +return([22], [23], [24]); +dup([5]) -> ([5], [9]); +contract_address_to_felt252([9]) -> ([8]); +snapshot_take([8]) -> ([10], [11]); +drop([10]) -> (); +felt252_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +felt252_sub([15], [16]) -> ([17]); +store_temp([17]) -> ([17]); +felt252_is_zero([17]) { fallthrough() 2918([18]) }; +branch_align() -> (); +struct_construct() -> ([19]); +enum_init([19]) -> ([20]); +store_temp([20]) -> ([21]); +jump() { 2923() }; +branch_align() -> (); +drop>([18]) -> (); +struct_construct() -> ([22]); +enum_init([22]) -> ([23]); +store_temp([23]) -> ([21]); +bool_not_impl([21]) -> ([24]); +store_temp([24]) -> ([24]); +enum_match([24]) { fallthrough([25]) 2945([26]) }; +branch_align() -> (); +drop([25]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +array_new() -> ([27]); +felt252_const<25936191677694277552149992725516921697451103245639728>() -> ([28]); +store_temp([28]) -> ([28]); +array_append([27], [28]) -> ([29]); +struct_construct() -> ([30]); +struct_construct>>([30], [29]) -> ([31]); +enum_init, 1>([31]) -> ([32]); +store_temp([0]) -> ([33]); +store_temp([1]) -> ([34]); +store_temp([2]) -> ([35]); +store_temp([3]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +drop([26]) -> (); +dup([6]) -> ([6], [39]); +contract_address_to_felt252([39]) -> ([38]); +snapshot_take([38]) -> ([40], [41]); +drop([40]) -> (); +felt252_const<0>() -> ([42]); +snapshot_take([42]) -> ([43], [44]); +drop([43]) -> (); +rename([41]) -> ([45]); +rename([44]) -> ([46]); +felt252_sub([45], [46]) -> ([47]); +store_temp([47]) -> ([47]); +felt252_is_zero([47]) { fallthrough() 2964([48]) }; +branch_align() -> (); +struct_construct() -> ([49]); +enum_init([49]) -> ([50]); +store_temp([50]) -> ([51]); +jump() { 2969() }; +branch_align() -> (); +drop>([48]) -> (); +struct_construct() -> ([52]); +enum_init([52]) -> ([53]); +store_temp([53]) -> ([51]); +bool_not_impl([51]) -> ([54]); +store_temp([54]) -> ([54]); +enum_match([54]) { fallthrough([55]) 2991([56]) }; +branch_align() -> (); +drop([55]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +array_new() -> ([57]); +felt252_const<395754877894504967531585582359572169455970492464>() -> ([58]); +store_temp([58]) -> ([58]); +array_append([57], [58]) -> ([59]); +struct_construct() -> ([60]); +struct_construct>>([60], [59]) -> ([61]); +enum_init, 1>([61]) -> ([62]); +store_temp([0]) -> ([63]); +store_temp([1]) -> ([64]); +store_temp([2]) -> ([65]); +store_temp([3]) -> ([66]); +store_temp>([62]) -> ([67]); +return([63], [64], [65], [66], [67]); +branch_align() -> (); +drop([56]) -> (); +struct_deconstruct([4]) -> ([68], [69], [70], [71], [72], [73]); +snapshot_take([72]) -> ([74], [75]); +store_temp([0]) -> ([81]); +store_temp([1]) -> ([82]); +store_temp([2]) -> ([83]); +store_temp([3]) -> ([84]); +store_temp([75]) -> ([85]); +dup([5]) -> ([5], [86]); +store_temp([86]) -> ([86]); +function_call([81], [82], [83], [84], [85], [86]) -> ([76], [77], [78], [79], [80]); +enum_match>([80]) { fallthrough([87]) 3171([88]) }; +branch_align() -> (); +struct_deconstruct>([87]) -> ([89]); +store_temp([76]) -> ([92]); +store_temp([89]) -> ([93]); +dup([7]) -> ([7], [94]); +store_temp([94]) -> ([94]); +function_call([92], [93], [94]) -> ([90], [91]); +enum_match>([91]) { fallthrough([95]) 3154([96]) }; +branch_align() -> (); +struct_deconstruct>([95]) -> ([97]); +store_temp([90]) -> ([103]); +store_temp([77]) -> ([104]); +store_temp([78]) -> ([105]); +store_temp([79]) -> ([106]); +store_temp([74]) -> ([107]); +dup([5]) -> ([5], [108]); +store_temp([108]) -> ([108]); +store_temp([97]) -> ([109]); +function_call([103], [104], [105], [106], [107], [108], [109]) -> ([98], [99], [100], [101], [102]); +enum_match>([102]) { fallthrough([110]) 3138([111]) }; +branch_align() -> (); +struct_deconstruct>([110]) -> ([112], [113]); +drop([113]) -> (); +snapshot_take([112]) -> ([114], [115]); +store_temp([98]) -> ([121]); +store_temp([99]) -> ([122]); +store_temp([100]) -> ([123]); +store_temp([101]) -> ([124]); +store_temp([115]) -> ([125]); +dup([6]) -> ([6], [126]); +store_temp([126]) -> ([126]); +function_call([121], [122], [123], [124], [125], [126]) -> ([116], [117], [118], [119], [120]); +enum_match>([120]) { fallthrough([127]) 3121([128]) }; +branch_align() -> (); +struct_deconstruct>([127]) -> ([129]); +store_temp([116]) -> ([132]); +store_temp([129]) -> ([133]); +dup([7]) -> ([7], [134]); +store_temp([134]) -> ([134]); +function_call([132], [133], [134]) -> ([130], [131]); +enum_match>([131]) { fallthrough([135]) 3104([136]) }; +branch_align() -> (); +struct_deconstruct>([135]) -> ([137]); +store_temp([130]) -> ([143]); +store_temp([117]) -> ([144]); +store_temp([118]) -> ([145]); +store_temp([119]) -> ([146]); +store_temp([114]) -> ([147]); +dup([6]) -> ([6], [148]); +store_temp([148]) -> ([148]); +store_temp([137]) -> ([149]); +function_call([143], [144], [145], [146], [147], [148], [149]) -> ([138], [139], [140], [141], [142]); +enum_match>([142]) { fallthrough([150]) 3088([151]) }; +branch_align() -> (); +struct_deconstruct>([150]) -> ([152], [153]); +drop([153]) -> (); +struct_construct([5], [6], [7]) -> ([154]); +struct_construct([68], [69], [70], [71], [152], [73]) -> ([155]); +store_temp([139]) -> ([159]); +store_temp([141]) -> ([160]); +store_temp([155]) -> ([161]); +store_temp([154]) -> ([162]); +function_call>([159], [160], [161], [162]) -> ([156], [157], [158]); +enum_match>([158]) { fallthrough([163]) 3080([164]) }; +branch_align() -> (); +struct_deconstruct>([163]) -> ([165], [166]); +drop([166]) -> (); +struct_construct() -> ([167]); +struct_construct>([165], [167]) -> ([168]); +enum_init, 0>([168]) -> ([169]); +store_temp([138]) -> ([170]); +store_temp([156]) -> ([171]); +store_temp([140]) -> ([172]); +store_temp([157]) -> ([173]); +store_temp>([169]) -> ([174]); +return([170], [171], [172], [173], [174]); +branch_align() -> (); +enum_init, 1>([164]) -> ([175]); +store_temp([138]) -> ([176]); +store_temp([156]) -> ([177]); +store_temp([140]) -> ([178]); +store_temp([157]) -> ([179]); +store_temp>([175]) -> ([180]); +return([176], [177], [178], [179], [180]); +branch_align() -> (); +drop([68]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([70]) -> (); +drop([69]) -> (); +drop([7]) -> (); +drop([6]) -> (); +enum_init, 1>([151]) -> ([181]); +store_temp([138]) -> ([182]); +store_temp([139]) -> ([183]); +store_temp([140]) -> ([184]); +store_temp([141]) -> ([185]); +store_temp>([181]) -> ([186]); +return([182], [183], [184], [185], [186]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([114]) -> (); +enum_init, 1>([136]) -> ([187]); +store_temp([130]) -> ([188]); +store_temp([117]) -> ([189]); +store_temp([118]) -> ([190]); +store_temp([119]) -> ([191]); +store_temp>([187]) -> ([192]); +return([188], [189], [190], [191], [192]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([114]) -> (); +enum_init, 1>([128]) -> ([193]); +store_temp([116]) -> ([194]); +store_temp([117]) -> ([195]); +store_temp([118]) -> ([196]); +store_temp([119]) -> ([197]); +store_temp>([193]) -> ([198]); +return([194], [195], [196], [197], [198]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +enum_init, 1>([111]) -> ([199]); +store_temp([98]) -> ([200]); +store_temp([99]) -> ([201]); +store_temp([100]) -> ([202]); +store_temp([101]) -> ([203]); +store_temp>([199]) -> ([204]); +return([200], [201], [202], [203], [204]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([74]) -> (); +enum_init, 1>([96]) -> ([205]); +store_temp([90]) -> ([206]); +store_temp([77]) -> ([207]); +store_temp([78]) -> ([208]); +store_temp([79]) -> ([209]); +store_temp>([205]) -> ([210]); +return([206], [207], [208], [209], [210]); +branch_align() -> (); +drop([70]) -> (); +drop([7]) -> (); +drop([68]) -> (); +drop([6]) -> (); +drop([69]) -> (); +drop([73]) -> (); +drop([5]) -> (); +drop([71]) -> (); +drop([74]) -> (); +enum_init, 1>([88]) -> ([211]); +store_temp([76]) -> ([212]); +store_temp([77]) -> ([213]); +store_temp([78]) -> ([214]); +store_temp([79]) -> ([215]); +store_temp>([211]) -> ([216]); +return([212], [213], [214], [215], [216]); +struct_deconstruct([4]) -> ([8], [9], [10], [11], [12], [13]); +snapshot_take([13]) -> ([14], [15]); +dup([5]) -> ([5], [16]); +dup([6]) -> ([6], [17]); +struct_construct>([16], [17]) -> ([18]); +store_temp([0]) -> ([24]); +store_temp([1]) -> ([25]); +store_temp([2]) -> ([26]); +store_temp([3]) -> ([27]); +store_temp([15]) -> ([28]); +store_temp>([18]) -> ([29]); +function_call([24], [25], [26], [27], [28], [29]) -> ([19], [20], [21], [22], [23]); +enum_match>([23]) { fallthrough([30]) 3312([31]) }; +branch_align() -> (); +u128_const<340282366920938463463374607431768211455>() -> ([32]); +snapshot_take([32]) -> ([33], [34]); +struct_deconstruct>([30]) -> ([35]); +struct_deconstruct([35]) -> ([36], [37]); +snapshot_take([36]) -> ([38], [39]); +rename([39]) -> ([40]); +rename([34]) -> ([41]); +u128_eq([40], [41]) { fallthrough() 3218() }; +branch_align() -> (); +drop([33]) -> (); +struct_construct() -> ([42]); +enum_init([42]) -> ([43]); +struct_construct([38], [37]) -> ([44]); +store_temp([44]) -> ([45]); +store_temp([43]) -> ([46]); +jump() { 3237() }; +branch_align() -> (); +snapshot_take([37]) -> ([47], [48]); +snapshot_take([33]) -> ([49], [50]); +drop([49]) -> (); +rename([48]) -> ([51]); +rename([50]) -> ([52]); +u128_eq([51], [52]) { fallthrough() 3230() }; +branch_align() -> (); +struct_construct() -> ([53]); +enum_init([53]) -> ([54]); +store_temp([54]) -> ([55]); +jump() { 3234() }; +branch_align() -> (); +struct_construct() -> ([56]); +enum_init([56]) -> ([57]); +store_temp([57]) -> ([55]); +struct_construct([38], [47]) -> ([58]); +store_temp([58]) -> ([45]); +store_temp([55]) -> ([46]); +enum_match([46]) { fallthrough([59]) 3291([60]) }; +branch_align() -> (); +drop([59]) -> (); +store_temp([19]) -> ([63]); +store_temp([45]) -> ([64]); +store_temp([7]) -> ([65]); +function_call([63], [64], [65]) -> ([61], [62]); +enum_match>([62]) { fallthrough([66]) 3275([67]) }; +branch_align() -> (); +struct_deconstruct>([66]) -> ([68]); +struct_construct([8], [9], [10], [11], [12], [14]) -> ([69]); +store_temp([61]) -> ([75]); +store_temp([20]) -> ([76]); +store_temp([21]) -> ([77]); +store_temp([22]) -> ([78]); +store_temp([69]) -> ([79]); +store_temp([5]) -> ([80]); +store_temp([6]) -> ([81]); +store_temp([68]) -> ([82]); +function_call([75], [76], [77], [78], [79], [80], [81], [82]) -> ([70], [71], [72], [73], [74]); +enum_match>([74]) { fallthrough([83]) 3267([84]) }; +branch_align() -> (); +struct_deconstruct>([83]) -> ([85], [86]); +drop([86]) -> (); +store_temp([70]) -> ([87]); +store_temp([71]) -> ([88]); +store_temp([72]) -> ([89]); +store_temp([73]) -> ([90]); +store_temp([85]) -> ([91]); +jump() { 3303() }; +branch_align() -> (); +enum_init, 1>([84]) -> ([92]); +store_temp([70]) -> ([93]); +store_temp([71]) -> ([94]); +store_temp([72]) -> ([95]); +store_temp([73]) -> ([96]); +store_temp>([92]) -> ([97]); +return([93], [94], [95], [96], [97]); +branch_align() -> (); +drop([8]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([14]) -> (); +drop([12]) -> (); +drop([11]) -> (); +drop([10]) -> (); +drop([9]) -> (); +enum_init, 1>([67]) -> ([98]); +store_temp([61]) -> ([99]); +store_temp([20]) -> ([100]); +store_temp([21]) -> ([101]); +store_temp([22]) -> ([102]); +store_temp>([98]) -> ([103]); +return([99], [100], [101], [102], [103]); +branch_align() -> (); +drop([60]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([7]) -> (); +drop([45]) -> (); +struct_construct([8], [9], [10], [11], [12], [14]) -> ([104]); +store_temp([19]) -> ([87]); +store_temp([20]) -> ([88]); +store_temp([21]) -> ([89]); +store_temp([22]) -> ([90]); +store_temp([104]) -> ([91]); +struct_construct() -> ([105]); +struct_construct>([91], [105]) -> ([106]); +enum_init, 0>([106]) -> ([107]); +store_temp([87]) -> ([108]); +store_temp([88]) -> ([109]); +store_temp([89]) -> ([110]); +store_temp([90]) -> ([111]); +store_temp>([107]) -> ([112]); +return([108], [109], [110], [111], [112]); +branch_align() -> (); +drop([8]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([9]) -> (); +drop([14]) -> (); +drop([12]) -> (); +drop([11]) -> (); +drop([10]) -> (); +drop([7]) -> (); +enum_init, 1>([31]) -> ([113]); +store_temp([19]) -> ([114]); +store_temp([20]) -> ([115]); +store_temp([21]) -> ([116]); +store_temp([22]) -> ([117]); +store_temp>([113]) -> ([118]); +return([114], [115], [116], [117], [118]); +dup([6]) -> ([6], [9]); +contract_address_to_felt252([9]) -> ([8]); +snapshot_take([8]) -> ([10], [11]); +drop([10]) -> (); +felt252_const<0>() -> ([12]); +snapshot_take([12]) -> ([13], [14]); +drop([13]) -> (); +rename([11]) -> ([15]); +rename([14]) -> ([16]); +felt252_sub([15], [16]) -> ([17]); +store_temp([17]) -> ([17]); +felt252_is_zero([17]) { fallthrough() 3346([18]) }; +branch_align() -> (); +struct_construct() -> ([19]); +enum_init([19]) -> ([20]); +store_temp([20]) -> ([21]); +jump() { 3351() }; +branch_align() -> (); +drop>([18]) -> (); +struct_construct() -> ([22]); +enum_init([22]) -> ([23]); +store_temp([23]) -> ([21]); +bool_not_impl([21]) -> ([24]); +store_temp([24]) -> ([24]); +enum_match([24]) { fallthrough([25]) 3373([26]) }; +branch_align() -> (); +drop([25]) -> (); +drop([7]) -> (); +drop([6]) -> (); +drop([5]) -> (); +drop([4]) -> (); +array_new() -> ([27]); +felt252_const<101313248740993271302566317381896466254801065025584>() -> ([28]); +store_temp([28]) -> ([28]); +array_append([27], [28]) -> ([29]); +struct_construct() -> ([30]); +struct_construct>>([30], [29]) -> ([31]); +enum_init, 1>([31]) -> ([32]); +store_temp([0]) -> ([33]); +store_temp([1]) -> ([34]); +store_temp([2]) -> ([35]); +store_temp([3]) -> ([36]); +store_temp>([32]) -> ([37]); +return([33], [34], [35], [36], [37]); +branch_align() -> (); +drop([26]) -> (); +struct_deconstruct([4]) -> ([38], [39], [40], [41], [42], [43]); +dup([5]) -> ([5], [44]); +dup([6]) -> ([6], [45]); +struct_construct>([44], [45]) -> ([46]); +store_temp([0]) -> ([52]); +store_temp([1]) -> ([53]); +store_temp([2]) -> ([54]); +store_temp([3]) -> ([55]); +store_temp([43]) -> ([56]); +store_temp>([46]) -> ([57]); +dup([7]) -> ([7], [58]); +store_temp([58]) -> ([58]); +function_call([52], [53], [54], [55], [56], [57], [58]) -> ([47], [48], [49], [50], [51]); +enum_match>([51]) { fallthrough([59]) 3420([60]) }; +branch_align() -> (); +struct_deconstruct>([59]) -> ([61], [62]); +drop([62]) -> (); +struct_construct([5], [6], [7]) -> ([63]); +struct_construct([38], [39], [40], [41], [42], [61]) -> ([64]); +store_temp([48]) -> ([68]); +store_temp([50]) -> ([69]); +store_temp([64]) -> ([70]); +store_temp([63]) -> ([71]); +function_call>([68], [69], [70], [71]) -> ([65], [66], [67]); +enum_match>([67]) { fallthrough([72]) 3412([73]) }; +branch_align() -> (); +struct_deconstruct>([72]) -> ([74], [75]); +drop([75]) -> (); +struct_construct() -> ([76]); +struct_construct>([74], [76]) -> ([77]); +enum_init, 0>([77]) -> ([78]); +store_temp([47]) -> ([79]); +store_temp([65]) -> ([80]); +store_temp([49]) -> ([81]); +store_temp([66]) -> ([82]); +store_temp>([78]) -> ([83]); +return([79], [80], [81], [82], [83]); +branch_align() -> (); +enum_init, 1>([73]) -> ([84]); +store_temp([47]) -> ([85]); +store_temp([65]) -> ([86]); +store_temp([49]) -> ([87]); +store_temp([66]) -> ([88]); +store_temp>([84]) -> ([89]); +return([85], [86], [87], [88], [89]); +branch_align() -> (); +drop([38]) -> (); +drop([5]) -> (); +drop([42]) -> (); +drop([41]) -> (); +drop([40]) -> (); +drop([39]) -> (); +drop([7]) -> (); +drop([6]) -> (); +enum_init, 1>([60]) -> ([90]); +store_temp([47]) -> ([91]); +store_temp([48]) -> ([92]); +store_temp([49]) -> ([93]); +store_temp([50]) -> ([94]); +store_temp>([90]) -> ([95]); +return([91], [92], [93], [94], [95]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +enum_match>([4]) { fallthrough([8]) 3447([9]) }; +branch_align() -> (); +struct_construct>([8]) -> ([10]); +enum_init, 0>([10]) -> ([11]); +store_temp([3]) -> ([12]); +store_temp>([11]) -> ([13]); +return([12], [13]); +branch_align() -> (); +drop([9]) -> (); +array_new() -> ([14]); +felt252_const<39879774624079483812136948410799859986295>() -> ([15]); +store_temp([15]) -> ([15]); +array_append([14], [15]) -> ([16]); +struct_construct() -> ([17]); +struct_construct>>([17], [16]) -> ([18]); +enum_init, 1>([18]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp>([19]) -> ([21]); +return([20], [21]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +enum_match>([4]) { fallthrough([8]) 3470([9]) }; +branch_align() -> (); +struct_construct>([8]) -> ([10]); +enum_init, 0>([10]) -> ([11]); +store_temp([3]) -> ([12]); +store_temp>([11]) -> ([13]); +return([12], [13]); +branch_align() -> (); +drop([9]) -> (); +array_new() -> ([14]); +felt252_const<39879774624085075084607933104993585622903>() -> ([15]); +store_temp([15]) -> ([15]); +array_append([14], [15]) -> ([16]); +struct_construct() -> ([17]); +struct_construct>>([17], [16]) -> ([18]); +enum_init, 1>([18]) -> ([19]); +store_temp([3]) -> ([20]); +store_temp>([19]) -> ([21]); +return([20], [21]); +u8_try_from_felt252([0], [1]) { fallthrough([2], [3]) 3488([4]) }; +branch_align() -> (); +enum_init, 0>([3]) -> ([5]); +store_temp([2]) -> ([6]); +store_temp>([5]) -> ([7]); +jump() { 3493() }; +branch_align() -> (); +struct_construct() -> ([8]); +enum_init, 1>([8]) -> ([9]); +store_temp([4]) -> ([6]); +store_temp>([9]) -> ([7]); +rename([6]) -> ([10]); +rename>([7]) -> ([11]); +return([10], [11]); +storage_base_address_const<1528802474226268325865027367859591458315299653151958663884057507666229546336>() -> ([4]); +storage_address_from_base([4]) -> ([5]); +u32_const<0>() -> ([6]); +snapshot_take([2]) -> ([7], [8]); +drop([8]) -> (); +store_temp([6]) -> ([6]); +store_temp([5]) -> ([5]); +storage_write_syscall([0], [1], [6], [5], [3]) { fallthrough([9], [10]) 3511([11], [12], [13]) }; +branch_align() -> (); +struct_construct() -> ([14]); +enum_init>, 0>([14]) -> ([15]); +store_temp([9]) -> ([16]); +store_temp([10]) -> ([17]); +store_temp>>([15]) -> ([18]); +jump() { 3516() }; +branch_align() -> (); +enum_init>, 1>([13]) -> ([19]); +store_temp([11]) -> ([16]); +store_temp([12]) -> ([17]); +store_temp>>([19]) -> ([18]); +rename>>([18]) -> ([21]); +function_call::unwrap_syscall>([21]) -> ([20]); +enum_match>([20]) { fallthrough([22]) 3527([23]) }; +branch_align() -> (); +struct_deconstruct>([22]) -> ([24]); +struct_construct>([7], [24]) -> ([25]); +enum_init, 0>([25]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp([17]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([23]) -> ([30]); +store_temp([16]) -> ([31]); +store_temp([17]) -> ([32]); +store_temp>([30]) -> ([33]); +return([31], [32], [33]); +storage_base_address_const<944713526212149105522785400348068751682982210605126537021911324578866405028>() -> ([4]); +storage_address_from_base([4]) -> ([5]); +u32_const<0>() -> ([6]); +snapshot_take([2]) -> ([7], [8]); +drop([8]) -> (); +store_temp([6]) -> ([6]); +store_temp([5]) -> ([5]); +storage_write_syscall([0], [1], [6], [5], [3]) { fallthrough([9], [10]) 3549([11], [12], [13]) }; +branch_align() -> (); +struct_construct() -> ([14]); +enum_init>, 0>([14]) -> ([15]); +store_temp([9]) -> ([16]); +store_temp([10]) -> ([17]); +store_temp>>([15]) -> ([18]); +jump() { 3554() }; +branch_align() -> (); +enum_init>, 1>([13]) -> ([19]); +store_temp([11]) -> ([16]); +store_temp([12]) -> ([17]); +store_temp>>([19]) -> ([18]); +rename>>([18]) -> ([21]); +function_call::unwrap_syscall>([21]) -> ([20]); +enum_match>([20]) { fallthrough([22]) 3565([23]) }; +branch_align() -> (); +struct_deconstruct>([22]) -> ([24]); +struct_construct>([7], [24]) -> ([25]); +enum_init, 0>([25]) -> ([26]); +store_temp([16]) -> ([27]); +store_temp([17]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([23]) -> ([30]); +store_temp([16]) -> ([31]); +store_temp([17]) -> ([32]); +store_temp>([30]) -> ([33]); +return([31], [32], [33]); +storage_base_address_const<134830404806214277570220174593674215737759987247891306080029841794115377321>() -> ([4]); +u8_to_felt252([3]) -> ([5]); +storage_address_from_base([4]) -> ([6]); +u32_const<0>() -> ([7]); +snapshot_take([2]) -> ([8], [9]); +drop([9]) -> (); +store_temp([7]) -> ([7]); +store_temp([6]) -> ([6]); +storage_write_syscall([0], [1], [7], [6], [5]) { fallthrough([10], [11]) 3588([12], [13], [14]) }; +branch_align() -> (); +struct_construct() -> ([15]); +enum_init>, 0>([15]) -> ([16]); +store_temp([10]) -> ([17]); +store_temp([11]) -> ([18]); +store_temp>>([16]) -> ([19]); +jump() { 3593() }; +branch_align() -> (); +enum_init>, 1>([14]) -> ([20]); +store_temp([12]) -> ([17]); +store_temp([13]) -> ([18]); +store_temp>>([20]) -> ([19]); +rename>>([19]) -> ([22]); +function_call::unwrap_syscall>([22]) -> ([21]); +enum_match>([21]) { fallthrough([23]) 3604([24]) }; +branch_align() -> (); +struct_deconstruct>([23]) -> ([25]); +struct_construct>([8], [25]) -> ([26]); +enum_init, 0>([26]) -> ([27]); +store_temp([17]) -> ([28]); +store_temp([18]) -> ([29]); +store_temp>([27]) -> ([30]); +return([28], [29], [30]); +branch_align() -> (); +drop([8]) -> (); +enum_init, 1>([24]) -> ([31]); +store_temp([17]) -> ([32]); +store_temp([18]) -> ([33]); +store_temp>([31]) -> ([34]); +return([32], [33], [34]); +storage_base_address_const<603278275252936218847294002513349627170936020082667936993356353388973422646>() -> ([4]); +u32_const<0>() -> ([5]); +store_temp([0]) -> ([9]); +store_temp([1]) -> ([10]); +store_temp([5]) -> ([11]); +store_temp([4]) -> ([12]); +store_temp([3]) -> ([13]); +function_call([9], [10], [11], [12], [13]) -> ([6], [7], [8]); +rename>>([8]) -> ([15]); +function_call::unwrap_syscall>([15]) -> ([14]); +enum_match>([14]) { fallthrough([16]) 3632([17]) }; +branch_align() -> (); +snapshot_take([2]) -> ([18], [19]); +drop([19]) -> (); +struct_deconstruct>([16]) -> ([20]); +struct_construct>([18], [20]) -> ([21]); +enum_init, 0>([21]) -> ([22]); +store_temp([6]) -> ([23]); +store_temp([7]) -> ([24]); +store_temp>([22]) -> ([25]); +return([23], [24], [25]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([17]) -> ([26]); +store_temp([6]) -> ([27]); +store_temp([7]) -> ([28]); +store_temp>([26]) -> ([29]); +return([27], [28], [29]); +snapshot_take([4]) -> ([7], [8]); +store_temp([0]) -> ([12]); +store_temp([2]) -> ([13]); +store_temp([8]) -> ([14]); +store_temp([5]) -> ([15]); +function_call([12], [13], [14], [15]) -> ([9], [10], [11]); +u32_const<0>() -> ([16]); +store_temp([1]) -> ([20]); +store_temp([3]) -> ([21]); +store_temp([16]) -> ([22]); +store_temp([11]) -> ([23]); +store_temp([6]) -> ([24]); +function_call([20], [21], [22], [23], [24]) -> ([17], [18], [19]); +rename>>([19]) -> ([26]); +function_call::unwrap_syscall>([26]) -> ([25]); +enum_match>([25]) { fallthrough([27]) 3665([28]) }; +branch_align() -> (); +struct_deconstruct>([27]) -> ([29]); +struct_construct>([7], [29]) -> ([30]); +enum_init, 0>([30]) -> ([31]); +store_temp([9]) -> ([32]); +store_temp([17]) -> ([33]); +store_temp([10]) -> ([34]); +store_temp([18]) -> ([35]); +store_temp>([31]) -> ([36]); +return([32], [33], [34], [35], [36]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([28]) -> ([37]); +store_temp([9]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp([18]) -> ([41]); +store_temp>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +store_temp([3]) -> ([5]); +function_call::into>([5]) -> ([4]); +array_new() -> ([6]); +array_new() -> ([7]); +snapshot_take([4]) -> ([8], [9]); +drop([8]) -> (); +store_temp([9]) -> ([13]); +store_temp>([6]) -> ([14]); +store_temp>([7]) -> ([15]); +function_call([13], [14], [15]) -> ([10], [11], [12]); +drop([12]) -> (); +snapshot_take>([10]) -> ([16], [17]); +drop>([16]) -> (); +struct_construct>([17]) -> ([18]); +snapshot_take>([11]) -> ([19], [20]); +drop>([19]) -> (); +struct_construct>([20]) -> ([21]); +store_temp>([18]) -> ([18]); +store_temp>([21]) -> ([21]); +emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 3701([24], [25], [26]) }; +branch_align() -> (); +struct_construct() -> ([27]); +enum_init>, 0>([27]) -> ([28]); +store_temp([22]) -> ([29]); +store_temp([23]) -> ([30]); +store_temp>>([28]) -> ([31]); +jump() { 3706() }; +branch_align() -> (); +enum_init>, 1>([26]) -> ([32]); +store_temp([24]) -> ([29]); +store_temp([25]) -> ([30]); +store_temp>>([32]) -> ([31]); +rename>>([31]) -> ([34]); +function_call::unwrap_syscall>([34]) -> ([33]); +enum_match>([33]) { fallthrough([35]) 3717([36]) }; +branch_align() -> (); +struct_deconstruct>([35]) -> ([37]); +struct_construct>([2], [37]) -> ([38]); +enum_init, 0>([38]) -> ([39]); +store_temp([29]) -> ([40]); +store_temp([30]) -> ([41]); +store_temp>([39]) -> ([42]); +return([40], [41], [42]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([36]) -> ([43]); +store_temp([29]) -> ([44]); +store_temp([30]) -> ([45]); +store_temp>([43]) -> ([46]); +return([44], [45], [46]); +enum_match>>([0]) { fallthrough([1]) 3730([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +storage_address_from_base([4]) -> ([5]); +storage_read_syscall([1], [2], [3], [5]) { fallthrough([6], [7], [8]) 3768([9], [10], [11]) }; +branch_align() -> (); +store_temp([0]) -> ([14]); +store_temp([8]) -> ([15]); +function_call([14], [15]) -> ([12], [13]); +store_temp([6]) -> ([6]); +store_temp([7]) -> ([7]); +enum_match>([13]) { fallthrough([16]) 3754([17]) }; +branch_align() -> (); +enum_init>, 0>([16]) -> ([18]); +struct_construct>>>([18]) -> ([19]); +enum_init>,)>, 0>([19]) -> ([20]); +store_temp([12]) -> ([21]); +store_temp([6]) -> ([22]); +store_temp([7]) -> ([23]); +store_temp>,)>>([20]) -> ([24]); +return([21], [22], [23], [24]); +branch_align() -> (); +drop([17]) -> (); +array_new() -> ([25]); +felt252_const<110930490496575599150170734222081291576>() -> ([26]); +store_temp([26]) -> ([26]); +array_append([25], [26]) -> ([27]); +struct_construct() -> ([28]); +struct_construct>>([28], [27]) -> ([29]); +enum_init>,)>, 1>([29]) -> ([30]); +store_temp([12]) -> ([31]); +store_temp([6]) -> ([32]); +store_temp([7]) -> ([33]); +store_temp>,)>>([30]) -> ([34]); +return([31], [32], [33], [34]); +branch_align() -> (); +enum_init>, 1>([11]) -> ([35]); +struct_construct>>>([35]) -> ([36]); +enum_init>,)>, 0>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([9]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp>,)>>([37]) -> ([41]); +return([38], [39], [40], [41]); +enum_match>>([0]) { fallthrough([1]) 3783([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +store_temp([0]) -> ([9]); +store_temp([1]) -> ([10]); +store_temp([2]) -> ([11]); +dup([3]) -> ([3], [12]); +store_temp([12]) -> ([12]); +dup([4]) -> ([4], [13]); +store_temp([13]) -> ([13]); +function_call([9], [10], [11], [12], [13]) -> ([5], [6], [7], [8]); +enum_match>,)>>([8]) { fallthrough([14]) 3859([15]) }; +branch_align() -> (); +struct_deconstruct>>>([14]) -> ([16]); +enum_match>>([16]) { fallthrough([17]) 3848([18]) }; +branch_align() -> (); +u8_const<1>() -> ([19]); +storage_address_from_base_and_offset([4], [19]) -> ([20]); +store_temp([20]) -> ([20]); +storage_read_syscall([6], [7], [3], [20]) { fallthrough([21], [22], [23]) 3838([24], [25], [26]) }; +branch_align() -> (); +store_temp([5]) -> ([29]); +store_temp([23]) -> ([30]); +function_call([29], [30]) -> ([27], [28]); +store_temp([21]) -> ([21]); +store_temp([22]) -> ([22]); +enum_match>([28]) { fallthrough([31]) 3823([32]) }; +branch_align() -> (); +struct_construct([17], [31]) -> ([33]); +enum_init>, 0>([33]) -> ([34]); +struct_construct>>>([34]) -> ([35]); +enum_init>,)>, 0>([35]) -> ([36]); +store_temp([27]) -> ([37]); +store_temp([21]) -> ([38]); +store_temp([22]) -> ([39]); +store_temp>,)>>([36]) -> ([40]); +return([37], [38], [39], [40]); +branch_align() -> (); +drop([32]) -> (); +drop([17]) -> (); +array_new() -> ([41]); +felt252_const<476442828812030857794232422692155113556837216824>() -> ([42]); +store_temp([42]) -> ([42]); +array_append([41], [42]) -> ([43]); +struct_construct() -> ([44]); +struct_construct>>([44], [43]) -> ([45]); +enum_init>,)>, 1>([45]) -> ([46]); +store_temp([27]) -> ([47]); +store_temp([21]) -> ([48]); +store_temp([22]) -> ([49]); +store_temp>,)>>([46]) -> ([50]); +return([47], [48], [49], [50]); +branch_align() -> (); +drop([17]) -> (); +enum_init>, 1>([26]) -> ([51]); +struct_construct>>>([51]) -> ([52]); +enum_init>,)>, 0>([52]) -> ([53]); +store_temp([5]) -> ([54]); +store_temp([24]) -> ([55]); +store_temp([25]) -> ([56]); +store_temp>,)>>([53]) -> ([57]); +return([54], [55], [56], [57]); +branch_align() -> (); +drop([4]) -> (); +drop([3]) -> (); +enum_init>, 1>([18]) -> ([58]); +struct_construct>>>([58]) -> ([59]); +enum_init>,)>, 0>([59]) -> ([60]); +store_temp([5]) -> ([61]); +store_temp([6]) -> ([62]); +store_temp([7]) -> ([63]); +store_temp>,)>>([60]) -> ([64]); +return([61], [62], [63], [64]); +branch_align() -> (); +drop([4]) -> (); +drop([3]) -> (); +enum_init>,)>, 1>([15]) -> ([65]); +store_temp([5]) -> ([66]); +store_temp([6]) -> ([67]); +store_temp([7]) -> ([68]); +store_temp>,)>>([65]) -> ([69]); +return([66], [67], [68], [69]); +enum_match>>([0]) { fallthrough([1]) 3874([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +drop([2]) -> (); +felt252_const<1065622543624526936256554561967983185612257046533136611876836524258158810564>() -> ([4]); +store_temp([1]) -> ([7]); +store_temp([4]) -> ([8]); +store_temp([3]) -> ([9]); +function_call([7], [8], [9]) -> ([5], [6]); +storage_base_address_from_felt252([0], [6]) -> ([10], [11]); +store_temp([10]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([11]) -> ([14]); +return([12], [13], [14]); +drop([2]) -> (); +felt252_const<337994139936370667767799129369552596157394447336989834104582481799883947719>() -> ([4]); +store_temp([1]) -> ([7]); +store_temp([4]) -> ([8]); +store_temp>([3]) -> ([9]); +function_call::hash>([7], [8], [9]) -> ([5], [6]); +storage_base_address_from_felt252([0], [6]) -> ([10], [11]); +store_temp([10]) -> ([12]); +store_temp([5]) -> ([13]); +store_temp([11]) -> ([14]); +return([12], [13], [14]); +u128s_from_felt252([0], [1]) { fallthrough([2], [3]) 3908([4], [5], [6]) }; +branch_align() -> (); +enum_init, 0>([3]) -> ([7]); +store_temp([2]) -> ([8]); +store_temp>([7]) -> ([9]); +jump() { 3915() }; +branch_align() -> (); +drop([5]) -> (); +drop([6]) -> (); +struct_construct() -> ([10]); +enum_init, 1>([10]) -> ([11]); +store_temp([4]) -> ([8]); +store_temp>([11]) -> ([9]); +rename([8]) -> ([12]); +rename>([9]) -> ([13]); +return([12], [13]); +get_execution_info_syscall([0], [1]) { fallthrough([2], [3], [4]) 3925([5], [6], [7]) }; +branch_align() -> (); +enum_init, core::array::Array::>, 0>([4]) -> ([8]); +store_temp([2]) -> ([9]); +store_temp([3]) -> ([10]); +store_temp, core::array::Array::>>([8]) -> ([11]); +jump() { 3930() }; +branch_align() -> (); +enum_init, core::array::Array::>, 1>([7]) -> ([12]); +store_temp([5]) -> ([9]); +store_temp([6]) -> ([10]); +store_temp, core::array::Array::>>([12]) -> ([11]); +rename, core::array::Array::>>([11]) -> ([14]); +function_call>::unwrap_syscall>([14]) -> ([13]); +enum_match,)>>([13]) { fallthrough([15]) 3941([16]) }; +branch_align() -> (); +struct_deconstruct>>([15]) -> ([17]); +struct_construct>>([17]) -> ([18]); +enum_init,)>, 0>([18]) -> ([19]); +store_temp([9]) -> ([20]); +store_temp([10]) -> ([21]); +store_temp,)>>([19]) -> ([22]); +return([20], [21], [22]); +branch_align() -> (); +enum_init,)>, 1>([16]) -> ([23]); +store_temp([9]) -> ([24]); +store_temp([10]) -> ([25]); +store_temp,)>>([23]) -> ([26]); +return([24], [25], [26]); +store_temp([3]) -> ([5]); +function_call([5]) -> ([4]); +array_new() -> ([6]); +array_new() -> ([7]); +snapshot_take([4]) -> ([8], [9]); +drop([8]) -> (); +store_temp([9]) -> ([13]); +store_temp>([6]) -> ([14]); +store_temp>([7]) -> ([15]); +function_call([13], [14], [15]) -> ([10], [11], [12]); +drop([12]) -> (); +snapshot_take>([10]) -> ([16], [17]); +drop>([16]) -> (); +struct_construct>([17]) -> ([18]); +snapshot_take>([11]) -> ([19], [20]); +drop>([19]) -> (); +struct_construct>([20]) -> ([21]); +store_temp>([18]) -> ([18]); +store_temp>([21]) -> ([21]); +emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 3974([24], [25], [26]) }; +branch_align() -> (); +struct_construct() -> ([27]); +enum_init>, 0>([27]) -> ([28]); +store_temp([22]) -> ([29]); +store_temp([23]) -> ([30]); +store_temp>>([28]) -> ([31]); +jump() { 3979() }; +branch_align() -> (); +enum_init>, 1>([26]) -> ([32]); +store_temp([24]) -> ([29]); +store_temp([25]) -> ([30]); +store_temp>>([32]) -> ([31]); +rename>>([31]) -> ([34]); +function_call::unwrap_syscall>([34]) -> ([33]); +enum_match>([33]) { fallthrough([35]) 3990([36]) }; +branch_align() -> (); +struct_deconstruct>([35]) -> ([37]); +struct_construct>([2], [37]) -> ([38]); +enum_init, 0>([38]) -> ([39]); +store_temp([29]) -> ([40]); +store_temp([30]) -> ([41]); +store_temp>([39]) -> ([42]); +return([40], [41], [42]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([36]) -> ([43]); +store_temp([29]) -> ([44]); +store_temp([30]) -> ([45]); +store_temp>([43]) -> ([46]); +return([44], [45], [46]); +snapshot_take([4]) -> ([7], [8]); +store_temp([0]) -> ([12]); +store_temp([2]) -> ([13]); +store_temp([8]) -> ([14]); +store_temp>([5]) -> ([15]); +function_call([12], [13], [14], [15]) -> ([9], [10], [11]); +u32_const<0>() -> ([16]); +store_temp([1]) -> ([20]); +store_temp([3]) -> ([21]); +store_temp([16]) -> ([22]); +store_temp([11]) -> ([23]); +store_temp([6]) -> ([24]); +function_call([20], [21], [22], [23], [24]) -> ([17], [18], [19]); +rename>>([19]) -> ([26]); +function_call::unwrap_syscall>([26]) -> ([25]); +enum_match>([25]) { fallthrough([27]) 4023([28]) }; +branch_align() -> (); +struct_deconstruct>([27]) -> ([29]); +struct_construct>([7], [29]) -> ([30]); +enum_init, 0>([30]) -> ([31]); +store_temp([9]) -> ([32]); +store_temp([17]) -> ([33]); +store_temp([10]) -> ([34]); +store_temp([18]) -> ([35]); +store_temp>([31]) -> ([36]); +return([32], [33], [34], [35], [36]); +branch_align() -> (); +drop([7]) -> (); +enum_init, 1>([28]) -> ([37]); +store_temp([9]) -> ([38]); +store_temp([17]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp([18]) -> ([41]); +store_temp>([37]) -> ([42]); +return([38], [39], [40], [41], [42]); +store_temp([3]) -> ([5]); +function_call([5]) -> ([4]); +array_new() -> ([6]); +array_new() -> ([7]); +snapshot_take([4]) -> ([8], [9]); +drop([8]) -> (); +store_temp([9]) -> ([13]); +store_temp>([6]) -> ([14]); +store_temp>([7]) -> ([15]); +function_call([13], [14], [15]) -> ([10], [11], [12]); +drop([12]) -> (); +snapshot_take>([10]) -> ([16], [17]); +drop>([16]) -> (); +struct_construct>([17]) -> ([18]); +snapshot_take>([11]) -> ([19], [20]); +drop>([19]) -> (); +struct_construct>([20]) -> ([21]); +store_temp>([18]) -> ([18]); +store_temp>([21]) -> ([21]); +emit_event_syscall([0], [1], [18], [21]) { fallthrough([22], [23]) 4059([24], [25], [26]) }; +branch_align() -> (); +struct_construct() -> ([27]); +enum_init>, 0>([27]) -> ([28]); +store_temp([22]) -> ([29]); +store_temp([23]) -> ([30]); +store_temp>>([28]) -> ([31]); +jump() { 4064() }; +branch_align() -> (); +enum_init>, 1>([26]) -> ([32]); +store_temp([24]) -> ([29]); +store_temp([25]) -> ([30]); +store_temp>>([32]) -> ([31]); +rename>>([31]) -> ([34]); +function_call::unwrap_syscall>([34]) -> ([33]); +enum_match>([33]) { fallthrough([35]) 4075([36]) }; +branch_align() -> (); +struct_deconstruct>([35]) -> ([37]); +struct_construct>([2], [37]) -> ([38]); +enum_init, 0>([38]) -> ([39]); +store_temp([29]) -> ([40]); +store_temp([30]) -> ([41]); +store_temp>([39]) -> ([42]); +return([40], [41], [42]); +branch_align() -> (); +drop([2]) -> (); +enum_init, 1>([36]) -> ([43]); +store_temp([29]) -> ([44]); +store_temp([30]) -> ([45]); +store_temp>([43]) -> ([46]); +return([44], [45], [46]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +struct_deconstruct>([4]) -> ([8], [9]); +enum_match([9]) { fallthrough([10]) 4093([11]) }; +branch_align() -> (); +drop([10]) -> (); +enum_init, 0>([8]) -> ([12]); +store_temp>([12]) -> ([13]); +jump() { 4099() }; +branch_align() -> (); +drop([11]) -> (); +drop([8]) -> (); +struct_construct() -> ([14]); +enum_init, 1>([14]) -> ([15]); +store_temp>([15]) -> ([13]); +store_temp([3]) -> ([16]); +store_temp>([13]) -> ([17]); +return([16], [17]); +store_temp([0]) -> ([5]); +store_temp([1]) -> ([6]); +store_temp([2]) -> ([7]); +function_call([5], [6], [7]) -> ([3], [4]); +struct_deconstruct>([4]) -> ([8], [9]); +enum_match([9]) { fallthrough([10]) 4113([11]) }; +branch_align() -> (); +drop([10]) -> (); +enum_init, 0>([8]) -> ([12]); +store_temp>([12]) -> ([13]); +jump() { 4119() }; +branch_align() -> (); +drop([11]) -> (); +drop([8]) -> (); +struct_construct() -> ([14]); +enum_init, 1>([14]) -> ([15]); +store_temp>([15]) -> ([13]); +store_temp([3]) -> ([16]); +store_temp>([13]) -> ([17]); +return([16], [17]); +enum_match>>([0]) { fallthrough([1]) 4128([2]) }; +branch_align() -> (); +struct_construct>([1]) -> ([3]); +enum_init, 0>([3]) -> ([4]); +store_temp>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init, 1>([7]) -> ([8]); +store_temp>([8]) -> ([9]); +return([9]); +struct_deconstruct([4]) -> ([5], [6]); +u128_to_felt252([5]) -> ([7]); +dup([3]) -> ([3], [9]); +storage_address_from_base([9]) -> ([8]); +dup([2]) -> ([2], [10]); +storage_write_syscall([0], [1], [10], [8], [7]) { fallthrough([11], [12]) 4160([13], [14], [15]) }; +branch_align() -> (); +u128_to_felt252([6]) -> ([16]); +u8_const<1>() -> ([17]); +storage_address_from_base_and_offset([3], [17]) -> ([18]); +store_temp([11]) -> ([11]); +store_temp([18]) -> ([18]); +storage_write_syscall([11], [12], [2], [18], [16]) { fallthrough([19], [20]) 4154([21], [22], [23]) }; +branch_align() -> (); +struct_construct() -> ([24]); +enum_init>, 0>([24]) -> ([25]); +store_temp([19]) -> ([26]); +store_temp([20]) -> ([27]); +store_temp>>([25]) -> ([28]); +return([26], [27], [28]); +branch_align() -> (); +enum_init>, 1>([23]) -> ([29]); +store_temp([21]) -> ([30]); +store_temp([22]) -> ([31]); +store_temp>>([29]) -> ([32]); +return([30], [31], [32]); +branch_align() -> (); +drop([3]) -> (); +drop([6]) -> (); +drop([2]) -> (); +enum_init>, 1>([15]) -> ([33]); +store_temp([13]) -> ([34]); +store_temp([14]) -> ([35]); +store_temp>>([33]) -> ([36]); +return([34], [35], [36]); +store_temp([0]) -> ([1]); +return([1]); +enum_match([0]) { fallthrough([3]) 4184([4]) }; +branch_align() -> (); +felt252_const<271746229759260285552388728919865295615886751538523744128730118297934206697>() -> ([5]); +store_temp([5]) -> ([5]); +array_append([1], [5]) -> ([6]); +store_temp([3]) -> ([10]); +store_temp>([6]) -> ([11]); +store_temp>([2]) -> ([12]); +function_call([10], [11], [12]) -> ([7], [8], [9]); +drop([9]) -> (); +store_temp>([7]) -> ([13]); +store_temp>([8]) -> ([14]); +jump() { 4195() }; +branch_align() -> (); +felt252_const<544914742286571513055574265148471203182105283038408585630116262969508767999>() -> ([15]); +store_temp([15]) -> ([15]); +array_append([1], [15]) -> ([16]); +store_temp([4]) -> ([20]); +store_temp>([16]) -> ([21]); +store_temp>([2]) -> ([22]); +function_call([20], [21], [22]) -> ([17], [18], [19]); +drop([19]) -> (); +store_temp>([17]) -> ([13]); +store_temp>([18]) -> ([14]); +struct_construct() -> ([23]); +rename>([13]) -> ([24]); +rename>([14]) -> ([25]); +store_temp([23]) -> ([26]); +return([24], [25], [26]); +storage_address_from_base([4]) -> ([5]); +storage_read_syscall([1], [2], [3], [5]) { fallthrough([6], [7], [8]) 4232([9], [10], [11]) }; +branch_align() -> (); +store_temp([0]) -> ([14]); +store_temp([8]) -> ([15]); +function_call([14], [15]) -> ([12], [13]); +store_temp([6]) -> ([6]); +store_temp([7]) -> ([7]); +enum_match>([13]) { fallthrough([16]) 4218([17]) }; +branch_align() -> (); +enum_init>, 0>([16]) -> ([18]); +struct_construct>>>([18]) -> ([19]); +enum_init>,)>, 0>([19]) -> ([20]); +store_temp([12]) -> ([21]); +store_temp([6]) -> ([22]); +store_temp([7]) -> ([23]); +store_temp>,)>>([20]) -> ([24]); +return([21], [22], [23], [24]); +branch_align() -> (); +drop([17]) -> (); +array_new() -> ([25]); +felt252_const<476442828812030857794232422692155113556837216824>() -> ([26]); +store_temp([26]) -> ([26]); +array_append([25], [26]) -> ([27]); +struct_construct() -> ([28]); +struct_construct>>([28], [27]) -> ([29]); +enum_init>,)>, 1>([29]) -> ([30]); +store_temp([12]) -> ([31]); +store_temp([6]) -> ([32]); +store_temp([7]) -> ([33]); +store_temp>,)>>([30]) -> ([34]); +return([31], [32], [33], [34]); +branch_align() -> (); +enum_init>, 1>([11]) -> ([35]); +struct_construct>>>([35]) -> ([36]); +enum_init>,)>, 0>([36]) -> ([37]); +store_temp([0]) -> ([38]); +store_temp([9]) -> ([39]); +store_temp([10]) -> ([40]); +store_temp>,)>>([37]) -> ([41]); +return([38], [39], [40], [41]); +contract_address_to_felt252([2]) -> ([3]); +pedersen([0], [1], [3]) -> ([4], [5]); +store_temp([4]) -> ([6]); +store_temp([5]) -> ([7]); +return([6], [7]); +struct_deconstruct>([2]) -> ([3], [4]); +store_temp([0]) -> ([7]); +store_temp([1]) -> ([8]); +store_temp([3]) -> ([9]); +function_call([7], [8], [9]) -> ([5], [6]); +rename([5]) -> ([12]); +rename([6]) -> ([13]); +store_temp([4]) -> ([14]); +function_call([12], [13], [14]) -> ([10], [11]); +rename([10]) -> ([15]); +rename([11]) -> ([16]); +return([15], [16]); +enum_match, core::array::Array::>>([0]) { fallthrough([1]) 4264([2]) }; +branch_align() -> (); +struct_construct>>([1]) -> ([3]); +enum_init,)>, 0>([3]) -> ([4]); +store_temp,)>>([4]) -> ([5]); +return([5]); +branch_align() -> (); +struct_construct() -> ([6]); +struct_construct>>([6], [2]) -> ([7]); +enum_init,)>, 1>([7]) -> ([8]); +store_temp,)>>([8]) -> ([9]); +return([9]); +enum_init([0]) -> ([1]); +store_temp([1]) -> ([2]); +return([2]); +enum_init([0]) -> ([1]); +store_temp([1]) -> ([2]); +return([2]); +struct_deconstruct([1]) -> ([3], [4]); +struct_deconstruct([2]) -> ([5], [6]); +u128_overflowing_add([0], [4], [6]) { fallthrough([7], [8]) 4286([9], [10]) }; +branch_align() -> (); +struct_construct() -> ([11]); +enum_init([11]) -> ([12]); +struct_construct>([8], [12]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>([13]) -> ([15]); +jump() { 4292() }; +branch_align() -> (); +struct_construct() -> ([16]); +enum_init([16]) -> ([17]); +struct_construct>([10], [17]) -> ([18]); +store_temp([9]) -> ([14]); +store_temp>([18]) -> ([15]); +struct_deconstruct>([15]) -> ([19], [20]); +u128_overflowing_add([14], [3], [5]) { fallthrough([21], [22]) 4300([23], [24]) }; +branch_align() -> (); +struct_construct([22], [19]) -> ([25]); +struct_construct>([25], [20]) -> ([26]); +store_temp([21]) -> ([27]); +store_temp>([26]) -> ([28]); +jump() { 4320() }; +branch_align() -> (); +u128_const<1>() -> ([29]); +store_temp([29]) -> ([29]); +u128_overflowing_add([23], [19], [29]) { fallthrough([30], [31]) 4310([32], [33]) }; +branch_align() -> (); +struct_construct([24], [31]) -> ([34]); +struct_construct>([34], [20]) -> ([35]); +store_temp([30]) -> ([36]); +store_temp>([35]) -> ([37]); +jump() { 4318() }; +branch_align() -> (); +drop([20]) -> (); +struct_construct([24], [33]) -> ([38]); +struct_construct() -> ([39]); +enum_init([39]) -> ([40]); +struct_construct>([38], [40]) -> ([41]); +store_temp([32]) -> ([36]); +store_temp>([41]) -> ([37]); +rename([36]) -> ([27]); +rename>([37]) -> ([28]); +rename([27]) -> ([42]); +rename>([28]) -> ([43]); +return([42], [43]); +struct_deconstruct([1]) -> ([3], [4]); +struct_deconstruct([2]) -> ([5], [6]); +u128_overflowing_sub([0], [4], [6]) { fallthrough([7], [8]) 4333([9], [10]) }; +branch_align() -> (); +struct_construct() -> ([11]); +enum_init([11]) -> ([12]); +struct_construct>([8], [12]) -> ([13]); +store_temp([7]) -> ([14]); +store_temp>([13]) -> ([15]); +jump() { 4339() }; +branch_align() -> (); +struct_construct() -> ([16]); +enum_init([16]) -> ([17]); +struct_construct>([10], [17]) -> ([18]); +store_temp([9]) -> ([14]); +store_temp>([18]) -> ([15]); +struct_deconstruct>([15]) -> ([19], [20]); +u128_overflowing_sub([14], [3], [5]) { fallthrough([21], [22]) 4347([23], [24]) }; +branch_align() -> (); +struct_construct([22], [19]) -> ([25]); +struct_construct>([25], [20]) -> ([26]); +store_temp([21]) -> ([27]); +store_temp>([26]) -> ([28]); +jump() { 4367() }; +branch_align() -> (); +u128_const<1>() -> ([29]); +store_temp([29]) -> ([29]); +u128_overflowing_sub([23], [19], [29]) { fallthrough([30], [31]) 4357([32], [33]) }; +branch_align() -> (); +struct_construct([24], [31]) -> ([34]); +struct_construct>([34], [20]) -> ([35]); +store_temp([30]) -> ([36]); +store_temp>([35]) -> ([37]); +jump() { 4365() }; +branch_align() -> (); +drop([20]) -> (); +struct_construct([24], [33]) -> ([38]); +struct_construct() -> ([39]); +enum_init([39]) -> ([40]); +struct_construct>([38], [40]) -> ([41]); +store_temp([32]) -> ([36]); +store_temp>([41]) -> ([37]); +rename([36]) -> ([27]); +rename>([37]) -> ([28]); +rename([27]) -> ([42]); +rename>([28]) -> ([43]); +return([42], [43]); +dup([0]) -> ([0], [3]); +struct_deconstruct([3]) -> ([4], [5], [6]); +drop([5]) -> (); +drop([6]) -> (); +store_temp([4]) -> ([9]); +store_temp>([2]) -> ([10]); +function_call([9], [10]) -> ([7], [8]); +drop([8]) -> (); +dup([0]) -> ([0], [11]); +struct_deconstruct([11]) -> ([12], [13], [14]); +drop([12]) -> (); +drop([14]) -> (); +store_temp([13]) -> ([17]); +store_temp>([7]) -> ([18]); +function_call([17], [18]) -> ([15], [16]); +drop([16]) -> (); +struct_deconstruct([0]) -> ([19], [20], [21]); +drop([19]) -> (); +drop([20]) -> (); +store_temp([21]) -> ([24]); +store_temp>([15]) -> ([25]); +function_call([24], [25]) -> ([22], [23]); +drop([23]) -> (); +struct_construct() -> ([26]); +store_temp>([1]) -> ([27]); +store_temp>([22]) -> ([28]); +store_temp([26]) -> ([29]); +return([27], [28], [29]); +dup([0]) -> ([0], [3]); +struct_deconstruct([3]) -> ([4], [5], [6]); +drop([5]) -> (); +drop([6]) -> (); +store_temp([4]) -> ([9]); +store_temp>([2]) -> ([10]); +function_call([9], [10]) -> ([7], [8]); +drop([8]) -> (); +dup([0]) -> ([0], [11]); +struct_deconstruct([11]) -> ([12], [13], [14]); +drop([12]) -> (); +drop([14]) -> (); +store_temp([13]) -> ([17]); +store_temp>([7]) -> ([18]); +function_call([17], [18]) -> ([15], [16]); +drop([16]) -> (); +struct_deconstruct([0]) -> ([19], [20], [21]); +drop([19]) -> (); +drop([20]) -> (); +store_temp([21]) -> ([24]); +store_temp>([15]) -> ([25]); +function_call([24], [25]) -> ([22], [23]); +drop([23]) -> (); +struct_construct() -> ([26]); +store_temp>([1]) -> ([27]); +store_temp>([22]) -> ([28]); +store_temp([26]) -> ([29]); +return([27], [28], [29]); +rename([0]) -> ([2]); +contract_address_to_felt252([2]) -> ([3]); +snapshot_take([3]) -> ([4], [5]); +drop([4]) -> (); +store_temp([5]) -> ([8]); +store_temp>([1]) -> ([9]); +function_call([8], [9]) -> ([6], [7]); +drop([7]) -> (); +struct_construct() -> ([10]); +store_temp>([6]) -> ([11]); +store_temp([10]) -> ([12]); +return([11], [12]); + +erc20::erc20::erc_20::__external::get_name@0([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::get_symbol@101([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::get_decimals@202([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::get_total_supply@303([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: core::array::Span::) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::balance_of@404([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::allowance@534([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::transfer@689([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::transfer_from@836([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::approve@1009([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::increase_allowance@1156([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__external::decrease_allowance@1303([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::__constructor::constructor@1450([0]: Pedersen, [1]: RangeCheck, [2]: GasBuiltin, [3]: System, [4]: core::array::Span::) -> (Pedersen, RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::array::Span::,)>); +erc20::erc20::erc_20::IERC20Impl::get_name@1677([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +core::Felt252Serde::serialize@1702([0]: felt252, [1]: Array) -> (Array, Unit); +erc20::erc20::erc_20::IERC20Impl::get_symbol@1708([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +erc20::erc20::erc_20::IERC20Impl::get_decimals@1733([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u8,)>); +core::integer::U8Serde::serialize@1761([0]: u8, [1]: Array) -> (Array, Unit); +erc20::erc20::erc_20::IERC20Impl::get_total_supply@1773([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::u256Serde::serialize@1801([0]: core::integer::u256, [1]: Array) -> (Array, Unit); +core::starknet::contract_address::ContractAddressSerde::deserialize@1816([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +erc20::erc20::erc_20::IERC20Impl::balance_of@1840([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +erc20::erc20::erc_20::IERC20Impl::allowance@1872([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::u256Serde::deserialize@1905([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +erc20::erc20::erc_20::IERC20Impl::transfer@1934([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::transfer_from@1981([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::approve@2055([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::increase_allowance@2102([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::IERC20Impl::decrease_allowance@2205([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::Felt252Serde::deserialize@2308([0]: core::array::Span::) -> (core::array::Span::, core::option::Option::); +core::integer::U8Serde::deserialize@2337([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +erc20::erc20::erc_20::constructor@2379([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: felt252, [6]: felt252, [7]: u8, [8]: core::integer::u256, [9]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::name::InternalContractStateImpl::read@2589([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::name::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +erc20::erc20::erc_20::symbol::InternalContractStateImpl::read@2624([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::symbol::ContractState) -> (GasBuiltin, System, core::panics::PanicResult::<(core::felt252,)>); +erc20::erc20::erc_20::decimals::InternalContractStateImpl::read@2659([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::decimals::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u8,)>); +erc20::erc20::erc_20::total_supply::InternalContractStateImpl::read@2697([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: erc20::erc20::erc_20::total_supply::ContractState) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::U128Serde::serialize@2735([0]: u128, [1]: Array) -> (Array, Unit); +erc20::erc20::erc_20::balances::InternalContractStateImpl::read@2747([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::balances::ContractState, [5]: ContractAddress) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +erc20::erc20::erc_20::allowances::InternalContractStateImpl::read@2791([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::allowances::ContractState, [5]: Tuple) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::U128Serde::deserialize@2835([0]: RangeCheck, [1]: core::array::Span::) -> (RangeCheck, core::array::Span::, core::option::Option::); +core::starknet::info::get_caller_address@2877([0]: GasBuiltin, [1]: System) -> (GasBuiltin, System, core::panics::PanicResult::<(core::starknet::contract_address::ContractAddress,)>); +erc20::erc20::erc_20::StorageImpl::transfer_helper@2901([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::StorageImpl::spend_allowance@3188([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::StorageImpl::approve_helper@3329([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::ContractState, [5]: ContractAddress, [6]: ContractAddress, [7]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::integer::U256Add::add@3436([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::U256Sub::sub@3459([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::panics::PanicResult::<(core::integer::u256,)>); +core::integer::Felt252TryIntoU8::try_into@3482([0]: RangeCheck, [1]: felt252) -> (RangeCheck, core::option::Option::); +erc20::erc20::erc_20::name::InternalContractStateImpl::write@3496([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::name::ContractState, [3]: felt252) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::name::ContractState, ())>); +erc20::erc20::erc_20::symbol::InternalContractStateImpl::write@3534([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::symbol::ContractState, [3]: felt252) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::symbol::ContractState, ())>); +erc20::erc20::erc_20::decimals::InternalContractStateImpl::write@3572([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::decimals::ContractState, [3]: u8) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::decimals::ContractState, ())>); +erc20::erc20::erc_20::total_supply::InternalContractStateImpl::write@3611([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::total_supply::ContractState, [3]: core::integer::u256) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::total_supply::ContractState, ())>); +erc20::erc20::erc_20::balances::InternalContractStateImpl::write@3639([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::balances::ContractState, [5]: ContractAddress, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::balances::ContractState, ())>); +erc20::erc20::erc_20::ContractStateEventEmitter::emit::>@3674([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Event) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3724([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::felt252,)>); +core::starknet::storage_access::StoreU8::read@3736([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); +core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3777([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::integer::u8,)>); +core::integer::Storeu256::read@3789([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); +core::starknet::SyscallResultTraitImpl::::unwrap_syscall@3868([0]: core::result::Result::>) -> (core::panics::PanicResult::<(core::integer::u256,)>); +erc20::erc20::erc_20::balances::InternalContractStateImpl::address@3880([0]: RangeCheck, [1]: Pedersen, [2]: erc20::erc20::erc_20::balances::ContractState, [3]: ContractAddress) -> (RangeCheck, Pedersen, StorageBaseAddress); +erc20::erc20::erc_20::allowances::InternalContractStateImpl::address@3891([0]: RangeCheck, [1]: Pedersen, [2]: erc20::erc20::erc_20::allowances::ContractState, [3]: Tuple) -> (RangeCheck, Pedersen, StorageBaseAddress); +core::integer::u128_try_from_felt252@3902([0]: RangeCheck, [1]: felt252) -> (RangeCheck, core::option::Option::); +core::starknet::info::get_execution_info@3918([0]: GasBuiltin, [1]: System) -> (GasBuiltin, System, core::panics::PanicResult::<(core::box::Box::,)>); +erc20::erc20::erc_20::ContractStateEventEmitter::emit::@3947([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Transfer) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +erc20::erc20::erc_20::allowances::InternalContractStateImpl::write@3997([0]: RangeCheck, [1]: GasBuiltin, [2]: Pedersen, [3]: System, [4]: erc20::erc20::erc_20::allowances::ContractState, [5]: Tuple, [6]: core::integer::u256) -> (RangeCheck, GasBuiltin, Pedersen, System, core::panics::PanicResult::<(erc20::erc20::erc_20::allowances::ContractState, ())>); +erc20::erc20::erc_20::ContractStateEventEmitter::emit::@4032([0]: GasBuiltin, [1]: System, [2]: erc20::erc20::erc_20::ContractState, [3]: erc20::erc20::erc_20::Approval) -> (GasBuiltin, System, core::panics::PanicResult::<(erc20::erc20::erc_20::ContractState, ())>); +core::integer::u256_checked_add@4082([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::option::Option::); +core::integer::u256_checked_sub@4102([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, core::option::Option::); +core::starknet::SyscallResultTraitImpl::<()>::unwrap_syscall@4122([0]: core::result::Result::<(), core::array::Array::>) -> (core::panics::PanicResult::<((),)>); +core::integer::Storeu256::write@4134([0]: GasBuiltin, [1]: System, [2]: u32, [3]: StorageBaseAddress, [4]: core::integer::u256) -> (GasBuiltin, System, core::result::Result::<(), core::array::Array::>); +core::traits::TIntoT::::into@4169([0]: erc20::erc20::erc_20::Event) -> (erc20::erc20::erc_20::Event); +erc20::erc20::erc_20::EventIsEvent::append_keys_and_data@4171([0]: erc20::erc20::erc_20::Event, [1]: Array, [2]: Array) -> (Array, Array, Unit); +core::starknet::storage_access::StoreU128::read@4200([0]: RangeCheck, [1]: GasBuiltin, [2]: System, [3]: u32, [4]: StorageBaseAddress) -> (RangeCheck, GasBuiltin, System, core::panics::PanicResult::<(core::result::Result::>,)>); +core::hash::LegacyHashContractAddress::hash@4241([0]: Pedersen, [1]: felt252, [2]: ContractAddress) -> (Pedersen, felt252); +core::hash::TupleSize2LegacyHash::::hash@4246([0]: Pedersen, [1]: felt252, [2]: Tuple) -> (Pedersen, felt252); +core::starknet::SyscallResultTraitImpl::>::unwrap_syscall@4258([0]: core::result::Result::, core::array::Array::>) -> (core::panics::PanicResult::<(core::box::Box::,)>); +erc20::erc20::erc_20::EventTransferIntoEvent::into@4270([0]: erc20::erc20::erc_20::Transfer) -> (erc20::erc20::erc_20::Event); +erc20::erc20::erc_20::EventApprovalIntoEvent::into@4273([0]: erc20::erc20::erc_20::Approval) -> (erc20::erc20::erc_20::Event); +core::integer::u256_overflowing_add@4276([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, Tuple); +core::integer::u256_overflow_sub@4323([0]: RangeCheck, [1]: core::integer::u256, [2]: core::integer::u256) -> (RangeCheck, Tuple); +erc20::erc20::erc_20::TransferIsEvent::append_keys_and_data@4370([0]: erc20::erc20::erc_20::Transfer, [1]: Array, [2]: Array) -> (Array, Array, Unit); +erc20::erc20::erc_20::ApprovalIsEvent::append_keys_and_data@4398([0]: erc20::erc20::erc_20::Approval, [1]: Array, [2]: Array) -> (Array, Array, Unit); +core::starknet::contract_address::ContractAddressSerde::serialize@4426([0]: ContractAddress, [1]: Array) -> (Array, Unit); diff --git a/cairo_programs/wallet.sierra b/cairo_programs/wallet.sierra new file mode 100644 index 000000000..51f9a924c --- /dev/null +++ b/cairo_programs/wallet.sierra @@ -0,0 +1,1430 @@ +{ + "sierra_program": [ + "0x1", + "0x3", + "0x0", + "0x2", + "0x2", + "0x0", + "0x110", + "0xf0", + "0x25", + "0x52616e6765436865636b", + "0x800000000000000100000000000000000000000000000000", + "0x537472756374", + "0x800000000000000f00000000000000000000000000000001", + "0x0", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x800000000000000f00000000000000000000000000000002", + "0x1", + "0x16a4c8d7c05909052238a862d8cc3e7975bf05a07b3a69c6b28951083a6d672", + "0x4172726179", + "0x800000000000000300000000000000000000000000000001", + "0x8", + "0x800000000000000300000000000000000000000000000003", + "0x3", + "0x4", + "0x456e756d", + "0xcc5e86243f861d2d64b08c35db21013e773ac5cf10097946fe0011304886d5", + "0x2", + "0x5", + "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", + "0x66656c74323532", + "0x800000000000000700000000000000000000000000000000", + "0x90d0203c41ad646d024845257a6eceb2f8b59b29ce7420dd518053d2edeedc", + "0x53746f7261676541646472657373", + "0x53746f726167654261736541646472657373", + "0x2633efa4b25602d1290a27d6aeb948fa53ef8a1976814cd1d78ed018207d9cd", + "0x800000000000000f00000000000000000000000000000003", + "0xc", + "0x289f3ec570490cc3a75d679992a6fbe6de8132318d9d268c66b360184dfa286", + "0xd", + "0x75313238", + "0x800000000000000700000000000000000000000000000003", + "0x25e2ca4b84968c2d8b83ef476ca8549410346b00836ce79beaf538155990bb2", + "0xf", + "0x800000000000000700000000000000000000000000000002", + "0x33dd38c898783061cd5539eddd96ee07d9522f364cb597d41a5d52b5c33314d", + "0x10", + "0x38ebd195e334343351be418d9529f6ec84f863f4b4de353979c00728b133d95", + "0x11", + "0x426f78", + "0x800000000000000700000000000000000000000000000001", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x13", + "0x10203be321c62a7bd4c060d69539c1fbe065baa9e253c74d2cc48be163e259", + "0x15", + "0x3520cd02f0e8297127614983b88bdaefde065b3fb4003d1a9d69b11592f6415", + "0x17", + "0x208991af02aa9b701a77c2c14af12d805ccecd643d794ba6794d824caf0095c", + "0x18", + "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", + "0x536e617073686f74", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x1b", + "0x1c", + "0x39d7e2f385e5d511ae0a83d1ae4f716c2c908fa7833dd212825a421b655f6c8", + "0x1e", + "0x4275696c74696e436f737473", + "0x53797374656d", + "0x9931c641b913035ae674b400b61a51476d506bbe8bba2ff8a6272790aba9e6", + "0x1d", + "0x753332", + "0x4761734275696c74696e", + "0x92", + "0x7265766f6b655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x23", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x73746f72655f74656d70", + "0x7533325f6571", + "0x61727261795f6e6577", + "0x66656c743235325f636f6e7374", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x61727261795f617070656e64", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x22", + "0x24", + "0x21", + "0x6765745f6275696c74696e5f636f737473", + "0x20", + "0x77697468647261775f6761735f616c6c", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x1f", + "0x4f7574206f6620676173", + "0x1a", + "0x6", + "0x19", + "0x4661696c656420746f20646573657269616c697a6520706172616d202331", + "0x7", + "0x16", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x14", + "0x6a756d70", + "0x756e626f78", + "0x753132385f636f6e7374", + "0x12", + "0x9", + "0x66656c743235325f616464", + "0xa", + "0xe", + "0x73746f726167655f626173655f616464726573735f636f6e7374", + "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091", + "0x73746f726167655f616464726573735f66726f6d5f62617365", + "0x73746f726167655f726561645f73797363616c6c", + "0xb", + "0x656d69745f6576656e745f73797363616c6c", + "0x73746f726167655f77726974655f73797363616c6c", + "0x155e08616bcbb7488110b83d2b0fbb666a76c8444c7199784579e8339c7e629", + "0x647570", + "0x753132385f746f5f66656c74323532", + "0x295", + "0xffffffffffffffff", + "0x51", + "0x44", + "0x26", + "0x27", + "0x28", + "0x3d", + "0x29", + "0x2a", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x31", + "0x32", + "0x2f", + "0x30", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x39", + "0x3a", + "0x3b", + "0x3c", + "0x3e", + "0x3f", + "0x40", + "0x41", + "0x42", + "0x43", + "0x45", + "0x46", + "0x47", + "0x48", + "0x49", + "0x4a", + "0x4b", + "0x4c", + "0x4d", + "0x4e", + "0x4f", + "0x50", + "0x52", + "0x53", + "0x54", + "0xbf", + "0xb0", + "0x80", + "0xa2", + "0x9b", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5b", + "0x5c", + "0x12d", + "0x11e", + "0xee", + "0x110", + "0x109", + "0x14b", + "0x15f", + "0x164", + "0x16e", + "0x1ac", + "0x1a4", + "0x19e", + "0x5d", + "0x1c6", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x1d9", + "0x62", + "0x63", + "0x1de", + "0x64", + "0x65", + "0x66", + "0x1e9", + "0x67", + "0x68", + "0x69", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x20a", + "0x70", + "0x71", + "0x20f", + "0x72", + "0x73", + "0x74", + "0x75", + "0x21a", + "0x76", + "0x77", + "0x230", + "0x235", + "0x240", + "0x78", + "0x79", + "0x7a", + "0x7b", + "0x7c", + "0x24d", + "0x7d", + "0x7e", + "0x7f", + "0x81", + "0x26a", + "0x82", + "0x83", + "0x84", + "0x85", + "0x86", + "0x87", + "0x88", + "0x89", + "0x8a", + "0x8b", + "0x8c", + "0x8d", + "0x8e", + "0x8f", + "0x90", + "0x91", + "0xcd", + "0x13b", + "0x152", + "0x158", + "0x175", + "0x1b4", + "0x1cc", + "0x1ef", + "0x221", + "0x247", + "0x253", + "0x255", + "0x264", + "0x270", + "0x27a", + "0x289", + "0x1815", + "0x38100602834060c0402c1409028100608040180a07018180a04018080200", + "0x2018080b8141a100b0541e08040202805068402608090202205068401e08", + "0x583e1304078101d0283420080407010060286c061a0281006160c858300f", + "0x144010060205228138204c05118404a08120144603110204408108144003", + "0x6c061c040b80a070184c102d040b00a0d0803010060288c0608040ac102a", + "0xc1e08148cc1008060206405100402608188206005068401008178200c05", + "0x4c1038040dc0a0d08030102f040180a20018d810060288c0635040d00a23", + "0xd8100821814840520814803f010f82c3d0982078081d8141a10010e82c39", + "0x20104a23020104a230201049028481048230201047230201045060201044", + "0x4c1008280381008280301008278301008251382408268301008260149605", + "0x1400a572b020104a02954a40804128a80804128a608041281012290202451", + "0xbc1008238e010082196810082c8381c082c0bc1008250bc1008280701008", + "0x20104707820104504020104707838105807820104a060201047060201045", + "0xd81008250d810082396c240826814245204048a23c04020a03604020a00f", + "0x3810582f848104d1882010472f02010592e83810582e0201059098381058", + "0x20a02d04020866104020b20c07020b01c04020941c040208a2f040208660", + "0x14018080412410122d02024510e02010472d020104a02848b408091447008", + "0x14c8630402094350402094050918c1012288301008310201008250201008", + "0x2024512e020104a02848b80809144180804194c608041641012318202451", + "0x2094050919c10122889c100828094100828014240833048240833020245c", + "0x2010500f0201043358201059350381058188201043029a4d00e04160ce08", + "0x14dc6d09020d82d040208e0809178101228978100825014245e04048a231", + "0x160d00804124101234020245134020104a02848d008091440a6f35020104a", + "0x701c082c020246104048a261040209405091841012288b41008281c01c08", + "0x20245130020104a02848c008091440a710f0381058338201047338201045", + "0x48a21e04020a0053904810082197410082c9ac1c082c1801008248202460", + "0x128e61204134ce0804164d00804164101235820245135820104a02848d608", + "0x48a25d0402094050917410122884810082818010082c8881c082c09c1008", + "0x20104712820104312820107412838105812820104a13820104304048ba08", + "0x140a053b014ea2204020920804020920f04020922707020b022040209422", + "0x38100e02814ee08028480a602e848f01307848ee1204014240802814ee08", + "0x1dc106a041740a7035048ee0834020260534020ee08060201e0506020ee08", + "0x201805029dc101e041740a6b0f048ee080e02026050e020ee08029800a05", + "0x1dc100f041a80a22041dc1022041a00a25041dc106b040300a22041dc1070", + "0x780a27041dc10050e0140a77040142405028d80a77090944412380141e08", + "0x1dc10051281456083b820ce27090880a67041dc1067041ac0a67041dc1005", + "0xbc10770403c106a029841077040b41067028b41077040acc61213814c608", + "0xbc1e082e020ee08308205a052f020ee0809020c60518820ee08098205605", + "0x3862051a820ee081a8205e051a820ee08029840a053b8200a1202970bc31", + "0x1700a56041dc10052f0140a770401424052d0e024791e0d82477090d4260f", + "0x20a8081a814f4083b82024083181400083b820780815814a8083b820ac08", + "0x14c103c028d81077040d8106a0294c8c52071dc107b3d0001c36029ec1077", + "0x48ee083e02070053f820ee08028700a053b8200a12029f8107d3e020ee12", + "0x1ac0a053b82104082a0150682091dc1081041580a053b82100082d0150280", + "0x20a60543a182477042150812230150a083b820fe082901508083b8210608", + "0x20ee0844820f605029dc1088041e80a8944048ee08430200005029dc1087", + "0xac0a8d041dc1036041a80a8c041dc108b041f80a8b041dc108a041f00a8a", + "0x23d1c8d0782120083b8211808168151e083b8208c08318151c083b820a408", + "0x148102b029f41077040d8106a02a441077041f8106702814ee08028480a90", + "0x152893491f41e084a020ee08488205a0549820ee0823020c60549020ee08", + "0x258107704258106b02a58107704014fe054a820ee08028700a053b8200a12", + "0x19c0a98041dc10973c8484e053c820ee08028940a97041dc10964a8484405", + "0x2024083181536083b820b4081581534083b82070083501532083b8213008", + "0x38108002814ee08028480a9d4e26d340f04274107704264102d02a701077", + "0x880a9f041dc109f041ac0a9f041dc10053f8153c083b8200a1c02814ee08", + "0x288106702a8810770428142121381542083b8200a2502a8010770427d3c12", + "0x20ee0809020c60552020ee083002056053c020ee082e820d40551820ee08", + "0x481005090200a053b8200a0502a994aa43c03c10a6041dc10a3040b40aa5", + "0x20d40841014d4083b8201c08408140a770401424053017424a70983c2477", + "0x200a120287010a838020ee1234021060507820ee0807820d405340302477", + "0x9444123b820d60809814d6083b8203c08078143c083b8201808070140a77", + "0x19c105d028acce123b8204e08098144e083b8200a6002814ee0811020ba05", + "0x18c10770418c1068028b41077040ac100c0298c107704094100c02814ee08", + "0x200a1c02814ee0838020a805029dc1005090140aa9029dc242d31848e005", + "0xc41077040bcc212110145e083b8205e08358145e083b8200a1e029841077", + "0x20d4051a820ee082e020ce052e020ee08189782427029781077040144a05", + "0x1dc1035040b40a38041dc10120418c0a3c041dc1013040ac0a36041dc100f", + "0x1dc1056040bc0a56041dc1005308140a770401424052d0e0783607820b408", + "0x200a5e02814ee08028480a532304954522a048ee122b04c1e0e18814ac08", + "0x2001077040481063029fc107704148102b029e8107704000105c028001077", + "0x1ec1c770420902803f83d0c0541020ee0838020d60540820ee083d0206a05", + "0x14ee08028480a86042ad06083b848fc0843814a8083b820a80835014fc7c", + "0x210107a02a1508123b8210e08000150e083b8200a1c02814ee08418210805", + "0x228107704224107e02a24107704220107c02a20107704214107b02814ee08", + "0x205a0546820ee083e020c60546020ee083d820560545820ee082a020d405", + "0x1a80a8f041dc10860419c0a053b8200a1202a391a8c4583c108e041dc108a", + "0x211e0816814fa083b820f8083181522083b820f6081581520083b820a808", + "0x1dc10050e0140a77041c0105402814ee08028480a923ea45200f042481077", + "0x152a083b8212893090880a94041dc1094041ac0a94041dc10053f8152608", + "0x118106a029e410770425c106702a5c1077042552c12138152c083b8200a25", + "0x20ee083c8205a054d020ee0809020c6054c820ee082982056054c020ee08", + "0x14ee08060210005029dc101c0414c0a053b8200a1202a6d34994c03c109b", + "0x2753812110153a083b8213a08358153a083b8200a8502a701077040143805", + "0x20ee0850020ce0550020ee084f27c242702a7c1077040144a054f020ee08", + "0xb40a78041dc10120418c0aa3041dc1013040ac0aa2041dc100f041a80aa1", + "0x700a053b8201c08400140a77040142405521e146a20782148083b8214208", + "0x1dc10a652848440553020ee0853020d60553020ee08029fc0aa5041dc1005", + "0x155e083b8215c08338155c083b82158ad0909c0aad041dc1005128155808", + "0x2bc102d02ac8107704048106302ac4107704180102b02ac0107704174106a", + "0x2d0260f091dc2408028481005029dc10050281566b258ac01e0859820ee08", + "0x14d00c091dc106a042080a6a041dc100e042040a053b8200a1202980ba12", + "0x201c05029dc10050901438085a9c01077091a010830283c10770403c106a", + "0x2044082e8144a22091dc106b0404c0a6b041dc101e0403c0a1e041dc100c", + "0x300a053b820ce082e8145667091dc10270404c0a27041dc1005300140a77", + "0xb4c61238014c6083b820c608340145a083b820560806014c6083b8204a08", + "0x780a61041dc10050e0140a77041c0105402814ee08028480a055b014ee12", + "0x1dc10051281462083b8205e61090880a2f041dc102f041ac0a2f041dc1005", + "0xd810770403c106a028d41077041701067029701077040c4bc1213814bc08", + "0xd81e082d020ee081a8205a051c020ee0809020c6051e020ee08098205605", + "0x3862052b020ee082b0205e052b020ee08029840a053b8200a1202968703c", + "0x1700a00041dc10052f0140a770401424052991824b729150247709158260f", + "0x20f4081a81500083b820240831814fe083b820a40815814f4083b8200008", + "0x20d4053f1f0f60e3b8210481401fc1e8802a081077041c0106b02a041077", + "0x210608420140a77040142405430217083041dc247e0421c0a54041dc1054", + "0x1ec0a053b82108083d0150a84091dc1087040000a87041dc10050e0140a77", + "0x20a8083501514083b82112083f01512083b82110083e01510083b8210a08", + "0x238107704228102d02a341077041f0106302a301077041ec102b02a2c1077", + "0x20ee082a020d40547820ee0843020ce05029dc1005090151c8d4622c1e08", + "0x3c1092041dc108f040b40a7d041dc107c0418c0a91041dc107b040ac0a90", + "0x14fe0549820ee08028700a053b820e0082a0140a77040142405491f52290", + "0x20ee08028940a95041dc10944984844054a020ee084a020d6054a020ee08", + "0x1530083b8208c0835014f2083b8212e08338152e083b8212a960909c0a96", + "0x265300f0426c1077041e4102d02a68107704048106302a6410770414c102b", + "0x1dc10050e0140a7704030108002814ee080e020a605029dc100509015369a", + "0x153c083b8213a9c090880a9d041dc109d041ac0a9d041dc1005428153808", + "0x3c106a02a84107704280106702a801077042793e12138153e083b8200a25", + "0x20ee08508205a053c020ee0809020c60551820ee0809820560551020ee08", + "0x2941077040143805029dc100e042000a053b8200a1202a90f0a35103c10a4", + "0x144a0556020ee0853294242202a98107704298106b02a98107704014fe05", + "0x1dc105d041a80aaf041dc10ae0419c0aae041dc10ac568484e0556820ee08", + "0x2166083b8215e081681564083b82024083181562083b820c008158156008", + "0x200a0815814260f091dc100e042280a0e041dc1012042240ab3592c5600f", + "0x1dc1070351a01c8c029c010770404c108b029a81077040201063029a01077", + "0x1dc101c042380a053b8200a120287810b90e020ee12060211a0506180ba0e", + "0x9c1077040941090028941077041ac44124781444083b8201e082e014d608", + "0x19c1c0831820ee0813821220515820ee0830020c60533820ee082e8205605", + "0x174102b028b4107704078109202814ee0807820fa05029dc100509014c62b", + "0x24c0a31179841c0818820ee0816821220517820ee0830020c60530820ee08", + "0x201c08290141e083b8200a940283810770404810121101424083b8200a08", + "0x20109602820107704014100e0297426120417410770403c10950284c1077", + "0x2024083c81426083b8201c084b8140a7704014240507821740e09048ee12", + "0x200a9402814ee08028480a055d8200a990298010770404c1098029741077", + "0x1801077041a010980297410770403c1079029a0107704030109a028301077", + "0x7010bc38020ee1230021360535020ee0835021020535020ee082e820f605", + "0x20d6084e814d6083b8203c08498143c083b820e0084e0140a77040142405", + "0x200a120289c4a120409c107704088109e028941077041a81081028881077", + "0x21020515820ee08338213e0533820ee0802a500a053b8203808298140a77", + "0x2280a0f041dc1012042240a2d31848102d041dc102b042780a63041dc106a", + "0x174108b029c01077040201063029a8107704014102b0297426123b8201e08", + "0x1ac10bd0f020ee12340211a0534030c00e3b82038703503918050e020ee08", + "0x1dc102511049440512820ee0802a840a22041dc1005500140a77040142405", + "0x14c6083b82026082e01456083b820ce083c014ce083b8204e08518144e08", + "0xac10a40297010770418c1035029781077040301063028c4107704180102b", + "0x217c36041dc242f0421c0a2f308b41c77040d4b85e1883d4a051a820ee08", + "0x2158052d020ee08070e024a6028e0107704078108e02814ee08028480a3c", + "0x1dc102d040ac0a52041dc1056042240a053b820a80829814a856091dc1036", + "0x14fc083b820b40835814f8083b820a40845814f6083b820c20831814f408", + "0x200a1202a0010bf3f820ee12000215c050014c8c0e3b820fc7c3d9e81ead", + "0x20ee084120c24b002a0c107704204105c02a0902123b820fe08578140a77", + "0x2c80a85041dc10530418c0a84041dc1046040ac0a87041dc1086042c40a86", + "0xac0a89041dc1080042cc0a053b8200a1202a210a840702110083b8210e08", + "0x231168a0702118083b82112085901516083b820a6083181514083b8208c08", + "0x20ee081e0216605029dc100e041500a053b8203c08600140a77040142405", + "0x381090041dc108d042c80a8f041dc10610418c0a8e041dc102d040ac0a8d", + "0x1ac10b302814ee0809820fa05029dc100e041500a053b8200a1202a411e8e", + "0x20ee0848821640549020ee0806020c6053e820ee0830020560548820ee08", + "0x2010083181418083b8200a08158141e083b82024084481526923e8381093", + "0x20e06a340301ead029c0107704038106b029a810770403c108b029a01077", + "0x203808578140a770401424050f021821c041dc2460042b80a602e84c1c77", + "0x144e083b820d6082e0144a083b8200a9402814ee0811020a605111ac2477", + "0x20c60531820ee0809820560515820ee0833821620533820ee081289c24b0", + "0x216605029dc100509014c22d318381061041dc102b042c80a2d041dc105d", + "0x1dc102f042c80a5e041dc105d0418c0a31041dc1013040ac0a2f041dc101e", + "0x1dc100e0430c0a0e041dc1005610140a7704048107d02970bc3107020b808", + "0x3140a0f041dc100f043100a13041dc1013041a00a13041dc1005300141e08", + "0x201808638140a77040142405381a8d00e63030c05d071dc240f098200a0f", + "0x8810770407010c8029ac107704180106302878107704174102b028701077", + "0x20ee0834020560512820ee08380219405029dc1005090140ac9040153205", + "0x3300a67041dc10220432c0a22041dc1025043200a6b041dc106a0418c0a1e", + "0xac108e02814ee08028480a630433456083b8484e08468144e083b820ce08", + "0x20ee080f020560517820ee08308219e0530820ee08168219c0516820ee08", + "0x1dc100509014b85e18838105c041dc102f043400a5e041dc106b0418c0a31", + "0x3400a3c041dc106b0418c0a36041dc101e040ac0a35041dc1063043440a05", + "0x3c10770404c10d20284c10770403810a4028e078360702070083b8206a08", + "0x3010d4029a018123b8201e0869814c0083b8200a1c029741077040143805", + "0x881077041801052029ac1077041741052028781077041a010a402814ee08", + "0x942477041a8100002814ee080e020a6050e1c0d40e3b820446b0f039aa05", + "0x1e80a6315848ee0838020000533820ee0813820f605029dc1025041e80a27", + "0x1dc102d042040a67041dc1067042040a2d041dc1063041ec0a053b8205608", + "0x2500a053b8200a1202970bc310735c5e61091dc242d338200a0f6b0145a08", + "0x1dc102f0418c0a3c041dc1061040ac0a36041dc1035043600a35041dc1005", + "0x20b8086d8140a7704014240502b6810054c814b4083b8206c086c8147008", + "0x16810770415810d9028e01077041781063028f01077040c4102b029581077", + "0x14c10df23020ee122a021bc052a020ee0829021ba0529020ee082d021b805", + "0x1e810b1029e810770400024125801400083b8208c08700140a77040142405", + "0x20ee083d82164053f020ee081c020c6053e020ee081e02056053d820ee08", + "0x20010770414c10b302814ee0809020b405029dc100509014fe7e3e038107f", + "0x2041c0841820ee0840021640541020ee081c020c60540820ee081e0205605", + "0x2114052e820ee08029800a13041dc100f0430c0a0f041dc1005610150682", + "0x1dc1013043100a5d041dc105d041a00a053b82018083e8141860091dc1012", + "0x140a770401424050f070e00e711a8d0123b8481c132e8200a13708142608", + "0x20d408318144a083b820d0081581444083b820d6086c014d6083b8200a94", + "0x7810db02814ee08028480a05718200a990299c10770408810d90289c1077", + "0x20ee0815821b20513820ee080e020c60512820ee0838020560515820ee08", + "0x21c861041dc2463043780a63041dc102d043740a2d041dc1067043700a67", + "0x21cc052f020ee081898024e5028c410770418410e002814ee08028480a2f", + "0x1dc105c0439c0a36041dc10270418c0a35041dc1025040ac0a5c041dc105e", + "0x20ee0817821d005029dc1060041f40a053b8200a12028f06c35070207808", + "0x381054041dc10380439c0a56041dc10270418c0a5a041dc1025040ac0a38", + "0x20ee08040219c05029dc10050901424087502010770901410e902950ac5a", + "0x140a77040142405098201013041dc100f043400a0f041dc100e0433c0a0e", + "0x3010d00283010770418010d102980107704048ba1213814ba083b8200a25", + "0x141c083b8200a087581410080402010770401410a4029a0100834020ee08", + "0x1dc100f04048440507820ee0807820d60507820ee0802bb00a053b8200a12", + "0x14e0083b820240829014d4083b820260829014d0083b8201c08768142608", + "0x1480a1c041dc10054a0140a7704030105302830c05d071dc1070351a01ca9", + "0x88d61e0702044083b82038084a814d6083b820c008290143c083b820ba08", + "0x3c40a0e041dc1008043c00a053b8200a120284810ef04020ee1202821dc05", + "0x200a2502814ee08028480a130402026083b8201e08790141e083b8201c08", + "0x20ee0806021e40506020ee0830021e60530020ee08091742427029741077", + "0x20ee0809020a4052e820ee0807021ea0507020ee0802821e805340201068", + "0x1480a0c041dc10054a0140a770404c10530284c1e123b820c05d093d80a60", + "0x1c0d46807020e0083b82018084a814d4083b8201e0829014d0083b8201008", + "0x3e80a053b8201e087c8141e0e091dc1012043e00a1202848ee0802821ee05", + "0x20a6052e84c247704030c0127d81418083b820100829014c0083b8201c08", + "0x20ee0835021f405029dc1068043e40a6a34048ee0802821f005029dc105d", + "0x881077041c010fc02870e0123b820d61e093ec0a6b041dc1013041480a1e", + "0x20ee0809021fe0509020ee0802821fc0512888240812820ee080e021fa05", + "0x1480a0c041dc1013041ac0a053b8201e082a014260f091dc100e041580a0e", + "0x200a9402814ee0830020a605301742477041a0181223014d0083b8201008", + "0x14c0a0f33870e012040701077041a81095029c01077041741052029a81077", + "0x30c1c1204014a454298141e362a14c0a0f02838240802948a8530283c6c54", + "0x404240802968a853070bca853074001c1204014a454298141e362a14c0a0f", + "0x200a5e2a14c1c0c17950a60f81814b836090d8110204014100f0903c1812", + "0x200a612a14c1c1c2a14c1d050704810052f150a60e060bca85307c101c12", + "0x200a6b2a14c1c0c0e150a60f83838240802978a8530719c5e542983e0c12", + "0x42c2408028201e0f0703c1e67074280a670419c1109029841068044201c12", + "0x43810050403c240f1284a1a1204014100f078381e0f1383a18052e820c008", + "0x10f04014100f0903c4412" + ], + "sierra_program_debug_info": { + "type_names": [ + [ + 0, + "RangeCheck" + ], + [ + 1, + "Unit" + ], + [ + 2, + "Tuple" + ], + [ + 3, + "core::panics::Panic" + ], + [ + 4, + "Array" + ], + [ + 5, + "Tuple>" + ], + [ + 6, + "core::panics::PanicResult::<((),)>" + ], + [ + 7, + "core::result::Result::<(), core::array::Array::>" + ], + [ + 8, + "felt252" + ], + [ + 9, + "core::result::Result::>" + ], + [ + 10, + "StorageAddress" + ], + [ + 11, + "StorageBaseAddress" + ], + [ + 12, + "wallet::wallet::SimpleWallet::balance::ContractMemberState" + ], + [ + 13, + "Tuple" + ], + [ + 14, + "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::balance::ContractMemberState, ())>" + ], + [ + 15, + "u128" + ], + [ + 16, + "core::integer::u256" + ], + [ + 17, + "wallet::wallet::SimpleWallet::DummyEvent" + ], + [ + 18, + "wallet::wallet::SimpleWallet::Event" + ], + [ + 19, + "Box" + ], + [ + 20, + "core::option::Option::>" + ], + [ + 21, + "Tuple" + ], + [ + 22, + "core::panics::PanicResult::<(core::felt252,)>" + ], + [ + 23, + "wallet::wallet::SimpleWallet::ContractState" + ], + [ + 24, + "Tuple" + ], + [ + 25, + "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::ContractState, ())>" + ], + [ + 26, + "core::option::Option::" + ], + [ + 27, + "Snapshot>" + ], + [ + 28, + "core::array::Span::" + ], + [ + 29, + "Tuple>" + ], + [ + 30, + "Tuple" + ], + [ + 31, + "core::panics::PanicResult::<(wallet::wallet::SimpleWallet::ContractState, core::felt252)>" + ], + [ + 32, + "BuiltinCosts" + ], + [ + 33, + "System" + ], + [ + 34, + "core::panics::PanicResult::<(core::array::Span::,)>" + ], + [ + 35, + "u32" + ], + [ + 36, + "GasBuiltin" + ] + ], + "libfunc_names": [ + [ + 0, + "revoke_ap_tracking" + ], + [ + 1, + "withdraw_gas" + ], + [ + 2, + "branch_align" + ], + [ + 3, + "struct_deconstruct>" + ], + [ + 4, + "array_len" + ], + [ + 5, + "snapshot_take" + ], + [ + 6, + "drop" + ], + [ + 7, + "u32_const<0>" + ], + [ + 8, + "rename" + ], + [ + 9, + "store_temp" + ], + [ + 10, + "store_temp" + ], + [ + 11, + "u32_eq" + ], + [ + 12, + "array_new" + ], + [ + 13, + "felt252_const<7733229381460288120802334208475838166080759535023995805565484692595>" + ], + [ + 14, + "store_temp" + ], + [ + 15, + "array_append" + ], + [ + 16, + "struct_construct" + ], + [ + 17, + "struct_construct>>" + ], + [ + 18, + "enum_init,)>, 1>" + ], + [ + 19, + "store_temp" + ], + [ + 20, + "store_temp" + ], + [ + 21, + "store_temp,)>>" + ], + [ + 22, + "get_builtin_costs" + ], + [ + 23, + "store_temp" + ], + [ + 24, + "withdraw_gas_all" + ], + [ + 25, + "struct_construct" + ], + [ + 26, + "struct_construct" + ], + [ + 27, + "store_temp" + ], + [ + 28, + "function_call" + ], + [ + 29, + "enum_match>" + ], + [ + 30, + "struct_deconstruct>" + ], + [ + 31, + "drop" + ], + [ + 32, + "snapshot_take" + ], + [ + 33, + "drop" + ], + [ + 34, + "store_temp>" + ], + [ + 35, + "function_call" + ], + [ + 36, + "drop" + ], + [ + 37, + "snapshot_take>" + ], + [ + 38, + "drop>" + ], + [ + 39, + "struct_construct>" + ], + [ + 40, + "struct_construct>>" + ], + [ + 41, + "enum_init,)>, 0>" + ], + [ + 42, + "felt252_const<375233589013918064796019>" + ], + [ + 43, + "drop>" + ], + [ + 44, + "store_temp>" + ], + [ + 45, + "function_call" + ], + [ + 46, + "enum_match>" + ], + [ + 47, + "function_call" + ], + [ + 48, + "enum_match>" + ], + [ + 49, + "drop>" + ], + [ + 50, + "felt252_const<485748461484230571791265682659113160264223489397539653310998840191492913>" + ], + [ + 51, + "function_call" + ], + [ + 52, + "struct_deconstruct" + ], + [ + 53, + "snapshot_take" + ], + [ + 54, + "store_temp" + ], + [ + 55, + "function_call" + ], + [ + 56, + "enum_match>" + ], + [ + 57, + "struct_deconstruct>" + ], + [ + 58, + "struct_construct>" + ], + [ + 59, + "enum_init, 0>" + ], + [ + 60, + "store_temp>" + ], + [ + 61, + "drop" + ], + [ + 62, + "enum_init, 1>" + ], + [ + 63, + "rename" + ], + [ + 64, + "struct_construct" + ], + [ + 65, + "store_temp" + ], + [ + 66, + "array_snapshot_pop_front" + ], + [ + 67, + "enum_init>, 0>" + ], + [ + 68, + "store_temp>>" + ], + [ + 69, + "store_temp>>" + ], + [ + 70, + "jump" + ], + [ + 71, + "enum_init>, 1>" + ], + [ + 72, + "enum_match>>" + ], + [ + 73, + "unbox" + ], + [ + 74, + "enum_init, 0>" + ], + [ + 75, + "store_temp>" + ], + [ + 76, + "enum_init, 1>" + ], + [ + 77, + "u128_const<2>" + ], + [ + 78, + "u128_const<0>" + ], + [ + 79, + "struct_construct" + ], + [ + 80, + "struct_construct" + ], + [ + 81, + "enum_init" + ], + [ + 82, + "store_temp" + ], + [ + 83, + "function_call>>" + ], + [ + 84, + "felt252_add" + ], + [ + 85, + "struct_deconstruct>" + ], + [ + 86, + "function_call" + ], + [ + 87, + "enum_match>" + ], + [ + 88, + "struct_deconstruct>" + ], + [ + 89, + "struct_construct>" + ], + [ + 90, + "enum_init, 0>" + ], + [ + 91, + "store_temp>" + ], + [ + 92, + "enum_init, 1>" + ], + [ + 93, + "drop>" + ], + [ + 94, + "storage_base_address_const<916907772491729262376534102982219947830828984996257231353398618781993312401>" + ], + [ + 95, + "storage_address_from_base" + ], + [ + 96, + "store_temp" + ], + [ + 97, + "storage_read_syscall" + ], + [ + 98, + "enum_init>, 0>" + ], + [ + 99, + "store_temp>>" + ], + [ + 100, + "enum_init>, 1>" + ], + [ + 101, + "rename>>" + ], + [ + 102, + "function_call::unwrap_syscall>" + ], + [ + 103, + "struct_construct>" + ], + [ + 104, + "enum_init, 0>" + ], + [ + 105, + "store_temp>" + ], + [ + 106, + "enum_init, 1>" + ], + [ + 107, + "function_call::into>" + ], + [ + 108, + "snapshot_take" + ], + [ + 109, + "drop" + ], + [ + 110, + "function_call" + ], + [ + 111, + "emit_event_syscall" + ], + [ + 112, + "enum_init>, 0>" + ], + [ + 113, + "store_temp>>" + ], + [ + 114, + "enum_init>, 1>" + ], + [ + 115, + "rename>>" + ], + [ + 116, + "function_call::unwrap_syscall>" + ], + [ + 117, + "enum_match>" + ], + [ + 118, + "struct_deconstruct>" + ], + [ + 119, + "storage_write_syscall" + ], + [ + 120, + "struct_construct>" + ], + [ + 121, + "enum_init, 0>" + ], + [ + 122, + "store_temp>" + ], + [ + 123, + "enum_init, 1>" + ], + [ + 124, + "enum_match>>" + ], + [ + 125, + "enum_match" + ], + [ + 126, + "felt252_const<604044455298473900658797727502986337863043931241839670982572839358997980713>" + ], + [ + 127, + "store_temp" + ], + [ + 128, + "function_call" + ], + [ + 129, + "enum_match>>" + ], + [ + 130, + "struct_construct>" + ], + [ + 131, + "enum_init, 0>" + ], + [ + 132, + "store_temp>" + ], + [ + 133, + "enum_init, 1>" + ], + [ + 134, + "struct_deconstruct" + ], + [ + 135, + "store_temp" + ], + [ + 136, + "function_call" + ], + [ + 137, + "dup" + ], + [ + 138, + "struct_deconstruct" + ], + [ + 139, + "drop" + ], + [ + 140, + "store_temp" + ], + [ + 141, + "function_call" + ], + [ + 142, + "rename>" + ], + [ + 143, + "rename" + ], + [ + 144, + "rename" + ], + [ + 145, + "u128_to_felt252" + ] + ], + "user_func_names": [ + [ + 0, + "wallet::wallet::SimpleWallet::__wrapper_get_balance" + ], + [ + 1, + "wallet::wallet::SimpleWallet::__wrapper_increase_balance" + ], + [ + 2, + "wallet::wallet::SimpleWallet::__wrapper_constructor" + ], + [ + 3, + "wallet::wallet::SimpleWallet::SimpleWallet::get_balance" + ], + [ + 4, + "core::Felt252Serde::serialize" + ], + [ + 5, + "core::Felt252Serde::deserialize" + ], + [ + 6, + "wallet::wallet::SimpleWallet::SimpleWallet::increase_balance" + ], + [ + 7, + "wallet::wallet::SimpleWallet::constructor" + ], + [ + 8, + "wallet::wallet::SimpleWallet::balance::InternalContractMemberStateImpl::read" + ], + [ + 9, + "wallet::wallet::SimpleWallet::ContractStateEventEmitter::emit::>" + ], + [ + 10, + "wallet::wallet::SimpleWallet::balance::InternalContractMemberStateImpl::write" + ], + [ + 11, + "core::starknet::SyscallResultTraitImpl::::unwrap_syscall" + ], + [ + 12, + "core::traits::TIntoT::::into" + ], + [ + 13, + "wallet::wallet::SimpleWallet::EventIsEvent::append_keys_and_data" + ], + [ + 14, + "core::starknet::SyscallResultTraitImpl::<()>::unwrap_syscall" + ], + [ + 15, + "wallet::wallet::SimpleWallet::DummyEventIsEvent::append_keys_and_data" + ], + [ + 16, + "core::integer::u256Serde::serialize" + ], + [ + 17, + "core::integer::U128Serde::serialize" + ] + ] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320", + "function_idx": 1 + }, + { + "selector": "0x39e11d48192e4333233c7eb19d10ad67c362bb28580c604d67884c85da39695", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "function_idx": 2 + } + ] + }, + "abi": [ + { + "type": "impl", + "name": "SimpleWallet", + "interface_name": "wallet::wallet::ISimpleWallet" + }, + { + "type": "interface", + "name": "wallet::wallet::ISimpleWallet", + "items": [ + { + "type": "function", + "name": "get_balance", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "increase_balance", + "inputs": [ + { + "name": "amount", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "initial_balance", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "event", + "name": "wallet::wallet::SimpleWallet::DummyEvent", + "kind": "struct", + "members": [ + { + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "wallet::wallet::SimpleWallet::Event", + "kind": "enum", + "variants": [ + { + "name": "DummyEvent", + "type": "wallet::wallet::SimpleWallet::DummyEvent", + "kind": "nested" + } + ] + } + ] +} \ No newline at end of file diff --git a/cli/src/main.rs b/cli/src/main.rs index c2dcbe052..177f70f55 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -202,7 +202,7 @@ fn invoke_parser( Some(Felt252::zero()), transaction_hash.unwrap(), )?; - let mut transactional_state = cached_state.create_transactional(); + let mut transactional_state = cached_state.create_transactional()?; let _tx_info = internal_invoke.apply(&mut transactional_state, &BlockContext::default(), 0)?; cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state)?)?; diff --git a/examples/contract_execution/main.rs b/examples/contract_execution/main.rs index cc7bb8a02..0bea3e760 100644 --- a/examples/contract_execution/main.rs +++ b/examples/contract_execution/main.rs @@ -24,7 +24,16 @@ use starknet_in_rust::{ }; use std::{path::Path, sync::Arc}; +use tracing_subscriber::EnvFilter; + fn main() { + tracing::subscriber::set_global_default( + tracing_subscriber::FmtSubscriber::builder() + .with_env_filter(EnvFilter::from_default_env()) + .finish(), + ) + .unwrap(); + // replace this with the path to your compiled contract let contract_path = "starknet_programs/fibonacci.json"; diff --git a/examples/lru_cache/main.rs b/examples/lru_cache/main.rs index f1ab212ff..266ad1074 100644 --- a/examples/lru_cache/main.rs +++ b/examples/lru_cache/main.rs @@ -96,7 +96,7 @@ fn run_contract( // Store the local cache changes into the shared cache. This updates the shared cache with all // the contracts used on this state. - contract_cache.extend(state.drain_private_contract_class_cache()); + contract_cache.extend(state.drain_private_contract_class_cache().unwrap()); invoke_tx_execution_info.call_info.unwrap().retdata } diff --git a/fuzzer/src/main.rs b/fuzzer/src/main.rs index 8bac1f09e..319652bc3 100644 --- a/fuzzer/src/main.rs +++ b/fuzzer/src/main.rs @@ -176,7 +176,7 @@ fn main() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [Felt252::from_bytes_be(data_to_ascii(data).as_bytes())].to_vec(), - execution_resources: ExecutionResources::default(), + execution_resources: Some(ExecutionResources::default()), class_hash: Some(class_hash), storage_read_values: vec![Felt252::from_bytes_be(data_to_ascii(data).as_bytes())], accessed_storage_keys: expected_accessed_storage_keys, diff --git a/rpc_state_reader/Cargo.toml b/rpc_state_reader/Cargo.toml index 370ee93d4..0cdbbf8ef 100644 --- a/rpc_state_reader/Cargo.toml +++ b/rpc_state_reader/Cargo.toml @@ -21,7 +21,7 @@ flate2 = "1.0.25" serde_with = "3.0.0" dotenv = "0.15.0" cairo-vm = "0.8.5" -blockifier = "0.2.0-rc0" +blockifier = "=0.2.0-rc0" starknet_in_rust = { path = "../", version = "0.4.0" } [dev-dependencies] diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 2ae84fab1..094029c55 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -138,7 +138,7 @@ mod tests { ); assert_eq!( - tx_trace.validate_invocation.calldata, + tx_trace.validate_invocation.as_ref().unwrap().calldata, Some(vec![ stark_felt!("1"), stark_felt!("690c876e61beda61e994543af68038edac4e1cb1990ab06e52a2d27e56a1232"), @@ -157,9 +157,16 @@ mod tests { stark_felt!("38bd34c31a0a5c"), ]) ); - assert_eq!(tx_trace.validate_invocation.retdata, Some(vec![])); + assert_eq!( + tx_trace.validate_invocation.as_ref().unwrap().retdata, + Some(vec![]) + ); assert_eq_sorted!( - tx_trace.validate_invocation.execution_resources, + tx_trace + .validate_invocation + .as_ref() + .unwrap() + .execution_resources, ExecutionResources { n_steps: 790, n_memory_holes: 51, @@ -170,7 +177,15 @@ mod tests { ]), } ); - assert_eq!(tx_trace.validate_invocation.internal_calls.len(), 1); + assert_eq!( + tx_trace + .validate_invocation + .as_ref() + .unwrap() + .internal_calls + .len(), + 1 + ); assert_eq!( tx_trace.function_invocation.as_ref().unwrap().calldata, @@ -243,7 +258,7 @@ mod tests { ); assert_eq!( - tx_trace.fee_transfer_invocation.calldata, + tx_trace.fee_transfer_invocation.as_ref().unwrap().calldata, Some(vec![ stark_felt!("1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"), stark_felt!("2b0322a23ba4"), @@ -251,11 +266,15 @@ mod tests { ]) ); assert_eq!( - tx_trace.fee_transfer_invocation.retdata, + tx_trace.fee_transfer_invocation.as_ref().unwrap().retdata, Some(vec![1u128.into()]) ); assert_eq_sorted!( - tx_trace.fee_transfer_invocation.execution_resources, + tx_trace + .fee_transfer_invocation + .as_ref() + .unwrap() + .execution_resources, ExecutionResources { n_steps: 586, n_memory_holes: 42, @@ -265,7 +284,15 @@ mod tests { ]), } ); - assert_eq!(tx_trace.fee_transfer_invocation.internal_calls.len(), 1); + assert_eq!( + tx_trace + .fee_transfer_invocation + .as_ref() + .unwrap() + .internal_calls + .len(), + 1 + ); } #[test] diff --git a/rpc_state_reader/src/rpc_state.rs b/rpc_state_reader/src/rpc_state.rs index 3ff561339..60bfd21b2 100644 --- a/rpc_state_reader/src/rpc_state.rs +++ b/rpc_state_reader/src/rpc_state.rs @@ -11,6 +11,7 @@ use starknet_api::{ state::StorageKey, transaction::{Transaction as SNTransaction, TransactionHash}, }; +use starknet_in_rust::definitions::block_context::StarknetChainId; use std::{collections::HashMap, env, fmt::Display}; use thiserror::Error; @@ -24,6 +25,16 @@ pub enum RpcChain { TestNet2, } +impl From for StarknetChainId { + fn from(network: RpcChain) -> StarknetChainId { + match network { + RpcChain::MainNet => StarknetChainId::MainNet, + RpcChain::TestNet => StarknetChainId::TestNet, + RpcChain::TestNet2 => StarknetChainId::TestNet2, + } + } +} + impl fmt::Display for RpcChain { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -147,9 +158,9 @@ pub struct RpcResponse { #[derive(Debug, Deserialize, Clone, Eq, PartialEq)] pub struct TransactionTrace { - pub validate_invocation: RpcCallInfo, + pub validate_invocation: Option, pub function_invocation: Option, - pub fee_transfer_invocation: RpcCallInfo, + pub fee_transfer_invocation: Option, pub signature: Vec, pub revert_error: Option, } @@ -390,12 +401,12 @@ impl RpcState { } } - pub fn get_contract_class(&self, class_hash: &ClassHash) -> SNContractClass { + pub fn get_contract_class(&self, class_hash: &ClassHash) -> Option { self.rpc_call_result( "starknet_getClass", &json!([self.block.to_value().unwrap(), class_hash.0.to_string()]), ) - .unwrap() + .ok() } pub fn get_class_hash_at(&self, contract_address: &ContractAddress) -> ClassHash { @@ -407,7 +418,7 @@ impl RpcState { contract_address.0.key().clone().to_string() ]), ) - .unwrap(); + .unwrap_or_default(); ClassHash(hash) } @@ -420,7 +431,8 @@ impl RpcState { contract_address.0.key().clone().to_string() ]), ) - .unwrap() + // When running deploy_account transactions, the nonce doesn't exist on the previous block so we return 0 + .unwrap_or_default() } pub fn get_storage_at( @@ -439,7 +451,7 @@ impl RpcState { self.block.to_value().unwrap() ]), ) - .unwrap() + .unwrap_or_default() } /// Requests the given transaction to the Feeder Gateway API. diff --git a/rpc_state_reader/src/utils.rs b/rpc_state_reader/src/utils.rs index a56d9f3b7..1a5ecffb4 100644 --- a/rpc_state_reader/src/utils.rs +++ b/rpc_state_reader/src/utils.rs @@ -11,7 +11,7 @@ use starknet_api::{ core::EntryPointSelector, deprecated_contract_class::{EntryPoint, EntryPointOffset, EntryPointType}, hash::{StarkFelt, StarkHash}, - transaction::{InvokeTransaction, Transaction}, + transaction::{DeclareTransaction, InvokeTransaction, Transaction}, }; #[derive(Debug, Deserialize)] @@ -82,6 +82,24 @@ pub fn deserialize_transaction_json( "unimplemented invoke version: {x}" ))), }, + "DEPLOY_ACCOUNT" => Ok(Transaction::DeployAccount(serde_json::from_value( + transaction, + )?)), + "DECLARE" => match tx_version.as_str() { + "0x0" => Ok(Transaction::Declare(DeclareTransaction::V0( + serde_json::from_value(transaction)?, + ))), + "0x1" => Ok(Transaction::Declare(DeclareTransaction::V1( + serde_json::from_value(transaction)?, + ))), + "0x2" => Ok(Transaction::Declare(DeclareTransaction::V2( + serde_json::from_value(transaction)?, + ))), + x => Err(serde::de::Error::custom(format!( + "unimplemented declare version: {x}" + ))), + }, + "L1_HANDLER" => Ok(Transaction::L1Handler(serde_json::from_value(transaction)?)), x => Err(serde::de::Error::custom(format!( "unimplemented transaction type deserialization: {x}" ))), diff --git a/rpc_state_reader/tests/blockifier_tests.rs b/rpc_state_reader/tests/blockifier_tests.rs index a32139934..584464929 100644 --- a/rpc_state_reader/tests/blockifier_tests.rs +++ b/rpc_state_reader/tests/blockifier_tests.rs @@ -3,11 +3,16 @@ use blockifier::{ execution::{contract_class::ContractClass, entry_point::CallInfo}, state::{ cached_state::{CachedState, GlobalContractCache}, + errors::StateError, state_api::{StateReader, StateResult}, }, transaction::{ - account_transaction::AccountTransaction, objects::TransactionExecutionInfo, - transactions::ExecutableTransaction, + account_transaction::AccountTransaction, + objects::TransactionExecutionInfo, + transactions::{ + DeclareTransaction, DeployAccountTransaction, ExecutableTransaction, + L1HandlerTransaction, + }, }, }; use blockifier::{ @@ -27,7 +32,10 @@ use starknet::core::types::ContractClass as SNContractClass; use starknet_api::{ block::BlockNumber, contract_address, - core::{ClassHash, CompiledClassHash, ContractAddress, Nonce, PatriciaKey}, + core::{ + calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, + PatriciaKey, + }, hash::{StarkFelt, StarkHash}, patricia_key, stark_felt, state::StorageKey, @@ -62,7 +70,7 @@ impl StateReader for RpcStateReader { class_hash: &ClassHash, ) -> StateResult { Ok(match self.0.get_contract_class(class_hash) { - SNContractClass::Legacy(compressed_legacy_cc) => { + Some(SNContractClass::Legacy(compressed_legacy_cc)) => { let as_str = utils::decode_reader(compressed_legacy_cc.program).unwrap(); let program = Program::from_bytes(as_str.as_bytes(), None).unwrap(); let entry_points_by_type = utils::map_entry_points_by_type_legacy( @@ -74,7 +82,7 @@ impl StateReader for RpcStateReader { }); BlockifierContractClass::V0(ContractClassV0(inner)) } - SNContractClass::Sierra(flattened_sierra_cc) => { + Some(SNContractClass::Sierra(flattened_sierra_cc)) => { let middle_sierra: utils::MiddleSierraContractClass = { let v = serde_json::to_value(flattened_sierra_cc).unwrap(); serde_json::from_value(v).unwrap() @@ -89,6 +97,7 @@ impl StateReader for RpcStateReader { let casm_cc = CasmContractClass::from_contract_class(sierra_cc, false).unwrap(); BlockifierContractClass::V1(casm_cc.try_into().unwrap()) } + None => return Err(StateError::UndeclaredClassHash(*class_hash)), }) } @@ -176,6 +185,46 @@ pub fn execute_tx( let invoke = InvokeTransaction { tx, tx_hash }; AccountTransaction::Invoke(invoke) } + SNTransaction::DeployAccount(tx) => { + let contract_address = calculate_contract_address( + tx.contract_address_salt, + tx.class_hash, + &tx.constructor_calldata, + ContractAddress::default(), + ) + .unwrap(); + AccountTransaction::DeployAccount(DeployAccountTransaction { + tx, + tx_hash, + contract_address, + }) + } + SNTransaction::Declare(tx) => { + // Fetch the contract_class from the next block (as we don't have it in the previous one) + let mut next_block_state_reader = + RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); + let contract_class = next_block_state_reader + .get_compiled_contract_class(&tx.class_hash()) + .unwrap(); + + let declare = DeclareTransaction::new(tx, tx_hash, contract_class).unwrap(); + AccountTransaction::Declare(declare) + } + SNTransaction::L1Handler(tx) => { + // As L1Hanlder is not an account transaction we execute it here and return the result + let blockifier_tx = L1HandlerTransaction { + tx, + tx_hash, + paid_fee_on_l1: starknet_api::transaction::Fee(u128::MAX), + }; + return ( + blockifier_tx + .execute(&mut state, &block_context, true, true) + .unwrap(), + trace, + receipt, + ); + } _ => unimplemented!(), }; @@ -286,6 +335,46 @@ fn blockifier_test_recent_tx() { 186551, // real block 186552 RpcChain::MainNet )] +#[test_case( + "0x1cbc74e101a1533082a021ce53235cfd744899b0ff948d1949a64646e0f15c2", + 885298, // real block 885299 + RpcChain::TestNet +)] +#[test_case( + "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", + 281513, // real block 281514 + RpcChain::MainNet +)] +#[test_case( + "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", + 351268, // real block 351269 + RpcChain::MainNet +)] +#[test_case( + "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", + 351225, // real block 351226 + RpcChain::MainNet +)] +// DeployAccount for different account providers (as of October 2023): +// All of them were deployed on testnet using starkli +// OpenZeppelin (v0.7.0) +#[test_case( + "0x0012696c03a0f0301af190288d9824583be813b71882308e4c5d686bf5967ec5", + 889866, // real block 889867 + RpcChain::TestNet +)] +// Braavos (v3.21.10) +#[test_case( + "0x04dc838fd4ed265ab2ea5fbab08e67b398e3caaedf75c548113c6b2f995fc9db", + 889858, // real block 889859 + RpcChain::TestNet +)] +// Argent X (v5.7.0) +#[test_case( + "0x01583c47a929f81f6a8c74d31708a7f161603893435d51b6897017fdcdaafee4", + 889897, // real block 889898 + RpcChain::TestNet +)] fn blockifier_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) { let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -357,3 +446,38 @@ fn blockifier_test_case_reverted_tx(hash: &str, block_number: u64, chain: RpcCha ); } } + +#[test_case( + // Declare tx + "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", + 347899, // real block 347900 + RpcChain::MainNet +)] +#[test_case( + // Declare tx + "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", + 271887, // real block 271888 + RpcChain::MainNet +)] +fn blockifier_test_case_declare_tx(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); + let TransactionExecutionInfo { + execute_call_info, + actual_fee, + .. + } = tx_info; + + assert!(execute_call_info.is_none()); + + let actual_fee = actual_fee.0; + if receipt.actual_fee != actual_fee { + let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; + + if diff >= 5 { + assert_eq!( + actual_fee, receipt.actual_fee, + "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", + ); + } + } +} diff --git a/rpc_state_reader/tests/sir_tests.rs b/rpc_state_reader/tests/sir_tests.rs index 8e49d1aaa..44d480490 100644 --- a/rpc_state_reader/tests/sir_tests.rs +++ b/rpc_state_reader/tests/sir_tests.rs @@ -8,10 +8,10 @@ use starknet_api::{ hash::{StarkFelt, StarkHash}, stark_felt, state::StorageKey, - transaction::{Transaction as SNTransaction, TransactionHash}, + transaction::{Transaction as SNTransaction, TransactionHash, TransactionVersion}, }; use starknet_in_rust::{ - core::errors::state_errors::StateError, + core::{contract_address::compute_casm_class_hash, errors::state_errors::StateError}, definitions::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, constants::{ @@ -26,7 +26,7 @@ use starknet_in_rust::{ cached_state::CachedState, contract_class_cache::PermanentContractClassCache, state_api::StateReader, state_cache::StorageEntry, BlockInfo, }, - transaction::{InvokeFunction, Transaction}, + transaction::{Declare, DeclareV2, DeployAccount, InvokeFunction, L1Handler}, utils::{Address, ClassHash}, }; @@ -34,12 +34,15 @@ use test_case::test_case; use rpc_state_reader::rpc_state::*; +#[derive(Debug)] pub struct RpcStateReader(RpcState); impl StateReader for RpcStateReader { fn get_contract_class(&self, class_hash: &ClassHash) -> Result { let hash = SNClassHash(StarkHash::new(*class_hash).unwrap()); - Ok(CompiledClass::from(self.0.get_contract_class(&hash))) + Ok(CompiledClass::from( + self.0.get_contract_class(&hash).unwrap(), + )) } fn get_class_hash_at(&self, contract_address: &Address) -> Result { @@ -84,10 +87,12 @@ impl StateReader for RpcStateReader { } #[allow(unused)] -pub fn execute_tx( +pub fn execute_tx_configurable( tx_hash: &str, network: RpcChain, block_number: BlockNumber, + skip_validate: bool, + skip_nonce_check: bool, ) -> ( TransactionExecutionInfo, TransactionTrace, @@ -135,9 +140,79 @@ pub fn execute_tx( // Get transaction before giving ownership of the reader let tx_hash = TransactionHash(stark_felt!(tx_hash)); let tx = match rpc_reader.0.get_transaction(&tx_hash) { - SNTransaction::Invoke(tx) => Transaction::InvokeFunction( - InvokeFunction::from_invoke_transaction(tx, chain_id).unwrap(), - ), + SNTransaction::Invoke(tx) => InvokeFunction::from_invoke_transaction(tx, chain_id) + .unwrap() + .create_for_simulation(skip_validate, false, false, false, skip_nonce_check), + SNTransaction::DeployAccount(tx) => { + DeployAccount::from_sn_api_transaction(tx, chain_id.to_felt()) + .unwrap() + .create_for_simulation(skip_validate, false, false, false) + } + SNTransaction::Declare(tx) => { + // Fetch the contract_class from the next block (as we don't have it in the previous one) + let next_block_state_reader = + RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); + let contract_class = next_block_state_reader + .get_contract_class(tx.class_hash().0.bytes().try_into().unwrap()) + .unwrap(); + + if tx.version() != TransactionVersion(2_u8.into()) { + let contract_class = match contract_class { + CompiledClass::Deprecated(cc) => cc.as_ref().clone(), + _ => unreachable!(), + }; + + let declare = Declare::new_with_tx_and_class_hash( + contract_class, + Address(Felt252::from_bytes_be(tx.sender_address().0.key().bytes())), + tx.max_fee().0, + Felt252::from_bytes_be(tx.version().0.bytes()), + tx.signature() + .0 + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(), + Felt252::from_bytes_be(tx.nonce().0.bytes()), + Felt252::from_bytes_be(tx_hash.0.bytes()), + tx.class_hash().0.bytes().try_into().unwrap(), + ) + .unwrap(); + declare.create_for_simulation(skip_validate, false, false, false) + } else { + let contract_class = match contract_class { + CompiledClass::Casm(cc) => cc.as_ref().clone(), + _ => unreachable!(), + }; + + let compiled_class_hash = compute_casm_class_hash(&contract_class).unwrap(); + + let declare = DeclareV2::new_with_sierra_class_hash_and_tx_hash( + None, + Felt252::from_bytes_be(tx.class_hash().0.bytes()), + Some(contract_class), + compiled_class_hash, + Address(Felt252::from_bytes_be(tx.sender_address().0.key().bytes())), + tx.max_fee().0, + Felt252::from_bytes_be(tx.version().0.bytes()), + tx.signature() + .0 + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(), + Felt252::from_bytes_be(tx.nonce().0.bytes()), + Felt252::from_bytes_be(tx_hash.0.bytes()), + ) + .unwrap(); + declare.create_for_simulation(skip_validate, false, false, false) + } + } + SNTransaction::L1Handler(tx) => L1Handler::from_sn_api_tx( + tx, + Felt252::from_bytes_be(tx_hash.0.bytes()), + Some(Felt252::from(u128::MAX)), + ) + .unwrap() + .create_for_simulation(skip_validate, false), _ => unimplemented!(), }; @@ -166,6 +241,30 @@ pub fn execute_tx( ) } +pub fn execute_tx( + tx_hash: &str, + network: RpcChain, + block_number: BlockNumber, +) -> ( + TransactionExecutionInfo, + TransactionTrace, + RpcTransactionReceipt, +) { + execute_tx_configurable(tx_hash, network, block_number, false, false) +} + +pub fn execute_tx_without_validate( + tx_hash: &str, + network: RpcChain, + block_number: BlockNumber, +) -> ( + TransactionExecutionInfo, + TransactionTrace, + RpcTransactionReceipt, +) { + execute_tx_configurable(tx_hash, network, block_number, true, true) +} + #[test] fn test_get_transaction_try_from() { let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); @@ -243,6 +342,51 @@ fn test_get_gas_price() { 186551, // real block 186552 RpcChain::MainNet )] +#[test_case( + "0x176a92e8df0128d47f24eebc17174363457a956fa233cc6a7f8561bfbd5023a", + 317092, // real block 317093 + RpcChain::MainNet +)] +#[test_case( + "0x1cbc74e101a1533082a021ce53235cfd744899b0ff948d1949a64646e0f15c2", + 885298, // real block 885299 + RpcChain::TestNet +)] +#[test_case( + "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", + 281513, // real block 281514 + RpcChain::MainNet +)] +#[test_case( + "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", + 351268, // real block 351269 + RpcChain::MainNet +)] +#[test_case( + "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", + 351225, // real block 351226 + RpcChain::MainNet +)] +// DeployAccount for different account providers (as of October 2023): +// All of them were deployed on testnet using starkli +// OpenZeppelin (v0.7.0) +#[test_case( + "0x0012696c03a0f0301af190288d9824583be813b71882308e4c5d686bf5967ec5", + 889866, // real block 889867 + RpcChain::TestNet +)] +// Braavos (v3.21.10) +#[test_case( + "0x04dc838fd4ed265ab2ea5fbab08e67b398e3caaedf75c548113c6b2f995fc9db", + 889858, // real block 889859 + RpcChain::TestNet +)] +// Argent X (v5.7.0) +#[test_case( + "0x01583c47a929f81f6a8c74d31708a7f161603893435d51b6897017fdcdaafee4", + 889897, // real block 889898 + RpcChain::TestNet +)] fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) { let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -260,12 +404,14 @@ fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) // check Cairo VM execution resources assert_eq_sorted!( - execution_resources, - trace - .function_invocation - .as_ref() - .unwrap() - .execution_resources, + execution_resources.as_ref(), + Some( + &trace + .function_invocation + .as_ref() + .unwrap() + .execution_resources + ), "execution resources mismatch" ); @@ -356,3 +502,52 @@ fn starknet_in_rust_test_case_reverted_tx(hash: &str, block_number: u64, chain: ); } } + +#[test_case( + "0x038c307a0a324dc92778820f2c6317f40157c06b12a7e537f7a16b2c015f64e7", + 274333-1, + RpcChain::MainNet +)] +fn test_validate_fee(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); + let (tx_info_without_fee, _trace, _receipt) = + execute_tx_without_validate(hash, chain, BlockNumber(block_number)); + + assert_eq!(tx_info.actual_fee, receipt.actual_fee); + assert!(tx_info_without_fee.actual_fee < tx_info.actual_fee); +} + +#[test_case( + // Declare tx + "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", + 347899, // real block 347900 + RpcChain::MainNet +)] +#[test_case( + // Declare tx + "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", + 271887, // real block 271888 + RpcChain::MainNet +)] +fn starknet_in_rust_test_case_declare_tx(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, _trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number)); + let TransactionExecutionInfo { + call_info, + actual_fee, + .. + } = tx_info; + + assert!(call_info.is_none()); + + let actual_fee = actual_fee; + if receipt.actual_fee != actual_fee { + let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; + + if diff >= 5 { + assert_eq!( + actual_fee, receipt.actual_fee, + "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", + ); + } + } +} diff --git a/rust-toolchain b/rust-toolchain index 2d24a1e07..baa36b056 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.72.1" components = ["rustfmt", "clippy"] profile = "minimal" diff --git a/src/core/contract_address/casm_contract_address.rs b/src/core/contract_address/casm_contract_address.rs index 537146e23..23dc701e8 100644 --- a/src/core/contract_address/casm_contract_address.rs +++ b/src/core/contract_address/casm_contract_address.rs @@ -112,7 +112,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/contract_a.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm").unwrap(); expected_result = felt_str!( "321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f", 16 @@ -144,7 +144,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/deploy.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm").unwrap(); expected_result = felt_str!( "53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0", 16 @@ -177,7 +177,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/fibonacci.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm").unwrap(); expected_result = felt_str!( "6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89", 16 @@ -210,7 +210,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/factorial.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm").unwrap(); expected_result = felt_str!( "7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641", 16 @@ -243,7 +243,7 @@ mod tests { let expected_result; #[cfg(not(feature = "cairo_1_tests"))] { - file = File::open("starknet_programs/cairo2/emit_event.casm").unwrap(); + file = File::open("starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm").unwrap(); expected_result = felt_str!( "3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2", 16 @@ -271,7 +271,7 @@ mod tests { #[test] fn test_declare_tx_class_hash() { - let file = File::open("starknet_programs/cairo2/events.casm").unwrap(); + let file = File::open("starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm").unwrap(); let reader = BufReader::new(file); let contract_class: CasmContractClass = serde_json::from_reader(reader).unwrap(); diff --git a/src/core/contract_address/deprecated_contract_address.rs b/src/core/contract_address/deprecated_contract_address.rs index 325902d45..07e7e2911 100644 --- a/src/core/contract_address/deprecated_contract_address.rs +++ b/src/core/contract_address/deprecated_contract_address.rs @@ -158,7 +158,7 @@ impl serde_json::ser::Formatter for PythonDefaultFormatter { } else { let buf = c.encode_utf16(&mut buf); for i in buf { - write!(writer, r"\u{:4x}", i)?; + write!(writer, r"\u{:04x}", i)?; } } } diff --git a/src/core/contract_address/sierra_contract_address.rs b/src/core/contract_address/sierra_contract_address.rs index 1bbcfb1e9..a4df995c2 100644 --- a/src/core/contract_address/sierra_contract_address.rs +++ b/src/core/contract_address/sierra_contract_address.rs @@ -4,7 +4,10 @@ use cairo_lang_starknet::{ contract_class::{ContractClass as SierraContractClass, ContractEntryPoint}, }; use cairo_vm::felt::Felt252; +use serde::Serialize; +use serde_json::ser::Formatter; use starknet_crypto::{poseidon_hash_many, FieldElement, PoseidonHasher}; +use std::io::{self, Cursor}; const CONTRACT_CLASS_VERSION: &[u8] = b"CONTRACT_CLASS_V0.1.0"; @@ -60,14 +63,22 @@ pub fn compute_sierra_class_hash( hasher.update(constructors); // Hash abi - let abi = serde_json_pythonic::to_string_pythonic( - &contract_class + let abi = { + let mut buf = Cursor::new(Vec::new()); + let mut fmt = serde_json::Serializer::with_formatter(&mut buf, PythonJsonFormatter); + + contract_class .abi .as_ref() .ok_or(ContractAddressError::MissingAbi)? - .items, - ) - .map_err(|_| ContractAddressError::MissingAbi)?; + .items + .serialize(&mut fmt) + .map_err(|_| ContractAddressError::MissingAbi)?; + + // Note: The following unwrap should never be triggered as long as serde_json generates + // UTF-8 encoded data, which in practice means it should never panic. + String::from_utf8(buf.into_inner()).unwrap() + }; let abi_hash = FieldElement::from_byte_slice_be(&starknet_keccak(abi.as_bytes()).to_bytes_be()) .map_err(|_err| { @@ -126,7 +137,8 @@ mod tests { /// Test the correctness of the compute_sierra_class_hash function for a specific testnet contract. #[test] fn test_declare_tx_from_testnet() { - let file = File::open("starknet_programs/cairo2/events.sierra").unwrap(); + let file = File::open("starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra").unwrap(); + // 0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3 let reader = BufReader::new(file); let sierra_contract_class: SierraContractClass = serde_json::from_reader(reader).unwrap(); @@ -142,3 +154,56 @@ mod tests { ) } } + +struct PythonJsonFormatter; + +impl Formatter for PythonJsonFormatter { + fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> + where + W: ?Sized + io::Write, + { + if first { + Ok(()) + } else { + writer.write_all(b", ") + } + } + + fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> + where + W: ?Sized + io::Write, + { + if first { + Ok(()) + } else { + writer.write_all(b", ") + } + } + + fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> + where + W: ?Sized + io::Write, + { + writer.write_all(b": ") + } + + fn write_string_fragment(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> + where + W: ?Sized + io::Write, + { + let mut buf = [0, 0]; + + for c in fragment.chars() { + if c.is_ascii() { + writer.write_all(&[c as u8])?; + } else { + let buf = c.encode_utf16(&mut buf); + for i in buf { + write!(writer, r"\u{i:04x}")?; + } + } + } + + Ok(()) + } +} diff --git a/src/core/errors/state_errors.rs b/src/core/errors/state_errors.rs index 7d6b3aa89..ba09e3e51 100644 --- a/src/core/errors/state_errors.rs +++ b/src/core/errors/state_errors.rs @@ -48,4 +48,6 @@ pub enum StateError { CustomError(String), #[error(transparent)] ByteArray(#[from] FromByteArrayError), + #[error("Failed to read contract class cache")] + FailedToReadContractClassCache, } diff --git a/src/definitions/constants.rs b/src/definitions/constants.rs index 77bf941c9..4087af325 100644 --- a/src/definitions/constants.rs +++ b/src/definitions/constants.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; pub(crate) const L2_TO_L1_MSG_HEADER_SIZE: usize = 3; pub(crate) const L1_TO_L2_MSG_HEADER_SIZE: usize = 5; -pub(crate) const DEPLOYMENT_INFO_SIZE: usize = 2; +pub(crate) const CLASS_UPDATE_SIZE: usize = 1; pub(crate) const CONSUMED_MSG_TO_L2_N_TOPICS: usize = 3; pub(crate) const LOG_MSG_TO_L1_N_TOPICS: usize = 2; pub(crate) const N_DEFAULT_TOPICS: usize = 1; // Events have one default topic. @@ -37,9 +37,9 @@ lazy_static! { 0.into(), 1.into(), 2.into(), - &0.into() | &QUERY_VERSION_BASE.clone(), - &1.into() | &QUERY_VERSION_BASE.clone(), - &2.into() | &QUERY_VERSION_BASE.clone(), + &Into::::into(0) | &QUERY_VERSION_BASE.clone(), + &Into::::into(1) | &QUERY_VERSION_BASE.clone(), + &Into::::into(2) | &QUERY_VERSION_BASE.clone(), ]; } diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 30c86cc91..c13994ca9 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -13,7 +13,7 @@ use crate::{ contract_class_cache::ContractClassCache, contract_storage_state::ContractStorageState, state_api::{State, StateReader}, - ExecutionResourcesManager, + ExecutionResourcesManager, StateDiff, }, syscalls::{ business_logic_syscall_handler::BusinessLogicSyscallHandler, @@ -41,6 +41,16 @@ use cairo_vm::{ }; use std::sync::Arc; +#[cfg(feature = "cairo-native")] +use { + crate::syscalls::native_syscall_handler::NativeSyscallHandler, + cairo_native::{ + context::NativeContext, execution_result::NativeExecutionResult, executor::NativeExecutor, + metadata::syscall_handler::SyscallHandlerMeta, utils::felt252_bigint, + }, + serde_json::Value, +}; + #[derive(Debug, Default)] pub struct ExecutionResult { pub call_info: Option, @@ -146,6 +156,45 @@ impl ExecutionEntryPoint { return Err(e); } + let n_reverted_steps = + (max_steps as usize) - resources_manager.cairo_usage.n_steps; + Ok(ExecutionResult { + call_info: None, + revert_error: Some(e.to_string()), + n_reverted_steps, + }) + } + } + } + CompiledClass::Sierra(sierra_contract_class) => { + let mut transactional_state = state.create_transactional()?; + + match self.native_execute( + &mut transactional_state, + sierra_contract_class, + tx_execution_context, + block_context, + ) { + Ok(call_info) => { + state.apply_state_update(&StateDiff::from_cached_state( + transactional_state, + )?)?; + + Ok(ExecutionResult { + call_info: Some(call_info), + revert_error: None, + n_reverted_steps: 0, + }) + } + Err(e) => { + if !support_reverted { + state.apply_state_update(&StateDiff::from_cached_state( + transactional_state, + )?)?; + + return Err(e); + } + let n_reverted_steps = (max_steps as usize) - resources_manager.cairo_usage.n_steps; Ok(ExecutionResult { @@ -174,15 +223,15 @@ impl ExecutionEntryPoint { let mut default_entry_point = None; let entry_point = entry_points .iter() - .filter_map(|x| { + .filter(|x| { if x.selector() == &*DEFAULT_ENTRY_POINT_SELECTOR { - default_entry_point = Some(x); + default_entry_point = Some(*x); } - (x.selector() == &self.entry_point_selector).then_some(x) + x.selector() == &self.entry_point_selector }) - .fold(Ok(None), |acc, x| match acc { - Ok(None) => Ok(Some(x)), + .try_fold(None, |acc, x| match acc { + None => Ok(Some(x)), _ => Err(TransactionError::NonUniqueEntryPoint), })?; @@ -206,15 +255,15 @@ impl ExecutionEntryPoint { let mut default_entry_point = None; let entry_point = entry_points .iter() - .filter_map(|x| { + .filter(|x| { if x.selector == DEFAULT_ENTRY_POINT_SELECTOR.to_biguint() { - default_entry_point = Some(x); + default_entry_point = Some(*x); } - (x.selector == self.entry_point_selector.to_biguint()).then_some(x) + x.selector == self.entry_point_selector.to_biguint() }) - .fold(Ok(None), |acc, x| match acc { - Ok(None) => Ok(Some(x)), + .try_fold(None, |acc, x| match acc { + None => Ok(Some(x)), _ => Err(TransactionError::NonUniqueEntryPoint), })?; entry_point @@ -245,7 +294,7 @@ impl ExecutionEntryPoint { entry_point_type: Some(self.entry_point_type), calldata: self.calldata.clone(), retdata, - execution_resources: execution_resources.filter_unused_builtins(), + execution_resources: Some(execution_resources.filter_unused_builtins()), events, l2_to_l1_messages, storage_read_values: starknet_storage_state.read_values, @@ -282,7 +331,7 @@ impl ExecutionEntryPoint { .iter() .map(|n| n.get_int_ref().cloned().unwrap_or_default()) .collect(), - execution_resources: execution_resources.filter_unused_builtins(), + execution_resources: Some(execution_resources.filter_unused_builtins()), events, l2_to_l1_messages, storage_read_values: starknet_storage_state.read_values, @@ -569,4 +618,183 @@ impl ExecutionEntryPoint { call_result, ) } + + #[cfg(not(feature = "cairo-native"))] + #[inline(always)] + fn native_execute( + &self, + _state: &mut CachedState, + _contract_class: Arc, + _tx_execution_context: &mut TransactionExecutionContext, + _block_context: &BlockContext, + ) -> Result { + Err(TransactionError::SierraCompileError( + "This version of SiR was compiled without the Cairo Native feature".to_string(), + )) + } + + #[cfg(feature = "cairo-native")] + #[inline(always)] + fn native_execute( + &self, + state: &mut CachedState, + contract_class: Arc, + tx_execution_context: &TransactionExecutionContext, + block_context: &BlockContext, + ) -> Result { + use cairo_lang_sierra::{ + extensions::core::{CoreLibfunc, CoreType, CoreTypeConcrete}, + program_registry::ProgramRegistry, + }; + use serde_json::json; + + use crate::syscalls::business_logic_syscall_handler::SYSCALL_BASE; + + let entry_point = match self.entry_point_type { + EntryPointType::External => contract_class + .entry_points_by_type + .external + .iter() + .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) + .unwrap(), + EntryPointType::Constructor => contract_class + .entry_points_by_type + .constructor + .iter() + .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) + .unwrap(), + EntryPointType::L1Handler => contract_class + .entry_points_by_type + .l1_handler + .iter() + .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) + .unwrap(), + }; + + let sierra_program = contract_class.extract_sierra_program().unwrap(); + let program_registry: ProgramRegistry = + ProgramRegistry::new(&sierra_program).unwrap(); + + let native_context = NativeContext::new(); + let mut native_program = native_context.compile(&sierra_program).unwrap(); + let contract_storage_state = + ContractStorageState::new(state, self.contract_address.clone()); + + let syscall_handler = NativeSyscallHandler { + starknet_storage_state: contract_storage_state, + events: Vec::new(), + l2_to_l1_messages: Vec::new(), + contract_address: self.contract_address.clone(), + internal_calls: Vec::new(), + caller_address: self.caller_address.clone(), + entry_point_selector: self.entry_point_selector.clone(), + tx_execution_context: tx_execution_context.clone(), + block_context: block_context.clone(), + resources_manager: Default::default(), + }; + + native_program + .insert_metadata(SyscallHandlerMeta::new(&syscall_handler)) + .unwrap(); + + let syscall_addr = native_program + .get_metadata::() + .unwrap() + .as_ptr() + .as_ptr() as *const () as usize; + + let entry_point_fn = &sierra_program + .funcs + .iter() + .find(|x| x.id.id == (entry_point.function_idx as u64)) + .unwrap(); + let ret_types: Vec<&CoreTypeConcrete> = entry_point_fn + .signature + .ret_types + .iter() + .map(|x| program_registry.get_type(x).unwrap()) + .collect(); + let entry_point_id = &entry_point_fn.id; + + let required_init_gas = native_program.get_required_init_gas(entry_point_id); + + let calldata: Vec<_> = self + .calldata + .iter() + .map(|felt| felt252_bigint(felt.to_bigint())) + .collect(); + + /* + Below we construct `params`, the Serde value that MLIR expects. It consists of the following: + + - One `null` value for each builtin that is going to be used. + - The maximum amout of gas allowed by the call. + - `syscall_addr`, the address of the syscall handler. + - `calldata`, an array of Felt arguments to the method being called. + */ + + let wrapped_calldata = vec![calldata]; + let params: Vec = sierra_program.funcs[entry_point_id.id as usize] + .params + .iter() + .map(|param| { + match param.ty.debug_name.as_ref().unwrap().as_str() { + "GasBuiltin" => { + json!(self.initial_gas) + } + "Pedersen" | "SegmentArena" | "RangeCheck" | "Bitwise" | "Poseidon" => { + json!(null) + } + "System" => { + json!(syscall_addr) + } + // calldata + "core::array::Span::" => json!(wrapped_calldata), + x => { + unimplemented!("unhandled param type: {:?}", x); + } + } + }) + .collect(); + + let mut writer: Vec = Vec::new(); + let returns = &mut serde_json::Serializer::new(&mut writer); + + let native_executor = NativeExecutor::new(native_program); + + native_executor + .execute(entry_point_id, json!(params), returns, required_init_gas) + .map_err(|e| TransactionError::CustomError(format!("cairo-native error: {:?}", e)))?; + + let value = NativeExecutionResult::deserialize_from_ret_types( + &mut serde_json::Deserializer::from_slice(&writer), + &ret_types, + ) + .expect("failed to serialize starknet execution result"); + + Ok(CallInfo { + caller_address: self.caller_address.clone(), + call_type: Some(self.call_type.clone()), + contract_address: self.contract_address.clone(), + code_address: self.code_address.clone(), + class_hash: Some( + self.get_code_class_hash(syscall_handler.starknet_storage_state.state)?, + ), + entry_point_selector: Some(self.entry_point_selector.clone()), + entry_point_type: Some(self.entry_point_type), + calldata: self.calldata.clone(), + retdata: value.return_values, + execution_resources: None, + events: syscall_handler.events, + storage_read_values: syscall_handler.starknet_storage_state.read_values, + accessed_storage_keys: syscall_handler.starknet_storage_state.accessed_keys, + failure_flag: value.failure_flag, + l2_to_l1_messages: syscall_handler.l2_to_l1_messages, + internal_calls: syscall_handler.internal_calls, + gas_consumed: self + .initial_gas + .saturating_sub(SYSCALL_BASE) + .saturating_sub(value.remaining_gas), + }) + } } diff --git a/src/execution/gas_usage.rs b/src/execution/gas_usage.rs index f0d254dc7..85e26a90a 100644 --- a/src/execution/gas_usage.rs +++ b/src/execution/gas_usage.rs @@ -1,6 +1,7 @@ use crate::definitions::constants::*; use crate::execution::L2toL1MessageInfo; use crate::services::eth_definitions::eth_gas_constants::*; +use crate::state::state_api::StateChangesCount; /// Estimates L1 gas usage by Starknet's update state and the verifier /// @@ -19,16 +20,13 @@ use crate::services::eth_definitions::eth_gas_constants::*; /// The estimation of L1 gas usage as a `usize` value. pub fn calculate_tx_gas_usage( l2_to_l1_messages: Vec, - n_modified_contracts: usize, - n_storage_changes: usize, + state_changes: &StateChangesCount, l1_handler_payload_size: Option, - n_deployments: usize, ) -> usize { let residual_message_segment_length = get_message_segment_lenght(&l2_to_l1_messages, l1_handler_payload_size); - let residual_onchain_data_segment_length = - get_onchain_data_segment_length(n_modified_contracts, n_storage_changes, n_deployments); + let residual_onchain_data_segment_length = get_onchain_data_segment_length(state_changes); let n_l2_to_l1_messages = l2_to_l1_messages.len(); let n_l1_to_l2_messages = match l1_handler_payload_size { @@ -95,22 +93,18 @@ pub fn get_message_segment_lenght( } /// Calculates the amount of `felt252` added to the output message's segment by the given operations. -/// -/// # Parameters: -/// -/// - `n_modified_contracts`: The number of contracts modified by the transaction. -/// - `n_storage_changes`: The number of storage changes made by the transaction. -/// - `n_deployments`: The number of contracts deployed by the transaction. -/// -/// # Returns: -/// -/// The on-chain data segment length -pub const fn get_onchain_data_segment_length( - n_modified_contracts: usize, - n_storage_changes: usize, - n_deployments: usize, -) -> usize { - n_modified_contracts * 2 + n_storage_changes * 2 + n_deployments * DEPLOYMENT_INFO_SIZE +pub const fn get_onchain_data_segment_length(state_changes: &StateChangesCount) -> usize { + // For each newly modified contract: + // contract address (1 word). + // + 1 word with the following info: A flag indicating whether the class hash was updated, the + // number of entry updates, and the new nonce. + state_changes.n_modified_contracts * 2 + // For each class updated (through a deploy or a class replacement). + + state_changes.n_class_hash_updates * CLASS_UPDATE_SIZE + // For each modified storage cell: key, new value. + + state_changes.n_storage_updates * 2 + // For each compiled class updated (through declare): class_hash, compiled_class_hash + + state_changes.n_compiled_class_hash_updates * 2 } /// Calculates the cost of ConsumedMessageToL2 event emissions caused by an L1 handler with the given @@ -261,8 +255,17 @@ mod test { let message2 = L2toL1MessageInfo::new(ord_ev2, Address(1235.into())); assert_eq!( - calculate_tx_gas_usage(vec![message1, message2], 2, 2, Some(2), 1), - 77051 + calculate_tx_gas_usage( + vec![message1, message2], + &StateChangesCount { + n_storage_updates: 2, + n_class_hash_updates: 1, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 2 + }, + Some(2) + ), + 76439 ) } } diff --git a/src/execution/mod.rs b/src/execution/mod.rs index 9fed18a67..5c9774517 100644 --- a/src/execution/mod.rs +++ b/src/execution/mod.rs @@ -43,7 +43,7 @@ pub struct CallInfo { pub entry_point_type: Option, pub calldata: Vec, pub retdata: Vec, - pub execution_resources: ExecutionResources, + pub execution_resources: Option, pub events: Vec, pub l2_to_l1_messages: Vec, pub storage_read_values: Vec, @@ -73,11 +73,11 @@ impl CallInfo { entry_point_type, calldata: Vec::new(), retdata: Vec::new(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 0, builtin_instance_counter: HashMap::new(), n_memory_holes: 0, - }, + }), events: Vec::new(), l2_to_l1_messages: Vec::new(), storage_read_values: Vec::new(), @@ -238,11 +238,11 @@ impl Default for CallInfo { l2_to_l1_messages: Vec::new(), accessed_storage_keys: HashSet::new(), calldata: Vec::new(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 0, n_memory_holes: 0, builtin_instance_counter: HashMap::new(), - }, + }), events: Vec::new(), gas_consumed: 0, failure_flag: false, @@ -291,7 +291,7 @@ impl<'de> Deserialize<'de> for CallInfo { } Ok(CallInfo { - execution_resources, + execution_resources: Some(execution_resources), retdata, calldata, internal_calls, @@ -370,6 +370,7 @@ pub struct TransactionExecutionContext { pub(crate) nonce: Felt252, pub(crate) n_sent_messages: usize, pub(crate) _n_steps: u64, + // pub(crate) use_cairo_native: bool, } impl TransactionExecutionContext { diff --git a/src/lib.rs b/src/lib.rs index b14dfc402..205b218a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -436,9 +436,10 @@ mod test { let block_context = BlockContext::default(); let Transaction::InvokeFunction(simul_invoke) = - invoke.create_for_simulation(true, false, false, false, false) else { - unreachable!() - }; + invoke.create_for_simulation(true, false, false, false, false) + else { + unreachable!() + }; let call_info = simul_invoke .run_validate_entrypoint( @@ -711,7 +712,7 @@ mod test { simulate_transaction( &[&internal_deploy], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -752,7 +753,7 @@ mod test { simulate_transaction( &[&declare_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -820,7 +821,7 @@ mod test { simulate_transaction( &[&invoke_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -867,7 +868,7 @@ mod test { simulate_transaction( &[&deploy_account_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -896,7 +897,7 @@ mod test { nonce: 0.into(), hash_value: 0.into(), compiled_class_hash: TEST_FIB_COMPILED_CONTRACT_CLASS_HASH.clone(), - sierra_contract_class, + sierra_contract_class: Some(sierra_contract_class), sierra_class_hash, casm_class: Default::default(), skip_execute: false, @@ -912,7 +913,7 @@ mod test { simulate_transaction( &[&declare_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -981,7 +982,7 @@ mod test { simulate_transaction( &[&l1_handler_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), &block_context, 100_000_000, @@ -1042,7 +1043,7 @@ mod test { simulate_transaction( &[&deploy, &invoke_tx], - state.clone(), + state.clone_for_testing(), state.contract_class_cache().clone(), block_context, 100_000_000, @@ -1056,7 +1057,7 @@ mod test { assert_eq!( estimate_fee(&[deploy, invoke_tx], state, block_context,).unwrap(), - [(0, 2448), (0, 2448)] + [(0, 1836), (0, 2448)] ); } @@ -1081,4 +1082,119 @@ mod test { ) ); } + + #[test] + fn test_simulate_declare_v1_compare_fees() { + // accounts contract class must be stored before running declaration of fibonacci + let contract_class = ContractClass::from_path("starknet_programs/Account.json").unwrap(); + + // Instantiate CachedState + let contract_class_cache = PermanentContractClassCache::default(); + + // ------------ contract data -------------------- + let hash = compute_deprecated_class_hash(&contract_class).unwrap(); + let class_hash = hash.to_be_bytes(); + + contract_class_cache.set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); + + // store sender_address + let sender_address = Address(1.into()); + // this is not conceptually correct as the sender address would be an + // Account contract (not the contract that we are currently declaring) + // but for testing reasons its ok + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(sender_address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(sender_address.clone(), Felt252::new(1)); + + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + // Insert pubkey storage var to pass validation + let storage_entry = &( + sender_address, + felt_str!( + "1672321442399497129215646424919402195095307045612040218489019266998007191460" + ) + .to_be_bytes(), + ); + state.set_storage_at( + storage_entry, + felt_str!( + "1735102664668487605176656616876767369909409133946409161569774794110049207117" + ), + ); + + //* --------------------------------------- + //* Test declare with previous data + //* --------------------------------------- + + let fib_contract_class = + ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); + + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + // Signature & tx hash values are hand-picked for account validations to pass + let mut declare = Declare::new( + fib_contract_class, + chain_id, + Address(Felt252::one()), + 60000, + 1.into(), + vec![ + felt_str!( + "3086480810278599376317923499561306189851900463386393948998357832163236918254" + ), + felt_str!( + "598673427589502599949712887611119751108407514580626464031881322743364689811" + ), + ], + Felt252::one(), + ) + .unwrap(); + declare.hash_value = felt_str!("2718"); + + let mut block_context = BlockContext::default(); + block_context.starknet_os_config_mut().gas_price = 12; + + let declare_tx = Transaction::Declare(declare); + + let without_validate_fee = simulate_transaction( + &[&declare_tx], + state.clone_for_testing(), + state.clone_for_testing().contract_class_cache().clone(), + &block_context, + 100_000_000, + true, + false, + true, + false, + false, + ) + .unwrap()[0] + .actual_fee; + + let with_validate_fee = simulate_transaction( + &[&declare_tx], + state.clone_for_testing(), + state.contract_class_cache().clone(), + &block_context, + 100_000_000, + false, + false, + true, + false, + false, + ) + .unwrap()[0] + .actual_fee; + + assert!(with_validate_fee > without_validate_fee) + } } diff --git a/src/services/api/contract_classes/compiled_class.rs b/src/services/api/contract_classes/compiled_class.rs index 035a96fbb..26b56281f 100644 --- a/src/services/api/contract_classes/compiled_class.rs +++ b/src/services/api/contract_classes/compiled_class.rs @@ -24,6 +24,7 @@ use starknet::core::types::ContractClass::{Legacy, Sierra}; pub enum CompiledClass { Deprecated(Arc), Casm(Arc), + Sierra(Arc), } impl TryInto for CompiledClass { @@ -129,7 +130,7 @@ impl From for CompiledClass { ) }) .collect::>(); - entry_points_by_type.insert(EntryPointType::Constructor, l1_handler_entries); + entry_points_by_type.insert(EntryPointType::L1Handler, l1_handler_entries); let v = serde_json::to_value(&_deprecated_contract_class.abi).unwrap(); let abi: Option = serde_json::from_value(v).unwrap(); diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index c453e1a96..1f8394bbb 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -1,6 +1,6 @@ use super::{ contract_class_cache::ContractClassCache, - state_api::{State, StateReader}, + state_api::{State, StateChangesCount, StateReader}, state_cache::{StateCache, StorageEntry}, }; use crate::{ @@ -12,19 +12,19 @@ use crate::{ to_cache_state_storage_mapping, Address, ClassHash, }, }; +use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; use getset::{Getters, MutGetters}; use num_traits::Zero; use std::{ - cell::RefCell, collections::{HashMap, HashSet}, - sync::Arc, + sync::{Arc, RwLock}, }; pub const UNINITIALIZED_CLASS_HASH: &ClassHash = &[0u8; 32]; /// Represents a cached state of contract classes with optional caches. -#[derive(Default, Clone, Debug, Getters, MutGetters)] +#[derive(Default, Debug, Getters, MutGetters)] pub struct CachedState { pub state_reader: Arc, #[getset(get = "pub", get_mut = "pub")] @@ -32,7 +32,7 @@ pub struct CachedState { #[getset(get = "pub", get_mut = "pub")] pub(crate) contract_class_cache: Arc, - pub(crate) contract_class_cache_private: RefCell>, + pub(crate) contract_class_cache_private: RwLock>, #[cfg(feature = "metrics")] cache_hits: usize, @@ -73,7 +73,7 @@ impl CachedState { cache: StateCache::default(), state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RefCell::new(HashMap::new()), + contract_class_cache_private: RwLock::new(HashMap::new()), #[cfg(feature = "metrics")] cache_hits: 0, @@ -92,7 +92,7 @@ impl CachedState { cache, state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RefCell::new(HashMap::new()), + contract_class_cache_private: RwLock::new(HashMap::new()), #[cfg(feature = "metrics")] cache_hits: 0, @@ -101,28 +101,51 @@ impl CachedState { } } + /// Clones a CachedState for testing purposes. + pub fn clone_for_testing(&self) -> Self { + Self { + state_reader: self.state_reader.clone(), + cache: self.cache.clone(), + contract_class_cache: self.contract_class_cache.clone(), + contract_class_cache_private: RwLock::new( + self.contract_class_cache_private.read().unwrap().clone(), + ), + #[cfg(feature = "metrics")] + cache_hits: self.cache_hits, + #[cfg(feature = "metrics")] + cache_misses: self.cache_misses, + } + } + pub fn drain_private_contract_class_cache( &self, - ) -> impl Iterator { - self.contract_class_cache_private.take().into_iter() + ) -> Result, StateError> { + Ok(self + .contract_class_cache_private + .read() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .clone() + .into_iter()) } /// Creates a copy of this state with an empty cache for saving changes and applying them /// later. - pub fn create_transactional(&self) -> TransactionalCachedState { - let state_reader = Arc::new(TransactionalCachedStateReader::new(self)); - CachedState { - state_reader, + pub fn create_transactional(&self) -> Result, StateError> { + Ok(CachedState { + state_reader: self.state_reader.clone(), cache: self.cache.clone(), contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RefCell::new( - self.contract_class_cache_private.borrow().clone(), + contract_class_cache_private: RwLock::new( + self.contract_class_cache_private + .read() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .clone(), ), #[cfg(feature = "metrics")] cache_hits: 0, #[cfg(feature = "metrics")] cache_misses: 0, - } + }) } } @@ -177,7 +200,10 @@ impl StateReader for CachedState { } // I: FETCHING FROM CACHE - let mut private_cache = self.contract_class_cache_private.borrow_mut(); + let mut private_cache = self + .contract_class_cache_private + .write() + .map_err(|_| StateError::FailedToReadContractClassCache)?; if let Some(compiled_class) = private_cache.get(class_hash) { return Ok(compiled_class.clone()); } else if let Some(compiled_class) = @@ -221,6 +247,7 @@ impl State for CachedState { // have a mutable reference to the `RefCell` available. self.contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, contract_class.clone()); Ok(()) @@ -294,7 +321,7 @@ impl State for CachedState { let compiled_class_hash = compiled_class_hash.to_be_bytes(); self.cache - .class_hash_to_compiled_class_hash + .compiled_class_hash_writes .insert(class_hash, compiled_class_hash); Ok(()) } @@ -311,10 +338,10 @@ impl State for CachedState { Ok(()) } - fn count_actual_storage_changes( + fn count_actual_state_changes( &mut self, fee_token_and_sender_address: Option<(&Address, &Address)>, - ) -> Result<(usize, usize), StateError> { + ) -> Result { self.update_initial_values_of_write_only_accesses()?; let mut storage_updates = subtract_mappings( @@ -324,9 +351,16 @@ impl State for CachedState { let storage_unique_updates = storage_updates.keys().map(|k| k.0.clone()); - let class_hash_updates = subtract_mappings_keys( + let class_hash_updates: Vec<&Address> = subtract_mappings_keys( &self.cache.class_hash_writes, &self.cache.class_hash_initial_values, + ) + .collect(); + let n_class_hash_updates = class_hash_updates.len(); + + let compiled_class_hash_updates = subtract_mappings_keys( + &self.cache.compiled_class_hash_writes, + &self.cache.compiled_class_hash_initial_values, ); let nonce_updates = @@ -334,7 +368,7 @@ impl State for CachedState { let mut modified_contracts: HashSet
= HashSet::new(); modified_contracts.extend(storage_unique_updates); - modified_contracts.extend(class_hash_updates.cloned()); + modified_contracts.extend(class_hash_updates.into_iter().cloned()); modified_contracts.extend(nonce_updates.cloned()); // Add fee transfer storage update before actually charging it, as it needs to be included in the @@ -348,7 +382,12 @@ impl State for CachedState { modified_contracts.remove(fee_token_address); } - Ok((modified_contracts.len(), storage_updates.len())) + Ok(StateChangesCount { + n_storage_updates: storage_updates.len(), + n_class_hash_updates, + n_compiled_class_hash_updates: compiled_class_hash_updates.count(), + n_modified_contracts: modified_contracts.len(), + }) } /// Returns the class hash for a given contract address. @@ -446,6 +485,7 @@ impl State for CachedState { if let Some(compiled_class) = self .contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .get(class_hash) .cloned() { @@ -457,6 +497,7 @@ impl State for CachedState { self.add_hit(); self.contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, compiled_class.clone()); return Ok(compiled_class); } @@ -465,14 +506,14 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when - // we have a mutable reference to the `RefCell` available. - if let Some(casm_class) = self + let write_guard = self .contract_class_cache_private .get_mut() - .get(compiled_class_hash) - .cloned() - { + .map_err(|_| StateError::FailedToReadContractClassCache)?; + + // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when + // we have a mutable reference to the `RefCell` available. + if let Some(casm_class) = write_guard.get(compiled_class_hash).cloned() { self.add_hit(); return Ok(casm_class); } else if let Some(casm_class) = self @@ -482,11 +523,21 @@ impl State for CachedState { self.add_hit(); self.contract_class_cache_private .get_mut() + .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, casm_class.clone()); return Ok(casm_class); } } + // if let Some(sierra_compiled_class) = self + // .sierra_programs + // .as_ref() + // .and_then(|x| x.get(class_hash)) + // { + // return Ok(CompiledClass::Sierra(Arc::new( + // sierra_compiled_class.clone(), + // ))); + // } // II: FETCHING FROM STATE_READER let contract = self.state_reader.get_contract_class(class_hash)?; match contract { @@ -501,137 +552,34 @@ impl State for CachedState { CompiledClass::Deprecated(ref contract) => { self.set_contract_class(class_hash, &CompiledClass::Deprecated(contract.clone()))? } + CompiledClass::Sierra(ref sierra_compiled_class) => self.set_contract_class( + class_hash, + &CompiledClass::Sierra(sierra_compiled_class.clone()), + )?, } Ok(contract) } -} -/// A CachedState which has access to another, "parent" state, used for executing transactions -/// without commiting changes to the parent. -pub type TransactionalCachedState<'a, T, C> = - CachedState, C>; - -/// State reader used for transactional states which allows to check the parent state's cache and -/// state reader if a transactional cache miss happens. -/// -/// In practice this will act as a way to access the parent state's cache and other fields, -/// without referencing the whole parent state, so there's no need to adapt state-modifying -/// functions in the case that a transactional state is needed. -#[derive(Debug, MutGetters, Getters, PartialEq, Clone)] -pub struct TransactionalCachedStateReader<'a, T: StateReader, C: ContractClassCache> { - /// The parent state's state_reader - #[get(get = "pub")] - pub(crate) state_reader: Arc, - /// The parent state's cache - #[get(get = "pub")] - pub(crate) cache: &'a StateCache, - - /// The parent state's contract_classes - #[get(get = "pub")] - pub(crate) contract_class_cache: Arc, - pub(crate) contract_class_cache_private: &'a RefCell>, -} - -impl<'a, T: StateReader, C: ContractClassCache> TransactionalCachedStateReader<'a, T, C> { - fn new(state: &'a CachedState) -> Self { - Self { - state_reader: state.state_reader.clone(), - cache: &state.cache, - contract_class_cache: state.contract_class_cache.clone(), - contract_class_cache_private: &state.contract_class_cache_private, - } - } -} - -impl<'a, T: StateReader, C: ContractClassCache> StateReader - for TransactionalCachedStateReader<'a, T, C> -{ - /// Returns the class hash for a given contract address. - /// Returns zero as default value if missing - fn get_class_hash_at(&self, contract_address: &Address) -> Result { - self.cache - .get_class_hash(contract_address) - .map(|a| Ok(*a)) - .unwrap_or_else(|| self.state_reader.get_class_hash_at(contract_address)) - } - - /// Returns the nonce for a given contract address. - fn get_nonce_at(&self, contract_address: &Address) -> Result { - if self.cache.get_nonce(contract_address).is_none() { - return self.state_reader.get_nonce_at(contract_address); - } - self.cache - .get_nonce(contract_address) - .ok_or_else(|| StateError::NoneNonce(contract_address.clone())) - .cloned() - } - - /// Returns storage data for a given storage entry. - /// Returns zero as default value if missing - fn get_storage_at(&self, storage_entry: &StorageEntry) -> Result { - self.cache - .get_storage(storage_entry) - .map(|v| Ok(v.clone())) - .unwrap_or_else(|| self.state_reader.get_storage_at(storage_entry)) - } + fn set_sierra_program( + &mut self, + compiled_class_hash: &Felt252, + _sierra_program: Vec, + ) -> Result<(), StateError> { + let _compiled_class_hash = compiled_class_hash.to_be_bytes(); - // TODO: check if that the proper way to store it (converting hash to address) - /// Returned the compiled class hash for a given class hash. - fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Result { - if self - .cache - .class_hash_to_compiled_class_hash - .get(class_hash) - .is_none() - { - return self.state_reader.get_compiled_class_hash(class_hash); - } - self.cache - .class_hash_to_compiled_class_hash - .get(class_hash) - .ok_or_else(|| StateError::NoneCompiledClass(*class_hash)) - .cloned() + // TODO implement + // self.sierra_programs + // .as_mut() + // .ok_or(StateError::MissingSierraProgramsCache)? + // .insert(compiled_class_hash, sierra_program); + Ok(()) } - /// Returns the contract class for a given class hash. - fn get_contract_class(&self, class_hash: &ClassHash) -> Result { - // This method can receive both compiled_class_hash & class_hash and return both casm and deprecated contract classes - //, which can be on the cache or on the state_reader, different cases will be described below: - if class_hash == UNINITIALIZED_CLASS_HASH { - return Err(StateError::UninitiaizedClassHash); - } - - // I: FETCHING FROM CACHE - let mut private_cache = self.contract_class_cache_private.borrow_mut(); - if let Some(compiled_class) = private_cache.get(class_hash) { - return Ok(compiled_class.clone()); - } else if let Some(compiled_class) = - self.contract_class_cache().get_contract_class(*class_hash) - { - private_cache.insert(*class_hash, compiled_class.clone()); - return Ok(compiled_class); - } - - // I: CASM CONTRACT CLASS : CLASS_HASH - if let Some(compiled_class_hash) = - self.cache.class_hash_to_compiled_class_hash.get(class_hash) - { - if let Some(casm_class) = private_cache.get(compiled_class_hash) { - return Ok(casm_class.clone()); - } else if let Some(casm_class) = self - .contract_class_cache() - .get_contract_class(*compiled_class_hash) - { - private_cache.insert(*class_hash, casm_class.clone()); - return Ok(casm_class); - } - } - - // II: FETCHING FROM STATE_READER - let contract_class = self.state_reader.get_contract_class(class_hash)?; - private_cache.insert(*class_hash, contract_class.clone()); - - Ok(contract_class) + fn get_sierra_program( + &mut self, + _class_hash: &ClassHash, + ) -> Result, StateError> { + todo!() } } @@ -979,7 +927,7 @@ mod tests { /// This test calculate the number of actual storage changes. #[test] - fn count_actual_storage_changes_test() { + fn count_actual_state_changes_test() { let state_reader = InMemoryStateReader::default(); let mut cached_state = CachedState::new( Arc::new(state_reader), @@ -1003,14 +951,15 @@ mod tests { let fee_token_address = Address(123.into()); let sender_address = Address(321.into()); - let expected_changes = { - let n_storage_updates = 3 + 1; // + 1 fee transfer balance update - let n_modified_contracts = 2; - - (n_modified_contracts, n_storage_updates) + let expected_changes = StateChangesCount { + n_storage_updates: 3 + 1, // + 1 fee transfer balance update, + n_class_hash_updates: 0, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 2, }; + let changes = cached_state - .count_actual_storage_changes(Some((&fee_token_address, &sender_address))) + .count_actual_state_changes(Some((&fee_token_address, &sender_address))) .unwrap(); assert_eq!(changes, expected_changes); diff --git a/src/state/mod.rs b/src/state/mod.rs index 0c15b6aad..ef6efc242 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -3,10 +3,10 @@ use self::{ }; use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::compiled_class::CompiledClass, transaction::error::TransactionError, utils::{ - get_keys, to_cache_state_storage_mapping, to_state_diff_storage_mapping, Address, ClassHash, + get_keys, to_cache_state_storage_mapping, to_state_diff_storage_mapping, Address, + ClassHash, CompiledClassHash, }, }; use cairo_vm::{felt::Felt252, vm::runners::cairo_runner::ExecutionResources}; @@ -106,7 +106,7 @@ impl ExecutionResourcesManager { pub struct StateDiff { pub(crate) address_to_class_hash: HashMap, pub(crate) address_to_nonce: HashMap, - pub(crate) class_hash_to_compiled_class: HashMap, + pub(crate) class_hash_to_compiled_class: HashMap, pub(crate) storage_updates: HashMap>, } @@ -114,7 +114,7 @@ impl StateDiff { pub const fn new( address_to_class_hash: HashMap, address_to_nonce: HashMap, - class_hash_to_compiled_class: HashMap, + class_hash_to_compiled_class: HashMap, storage_updates: HashMap>, ) -> Self { StateDiff { @@ -133,7 +133,7 @@ impl StateDiff { let state_cache = cached_state.cache().to_owned(); let substracted_maps = state_cache.storage_writes; - let storage_updates = to_state_diff_storage_mapping(substracted_maps); + let storage_updates = to_state_diff_storage_mapping(&substracted_maps); let address_to_nonce = state_cache.nonce_writes; let class_hash_to_compiled_class = state_cache.compiled_class_hash_writes; @@ -330,7 +330,7 @@ mod test { Arc::new(PermanentContractClassCache::default()), ); - let diff = StateDiff::from_cached_state(cached_state_original.clone()).unwrap(); + let diff = StateDiff::from_cached_state(cached_state_original.clone_for_testing()).unwrap(); let cached_state = diff .to_cached_state::<_, PermanentContractClassCache>( diff --git a/src/state/state_api.rs b/src/state/state_api.rs index ff468671a..4abe12354 100644 --- a/src/state/state_api.rs +++ b/src/state/state_api.rs @@ -5,6 +5,7 @@ use crate::{ state::StateDiff, utils::{Address, ClassHash, CompiledClassHash}, }; +use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; pub trait StateReader { @@ -25,6 +26,14 @@ pub trait StateReader { ) -> Result; } +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct StateChangesCount { + pub n_storage_updates: usize, + pub n_class_hash_updates: usize, + pub n_compiled_class_hash_updates: usize, + pub n_modified_contracts: usize, +} + pub trait State { fn set_contract_class( &mut self, @@ -53,13 +62,20 @@ pub trait State { class_hash: &Felt252, compiled_class_hash: &Felt252, ) -> Result<(), StateError>; + + fn set_sierra_program( + &mut self, + compiled_class_hash: &Felt252, + sierra_program: Vec, + ) -> Result<(), StateError>; + fn apply_state_update(&mut self, sate_updates: &StateDiff) -> Result<(), StateError>; - /// Counts the amount of modified contracts and the updates to the storage - fn count_actual_storage_changes( + /// Counts the amount of state changes + fn count_actual_state_changes( &mut self, fee_token_and_sender_address: Option<(&Address, &Address)>, - ) -> Result<(usize, usize), StateError>; + ) -> Result; /// Returns the class hash of the contract class at the given address. /// Returns zero by default if the value is not present @@ -75,4 +91,9 @@ pub trait State { fn get_compiled_class_hash(&mut self, class_hash: &ClassHash) -> Result; fn get_contract_class(&mut self, class_hash: &ClassHash) -> Result; + + fn get_sierra_program( + &mut self, + class_hash: &ClassHash, + ) -> Result, StateError>; } diff --git a/src/state/state_cache.rs b/src/state/state_cache.rs index 6238c258d..23a77400c 100644 --- a/src/state/state_cache.rs +++ b/src/state/state_cache.rs @@ -1,6 +1,5 @@ use crate::{ core::errors::state_errors::StateError, - services::api::contract_classes::compiled_class::CompiledClass, utils::{Address, ClassHash, CompiledClassHash}, }; use cairo_vm::felt::Felt252; @@ -18,7 +17,7 @@ pub struct StateCache { #[get_mut = "pub"] pub(crate) class_hash_initial_values: HashMap, #[get_mut = "pub"] - pub(crate) compiled_class_hash_initial_values: HashMap, + pub(crate) compiled_class_hash_initial_values: HashMap, #[getset(get = "pub", get_mut = "pub")] pub(crate) nonce_initial_values: HashMap, #[getset(get = "pub", get_mut = "pub")] @@ -28,7 +27,7 @@ pub struct StateCache { #[get_mut = "pub"] pub(crate) class_hash_writes: HashMap, #[get_mut = "pub"] - pub(crate) compiled_class_hash_writes: HashMap, + pub(crate) compiled_class_hash_writes: HashMap, #[get_mut = "pub"] pub(crate) nonce_writes: HashMap, #[getset(get = "pub", get_mut = "pub")] @@ -43,11 +42,11 @@ impl StateCache { /// Create a new StateCache with given initial and written values for testing pub const fn new( class_hash_initial_values: HashMap, - compiled_class_hash_initial_values: HashMap, + compiled_class_hash_initial_values: HashMap, nonce_initial_values: HashMap, storage_initial_values: HashMap, class_hash_writes: HashMap, - compiled_class_hash_writes: HashMap, + compiled_class_hash_writes: HashMap, nonce_writes: HashMap, storage_writes: HashMap, class_hash_to_compiled_class_hash: HashMap, @@ -84,11 +83,11 @@ impl StateCache { #[allow(clippy::too_many_arguments)] pub const fn new_for_testing( class_hash_initial_values: HashMap, - compiled_class_hash_initial_values: HashMap, + compiled_class_hash_initial_values: HashMap, nonce_initial_values: HashMap, storage_initial_values: HashMap, class_hash_writes: HashMap, - compiled_class_hash_writes: HashMap, + compiled_class_hash_writes: HashMap, nonce_writes: HashMap, storage_writes: HashMap<(Address, [u8; 32]), Felt252>, class_hash_to_compiled_class_hash: HashMap, @@ -116,7 +115,10 @@ impl StateCache { /// Get the compiled hash for a given class hash #[allow(dead_code)] - pub(crate) fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Option<&CompiledClass> { + pub(crate) fn get_compiled_class_hash( + &self, + class_hash: &ClassHash, + ) -> Option<&CompiledClassHash> { if self.compiled_class_hash_writes.contains_key(class_hash) { return self.compiled_class_hash_writes.get(class_hash); } @@ -143,7 +145,7 @@ impl StateCache { pub(crate) fn update_writes( &mut self, address_to_class_hash: &HashMap, - class_hash_to_compiled_class_hash: &HashMap, + class_hash_to_compiled_class_hash: &HashMap, address_to_nonce: &HashMap, storage_updates: &HashMap, ) { @@ -158,7 +160,7 @@ impl StateCache { pub fn set_initial_values( &mut self, address_to_class_hash: &HashMap, - class_hash_to_compiled_class: &HashMap, + class_hash_to_compiled_class: &HashMap, address_to_nonce: &HashMap, storage_updates: &HashMap, ) -> Result<(), StateError> { @@ -201,8 +203,7 @@ impl StateCache { } for (k, v) in self.compiled_class_hash_writes.iter() { - self.compiled_class_hash_initial_values - .insert(*k, v.clone()); + self.compiled_class_hash_initial_values.insert(*k, *v); } for (k, v) in self.storage_writes.iter() { @@ -219,9 +220,11 @@ impl StateCache { /// Unit tests for StateCache #[cfg(test)] mod tests { - use std::sync::Arc; - use crate::services::api::contract_classes::deprecated_contract_class::ContractClass; + use crate::{ + core::contract_address::compute_deprecated_class_hash, + services::api::contract_classes::deprecated_contract_class::ContractClass, + }; use super::*; @@ -232,7 +235,9 @@ mod tests { let contract_class = ContractClass::from_path("starknet_programs/raw_contract_classes/class_with_abi.json") .unwrap(); - let compiled_class = CompiledClass::Deprecated(Arc::new(contract_class)); + let compiled_class = compute_deprecated_class_hash(&contract_class) + .unwrap() + .to_be_bytes(); let class_hash_to_compiled_class_hash = HashMap::from([([8; 32], compiled_class)]); let address_to_nonce = HashMap::from([(Address(9.into()), 12.into())]); let storage_updates = HashMap::from([((Address(4.into()), [1; 32]), 18.into())]); diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index 5deb7b2ee..42925bf16 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -58,9 +58,10 @@ use crate::services::api::contract_classes::deprecated_contract_class::EntryPoin use crate::state::contract_class_cache::ContractClassCache; use num_traits::{One, ToPrimitive, Zero}; -const STEP: u128 = 100; -const SYSCALL_BASE: u128 = 100 * STEP; -const KECCAK_ROUND_COST: u128 = 180000; +pub(crate) const STEP: u128 = 100; +pub(crate) const SYSCALL_BASE: u128 = 100 * STEP; +pub(crate) const KECCAK_ROUND_COST: u128 = 180000; + lazy_static! { /// Felt->syscall map that was extracted from new_syscalls.json (Cairo 1.0 syscalls) static ref SELECTOR_TO_SYSCALL: HashMap = { @@ -92,7 +93,7 @@ lazy_static! { // Taken from starkware/starknet/constants.py in cairo-lang // See further documentation on cairo_programs/constants.cairo /// Maps syscall name to gas costs - static ref SYSCALL_GAS_COST: HashMap<&'static str, u128> = { + pub(crate) static ref SYSCALL_GAS_COST: HashMap<&'static str, u128> = { let mut map = HashMap::new(); map.insert("initial", 100_000_000 * STEP); @@ -134,6 +135,7 @@ pub struct BusinessLogicSyscallHandler<'a, S: StateReader, C: ContractClassCache pub(crate) support_reverted: bool, pub(crate) entry_point_selector: Felt252, pub(crate) selector_to_syscall: &'a HashMap, + pub(crate) execution_info_ptr: Option, } // TODO: execution entry point may no be a parameter field, but there is no way to generate a default for now @@ -172,6 +174,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, support_reverted, entry_point_selector, selector_to_syscall: &SELECTOR_TO_SYSCALL, + execution_info_ptr: None, } } @@ -229,6 +232,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, support_reverted: false, entry_point_selector, selector_to_syscall: &SELECTOR_TO_SYSCALL, + execution_info_ptr: None, } } @@ -312,6 +316,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } @@ -320,7 +325,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, contract_address: &Address, class_hash_bytes: ClassHash, constructor_calldata: Vec, - remainig_gas: u128, + remaining_gas: u128, ) -> Result { let compiled_class = if let Ok(compiled_class) = self .starknet_storage_state @@ -359,7 +364,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, EntryPointType::Constructor, Some(CallType::Call), None, - remainig_gas, + remaining_gas, ); let ExecutionResult { @@ -534,10 +539,10 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, /// them as accessed. pub(crate) fn validate_read_only_segments( &self, - runner: &mut VirtualMachine, + vm: &mut VirtualMachine, ) -> Result<(), TransactionError> { for (segment_ptr, segment_size) in self.read_only_segments.clone() { - let used_size = runner + let used_size = vm .get_segment_used_size(segment_ptr.segment_index as usize) .ok_or(TransactionError::InvalidSegmentSize)?; @@ -549,7 +554,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, if seg_size != used_size.into() { return Err(TransactionError::OutOfBound); } - runner.mark_address_range_as_accessed(segment_ptr, used_size)?; + vm.mark_address_range_as_accessed(segment_ptr, used_size)?; } Ok(()) } @@ -626,63 +631,69 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, }) } + // Returns the pointer to the segment with the execution info if it was already written. + // If it wasn't, it writes the execution info into memory and returns its start address. + fn get_or_allocate_execution_info( + &mut self, + vm: &mut VirtualMachine, + ) -> Result { + if let Some(ptr) = self.execution_info_ptr { + return Ok(ptr); + } + + // Allocate block_info + let block_info = &self.block_context.block_info; + let block_info_data = vec![ + MaybeRelocatable::from(Felt252::from(block_info.block_number)), + MaybeRelocatable::from(Felt252::from(block_info.block_timestamp)), + MaybeRelocatable::from(&block_info.sequencer_address.0), + ]; + let block_info_ptr = self.allocate_segment(vm, block_info_data)?; + + // Allocate signature + let signature: Vec = self + .tx_execution_context + .signature + .iter() + .map(MaybeRelocatable::from) + .collect(); + let signature_start_ptr = self.allocate_segment(vm, signature)?; + let signature_end_ptr = (signature_start_ptr + self.tx_execution_context.signature.len())?; + + // Allocate tx info + let tx_info = &self.tx_execution_context; + let tx_info_data = vec![ + MaybeRelocatable::from(&tx_info.version), + MaybeRelocatable::from(&tx_info.account_contract_address.0), + MaybeRelocatable::from(Felt252::from(tx_info.max_fee)), + signature_start_ptr.into(), + signature_end_ptr.into(), + MaybeRelocatable::from(&tx_info.transaction_hash), + MaybeRelocatable::from(&self.block_context.starknet_os_config.chain_id), + MaybeRelocatable::from(&tx_info.nonce), + ]; + let tx_info_ptr = self.allocate_segment(vm, tx_info_data)?; + + // Allocate execution_info + let execution_info = vec![ + block_info_ptr.into(), + tx_info_ptr.into(), + MaybeRelocatable::from(&self.caller_address.0), + MaybeRelocatable::from(&self.contract_address.0), + MaybeRelocatable::from(&self.entry_point_selector), + ]; + let execution_info_ptr = self.allocate_segment(vm, execution_info)?; + + self.execution_info_ptr = Some(execution_info_ptr); + Ok(execution_info_ptr) + } + fn get_execution_info( - &self, + &mut self, vm: &mut VirtualMachine, remaining_gas: u128, ) -> Result { - let tx_info = &self.tx_execution_context; - let block_info = &self.block_context.block_info; - - let mut res_segment = vm.add_memory_segment(); - - let signature_start = res_segment; - for s in tx_info.signature.iter() { - vm.insert_value(res_segment, s)?; - res_segment = (res_segment + 1)?; - } - let signature_end = res_segment; - - let tx_info_ptr = res_segment; - vm.insert_value::(res_segment, tx_info.version.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, tx_info.account_contract_address.0.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, tx_info.max_fee.into())?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, signature_start)?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, signature_end)?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, tx_info.transaction_hash.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::( - res_segment, - self.block_context.starknet_os_config.chain_id.clone(), - )?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, tx_info.nonce.clone())?; - res_segment = (res_segment + 1)?; - - let block_info_ptr = res_segment; - vm.insert_value::(res_segment, block_info.block_number.into())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, block_info.block_timestamp.into())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, block_info.sequencer_address.0.clone())?; - res_segment = (res_segment + 1)?; - - let exec_info_ptr = res_segment; - vm.insert_value(res_segment, block_info_ptr)?; - res_segment = (res_segment + 1)?; - vm.insert_value(res_segment, tx_info_ptr)?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, self.caller_address.0.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, self.contract_address.0.clone())?; - res_segment = (res_segment + 1)?; - vm.insert_value::(res_segment, self.entry_point_selector.clone())?; - + let exec_info_ptr = self.get_or_allocate_execution_info(vm)?; Ok(SyscallResponse { gas: remaining_gas, body: Some(ResponseBody::GetExecutionInfo { exec_info_ptr }), @@ -876,7 +887,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, fn send_message_to_l1( &mut self, - vm: &mut VirtualMachine, + vm: &VirtualMachine, request: SendMessageToL1Request, remaining_gas: u128, ) -> Result { diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 9f0b66e32..56817de19 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -193,6 +193,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } @@ -596,7 +597,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S pub(crate) fn storage_write( &mut self, - vm: &mut VirtualMachine, + vm: &VirtualMachine, syscall_ptr: Relocatable, ) -> Result<(), SyscallHandlerError> { let request = @@ -887,7 +888,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S pub(crate) fn replace_class( &mut self, - vm: &mut VirtualMachine, + vm: &VirtualMachine, syscall_ptr: Relocatable, ) -> Result<(), SyscallHandlerError> { let request = match self.read_and_validate_syscall_request("replace_class", vm, syscall_ptr) diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index eabf9bdfa..997f684df 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -1214,7 +1214,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index 065e31652..48a332316 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -4,6 +4,8 @@ pub mod deprecated_syscall_handler; pub mod deprecated_syscall_request; pub mod deprecated_syscall_response; pub mod hint_code; +#[cfg(feature = "cairo-native")] +pub mod native_syscall_handler; pub mod other_syscalls; pub mod syscall_handler; pub mod syscall_handler_errors; diff --git a/src/syscalls/native_syscall_handler.rs b/src/syscalls/native_syscall_handler.rs new file mode 100644 index 000000000..00386eaea --- /dev/null +++ b/src/syscalls/native_syscall_handler.rs @@ -0,0 +1,576 @@ +use crate::ContractClassCache; +use cairo_native::starknet::{ + BlockInfo, ExecutionInfo, StarkNetSyscallHandler, SyscallResult, TxInfo, U256, +}; +use cairo_vm::felt::Felt252; +use num_traits::Zero; + +use crate::definitions::constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR; +use crate::execution::CallResult; +use crate::hash_utils::calculate_contract_address; +use crate::services::api::contract_class_errors::ContractClassError; +use crate::services::api::contract_classes::compiled_class::CompiledClass; +use crate::state::state_api::State; +use crate::utils::felt_to_hash; +use crate::utils::ClassHash; +use crate::{ + core::errors::state_errors::StateError, + definitions::block_context::BlockContext, + execution::{ + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + CallInfo, CallType, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, + }, + state::{ + contract_storage_state::ContractStorageState, state_api::StateReader, + ExecutionResourcesManager, + }, + syscalls::business_logic_syscall_handler::{SYSCALL_BASE, SYSCALL_GAS_COST}, + utils::Address, + EntryPointType, +}; + +#[derive(Debug)] +pub struct NativeSyscallHandler<'a, S, C> +where + S: StateReader, + C: ContractClassCache, +{ + pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, + pub(crate) contract_address: Address, + pub(crate) caller_address: Address, + pub(crate) entry_point_selector: Felt252, + pub(crate) events: Vec, + pub(crate) l2_to_l1_messages: Vec, + pub(crate) tx_execution_context: TransactionExecutionContext, + pub(crate) block_context: BlockContext, + pub(crate) internal_calls: Vec, + pub(crate) resources_manager: ExecutionResourcesManager, +} + +impl<'a, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, S, C> { + /// Generic code that needs to be run on all syscalls. + fn handle_syscall_request(&mut self, gas: &mut u128, syscall_name: &str) -> SyscallResult<()> { + let required_gas = SYSCALL_GAS_COST + .get(syscall_name) + .map(|&x| x.saturating_sub(SYSCALL_BASE)) + .unwrap_or(0); + + if *gas < required_gas { + let out_of_gas_felt = Felt252::from_bytes_be("Out of gas".as_bytes()); + println!("out of gas!: {:?} < {:?}", *gas, required_gas); // TODO: remove once all other prints are removed + return Err(vec![out_of_gas_felt.clone()]); + } + + *gas = gas.saturating_sub(required_gas); + + self.resources_manager + .increment_syscall_counter(syscall_name, 1); + + Ok(()) + } +} + +impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler + for NativeSyscallHandler<'a, S, C> +{ + fn get_block_hash( + &mut self, + block_number: u64, + gas: &mut u128, + ) -> SyscallResult { + println!("Called `get_block_hash({block_number})` from MLIR."); + + self.handle_syscall_request(gas, "get_block_hash")?; + + Ok(Felt252::from_bytes_be(b"get_block_hash ok")) + } + + fn get_execution_info( + &mut self, + gas: &mut u128, + ) -> SyscallResult { + println!("Called `get_execution_info()` from MLIR."); + + self.handle_syscall_request(gas, "get_execution_info")?; + + Ok(ExecutionInfo { + block_info: BlockInfo { + block_number: self.block_context.block_info.block_number, + block_timestamp: self.block_context.block_info.block_timestamp, + sequencer_address: self.block_context.block_info.sequencer_address.0.clone(), + }, + tx_info: TxInfo { + version: self.tx_execution_context.version.clone(), + account_contract_address: self + .tx_execution_context + .account_contract_address + .0 + .clone(), + max_fee: self.tx_execution_context.max_fee, + signature: self.tx_execution_context.signature.clone(), + transaction_hash: self.tx_execution_context.transaction_hash.clone(), + chain_id: self.block_context.starknet_os_config.chain_id.clone(), + nonce: self.tx_execution_context.nonce.clone(), + }, + caller_address: self.caller_address.0.clone(), + contract_address: self.contract_address.0.clone(), + entry_point_selector: self.entry_point_selector.clone(), + }) + } + + fn deploy( + &mut self, + class_hash: cairo_vm::felt::Felt252, + contract_address_salt: cairo_vm::felt::Felt252, + calldata: &[cairo_vm::felt::Felt252], + deploy_from_zero: bool, + gas: &mut u128, + ) -> SyscallResult<(cairo_vm::felt::Felt252, Vec)> { + self.handle_syscall_request(gas, "deploy")?; + + let deployer_address = if deploy_from_zero { + Address::default() + } else { + self.contract_address.clone() + }; + + let contract_address = Address( + calculate_contract_address( + &contract_address_salt, + &class_hash, + calldata, + deployer_address, + ) + .map_err(|_| { + vec![Felt252::from_bytes_be( + b"FAILED_TO_CALCULATE_CONTRACT_ADDRESS", + )] + })?, + ); + // Initialize the contract. + let class_hash_bytes: ClassHash = felt_to_hash(&class_hash); + + self.starknet_storage_state + .state + .deploy_contract(contract_address.clone(), class_hash_bytes) + .map_err(|_| vec![Felt252::from_bytes_be(b"CONTRACT_ADDRESS_UNAVAILABLE")])?; + + let result = self + .execute_constructor_entry_point( + &contract_address, + class_hash_bytes, + calldata.to_vec(), + *gas, + ) + .map_err(|_| vec![Felt252::from_bytes_be(b"CONSTRUCTOR_ENTRYPOINT_FAILURE")])?; + + *gas = gas.saturating_sub(result.gas_consumed); + + Ok(( + contract_address.0, + result + .retdata + .iter() + .map(|mb| mb.get_int_ref().cloned().unwrap_or_default()) + .collect(), + )) + } + + fn replace_class( + &mut self, + class_hash: cairo_vm::felt::Felt252, + gas: &mut u128, + ) -> SyscallResult<()> { + println!("Called `replace_class({class_hash})` from MLIR."); + + self.handle_syscall_request(gas, "replace_class")?; + Ok(()) + } + + fn library_call( + &mut self, + class_hash: cairo_vm::felt::Felt252, + function_selector: cairo_vm::felt::Felt252, + calldata: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult> { + println!( + "Called `library_call({class_hash}, {function_selector}, {calldata:?})` from MLIR." + ); + + self.handle_syscall_request(gas, "library_call")?; + + Ok(calldata.iter().map(|x| x * &Felt252::new(3)).collect()) + } + + fn call_contract( + &mut self, + address: cairo_vm::felt::Felt252, + entrypoint_selector: cairo_vm::felt::Felt252, + calldata: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult> { + println!( + "Called `call_contract({address}, {entrypoint_selector}, {calldata:?})` from MLIR." + ); + + self.handle_syscall_request(gas, "call_contract")?; + + let address = Address(address); + let exec_entry_point = ExecutionEntryPoint::new( + address, + calldata.to_vec(), + entrypoint_selector, + self.caller_address.clone(), + EntryPointType::External, + Some(CallType::Call), + None, + *gas, + ); + + let ExecutionResult { call_info, .. } = exec_entry_point + .execute( + self.starknet_storage_state.state, + // TODO: This fields dont make much sense in the Cairo Native context, + // they are only dummy values for the `execute` method. + &self.block_context, + &mut self.resources_manager, + &mut self.tx_execution_context, + false, + self.block_context.invoke_tx_max_n_steps, + ) + .unwrap(); + + let call_info = call_info.unwrap(); + + *gas = gas.saturating_sub(call_info.gas_consumed); + + // update syscall handler information + self.starknet_storage_state + .read_values + .extend(call_info.storage_read_values.clone()); + self.starknet_storage_state + .accessed_keys + .extend(call_info.accessed_storage_keys.clone()); + + let retdata = call_info.retdata.clone(); + self.internal_calls.push(call_info); + + Ok(retdata) + } + + fn storage_read( + &mut self, + address_domain: u32, + address: cairo_vm::felt::Felt252, + gas: &mut u128, + ) -> SyscallResult { + println!("Called `storage_read({address_domain}, {address})` from MLIR."); + + self.handle_syscall_request(gas, "storage_read")?; + + let value = match self.starknet_storage_state.read(&address.to_be_bytes()) { + Ok(value) => Ok(value), + Err(_e @ StateError::Io(_)) => todo!(), + Err(_) => Ok(Felt252::zero()), + }; + + println!(" = {value:?}` from MLIR."); + + value + } + + fn storage_write( + &mut self, + address_domain: u32, + address: cairo_vm::felt::Felt252, + value: cairo_vm::felt::Felt252, + gas: &mut u128, + ) -> SyscallResult<()> { + println!("Called `storage_write({address_domain}, {address}, {value})` from MLIR."); + + self.handle_syscall_request(gas, "storage_write")?; + + self.starknet_storage_state + .write(&address.to_be_bytes(), value); + Ok(()) + } + + fn emit_event( + &mut self, + keys: &[cairo_vm::felt::Felt252], + data: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult<()> { + let order = self.tx_execution_context.n_emitted_events; + println!("Called `emit_event(KEYS: {keys:?}, DATA: {data:?})` from MLIR."); + + self.handle_syscall_request(gas, "emit_event")?; + + self.events + .push(OrderedEvent::new(order, keys.to_vec(), data.to_vec())); + self.tx_execution_context.n_emitted_events += 1; + Ok(()) + } + + fn send_message_to_l1( + &mut self, + to_address: cairo_vm::felt::Felt252, + payload: &[cairo_vm::felt::Felt252], + gas: &mut u128, + ) -> SyscallResult<()> { + println!("Called `send_message_to_l1({to_address}, {payload:?})` from MLIR."); + + self.handle_syscall_request(gas, "send_message_to_l1")?; + + let addr = Address(to_address); + self.l2_to_l1_messages.push(OrderedL2ToL1Message::new( + self.tx_execution_context.n_sent_messages, + addr, + payload.to_vec(), + )); + + // Update messages count. + self.tx_execution_context.n_sent_messages += 1; + + Ok(()) + } + + fn keccak( + &mut self, + input: &[u64], + gas: &mut u128, + ) -> SyscallResult { + println!("Called `keccak({input:?})` from MLIR."); + + self.handle_syscall_request(gas, "keccak")?; + + Ok(U256(Felt252::from(1234567890).to_le_bytes())) + } + + fn secp256k1_add( + &mut self, + _p0: cairo_native::starknet::Secp256k1Point, + _p1: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_get_point_from_x( + &self, + _x: cairo_native::starknet::U256, + _y_parity: bool, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_get_xy( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { + todo!() + } + + fn secp256k1_mul( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _m: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256k1_new( + &self, + _x: cairo_native::starknet::U256, + _y: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_add( + &self, + _p0: cairo_native::starknet::Secp256k1Point, + _p1: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_get_point_from_x( + &self, + _x: cairo_native::starknet::U256, + _y_parity: bool, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_get_xy( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _gas: &mut u128, + ) -> SyscallResult<(cairo_native::starknet::U256, cairo_native::starknet::U256)> { + todo!() + } + + fn secp256r1_mul( + &self, + _p: cairo_native::starknet::Secp256k1Point, + _m: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn secp256r1_new( + &mut self, + _x: cairo_native::starknet::U256, + _y: cairo_native::starknet::U256, + _gas: &mut u128, + ) -> SyscallResult> { + todo!() + } + + fn pop_log(&mut self) { + todo!() + } + + fn set_account_contract_address(&mut self, contract_address: cairo_vm::felt::Felt252) { + self.tx_execution_context.account_contract_address = Address(contract_address); + } + + fn set_block_number(&mut self, block_number: u64) { + self.block_context.block_info.block_number = block_number; + } + + fn set_block_timestamp(&mut self, block_timestamp: u64) { + self.block_context.block_info.block_timestamp = block_timestamp; + } + + fn set_caller_address(&mut self, address: cairo_vm::felt::Felt252) { + self.caller_address = Address(address); + } + + fn set_chain_id(&mut self, chain_id: cairo_vm::felt::Felt252) { + self.block_context.starknet_os_config.chain_id = chain_id; + } + + fn set_contract_address(&mut self, address: cairo_vm::felt::Felt252) { + self.contract_address = Address(address); + } + + fn set_max_fee(&mut self, max_fee: u128) { + self.tx_execution_context.max_fee = max_fee; + } + + fn set_nonce(&mut self, nonce: cairo_vm::felt::Felt252) { + self.tx_execution_context.nonce = nonce; + } + + fn set_sequencer_address(&mut self, _address: cairo_vm::felt::Felt252) { + todo!() + } + + fn set_signature(&mut self, signature: &[cairo_vm::felt::Felt252]) { + self.tx_execution_context.signature = signature.to_vec(); + } + + fn set_transaction_hash(&mut self, transaction_hash: cairo_vm::felt::Felt252) { + self.tx_execution_context.transaction_hash = transaction_hash; + } + + fn set_version(&mut self, version: cairo_vm::felt::Felt252) { + self.tx_execution_context.version = version; + } +} + +impl<'a, S, C> NativeSyscallHandler<'a, S, C> +where + S: StateReader, + C: ContractClassCache, +{ + fn execute_constructor_entry_point( + &mut self, + contract_address: &Address, + class_hash_bytes: ClassHash, + constructor_calldata: Vec, + remaining_gas: u128, + ) -> Result { + let compiled_class = if let Ok(compiled_class) = self + .starknet_storage_state + .state + .get_contract_class(&class_hash_bytes) + { + compiled_class + } else { + return Ok(CallResult { + gas_consumed: 0, + is_success: false, + retdata: vec![Felt252::from_bytes_be(b"CLASS_HASH_NOT_FOUND").into()], + }); + }; + + if self.constructor_entry_points_empty(compiled_class)? { + if !constructor_calldata.is_empty() { + return Err(StateError::ConstructorCalldataEmpty); + } + + let call_info = CallInfo::empty_constructor_call( + contract_address.clone(), + self.contract_address.clone(), + Some(class_hash_bytes), + ); + self.internal_calls.push(call_info.clone()); + + return Ok(call_info.result()); + } + + let call = ExecutionEntryPoint::new( + contract_address.clone(), + constructor_calldata, + CONSTRUCTOR_ENTRY_POINT_SELECTOR.clone(), + self.contract_address.clone(), + EntryPointType::Constructor, + Some(CallType::Call), + None, + remaining_gas, + ); + + let ExecutionResult { call_info, .. } = call + .execute( + self.starknet_storage_state.state, + &self.block_context, + &mut self.resources_manager, + &mut self.tx_execution_context, + false, + u64::MAX, + ) + .map_err(|_| StateError::ExecutionEntryPoint)?; + + let call_info = call_info.ok_or(StateError::CustomError("Execution error".to_string()))?; + + self.internal_calls.push(call_info.clone()); + + Ok(call_info.result()) + } + + fn constructor_entry_points_empty( + &self, + contract_class: CompiledClass, + ) -> Result { + match contract_class { + CompiledClass::Deprecated(class) => Ok(class + .entry_points_by_type + .get(&EntryPointType::Constructor) + .ok_or(ContractClassError::NoneEntryPointType)? + .is_empty()), + CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + } + } +} diff --git a/src/syscalls/syscall_handler.rs b/src/syscalls/syscall_handler.rs index b62fb9b64..679098a02 100644 --- a/src/syscalls/syscall_handler.rs +++ b/src/syscalls/syscall_handler.rs @@ -146,7 +146,7 @@ impl<'a, S: StateReader, C: ContractClassCache> HintProcessorPostRun // TODO: These four functions were copied from cairo-rs in // hint_processor/cairo-1-hint-processor/hint_processor_utils.rs as these functions are private. // They will became public soon and then we have to remove this ones and use the ones in cairo-rs instead -fn as_relocatable(vm: &mut VirtualMachine, value: &ResOperand) -> Result { +fn as_relocatable(vm: &VirtualMachine, value: &ResOperand) -> Result { let (base, offset) = extract_buffer(value)?; get_ptr(vm, base, &offset).map_err(HintError::from) } diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index 364628bcd..bf173065c 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -32,6 +32,8 @@ use crate::{ }; use cairo_vm::felt::Felt252; use num_traits::Zero; + +use std::fmt::Debug; use std::sync::Arc; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -146,6 +148,44 @@ impl Declare { Ok(internal_declare) } + #[allow(clippy::too_many_arguments)] + pub fn new_with_tx_and_class_hash( + contract_class: ContractClass, + sender_address: Address, + max_fee: u128, + version: Felt252, + signature: Vec, + nonce: Felt252, + hash_value: Felt252, + class_hash: ClassHash, + ) -> Result { + let validate_entry_point_selector = VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(); + + let internal_declare = Declare { + class_hash, + sender_address, + validate_entry_point_selector, + version, + max_fee, + signature, + nonce, + hash_value, + contract_class, + skip_execute: false, + skip_validate: false, + skip_fee_transfer: false, + }; + + verify_version( + &internal_declare.version, + internal_declare.max_fee, + &internal_declare.nonce, + &internal_declare.signature, + )?; + + Ok(internal_declare) + } + pub fn get_calldata(&self) -> Vec { let bytes = Felt252::from_bytes_be(&self.class_hash); Vec::from([bytes]) @@ -167,7 +207,7 @@ impl Declare { } else { self.run_validate_entrypoint(state, &mut resources_manager, block_context)? }; - let changes = state.count_actual_storage_changes(Some(( + let changes = state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.sender_address, )))?; @@ -266,6 +306,14 @@ impl Declare { /// Calculates actual fee used by the transaction using the execution /// info returned by apply(), then updates the transaction execution info with the data of the fee. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::Declare, + self.version = ?self.version, + self.class_hash = ?self.class_hash, + self.hash_value = ?self.hash_value, + self.sender_address = ?self.sender_address, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, @@ -295,7 +343,7 @@ impl Declare { Ok(tx_exec_info) } - pub(crate) fn create_for_simulation( + pub fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -426,10 +474,10 @@ mod tests { entry_point_type: Some(EntryPointType::External), calldata, class_hash: Some(expected_class_hash), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 12, ..Default::default() - }, + }), ..Default::default() }); @@ -888,4 +936,104 @@ mod tests { Err(TransactionError::FeeTransferError(_)) ); } + + #[test] + fn declare_v1_with_validation_fee_higher_than_no_validation() { + // accounts contract class must be stored before running declaration of fibonacci + let contract_class = ContractClass::from_path("starknet_programs/Account.json").unwrap(); + + // Instantiate CachedState + let contract_class_cache = PermanentContractClassCache::default(); + + // ------------ contract data -------------------- + let hash = compute_deprecated_class_hash(&contract_class).unwrap(); + let class_hash = hash.to_be_bytes(); + + contract_class_cache.set_contract_class( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); + + // store sender_address + let sender_address = Address(1.into()); + // this is not conceptually correct as the sender address would be an + // Account contract (not the contract that we are currently declaring) + // but for testing reasons its ok + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(sender_address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(sender_address.clone(), Felt252::new(1)); + + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + // Insert pubkey storage var to pass validation + let storage_entry = &( + sender_address, + felt_str!( + "1672321442399497129215646424919402195095307045612040218489019266998007191460" + ) + .to_be_bytes(), + ); + state.set_storage_at( + storage_entry, + felt_str!( + "1735102664668487605176656616876767369909409133946409161569774794110049207117" + ), + ); + + //* --------------------------------------- + //* Test declare with previous data + //* --------------------------------------- + + let fib_contract_class = + ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); + + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + // Signature & tx hash values are hand-picked for account validations to pass + let mut declare = Declare::new( + fib_contract_class, + chain_id, + Address(Felt252::one()), + 60000, + 1.into(), + vec![ + felt_str!( + "3086480810278599376317923499561306189851900463386393948998357832163236918254" + ), + felt_str!( + "598673427589502599949712887611119751108407514580626464031881322743364689811" + ), + ], + Felt252::one(), + ) + .unwrap(); + declare.skip_fee_transfer = true; + declare.hash_value = felt_str!("2718"); + + let simulate_declare = declare + .clone() + .create_for_simulation(true, false, true, false); + + // --------------------- + // Comparison + // --------------------- + let mut state_copy = state.clone_for_testing(); + let mut bock_context = BlockContext::default(); + bock_context.starknet_os_config.gas_price = 12; + assert!( + declare + .execute(&mut state, &bock_context) + .unwrap() + .actual_fee + > simulate_declare + .execute(&mut state_copy, &bock_context, 0) + .unwrap() + .actual_fee, + ); + } } diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index a342b9d25..cbcca05cb 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -28,6 +28,7 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; use cairo_vm::felt::Felt252; use num_traits::Zero; +use std::fmt::Debug; use std::sync::Arc; /// Represents a declare transaction in the starknet network. @@ -42,7 +43,7 @@ pub struct DeclareV2 { pub signature: Vec, pub nonce: Felt252, pub compiled_class_hash: Felt252, - pub sierra_contract_class: SierraContractClass, + pub sierra_contract_class: Option, pub sierra_class_hash: Felt252, pub hash_value: Felt252, pub casm_class: Option, @@ -89,7 +90,7 @@ impl DeclareV2 { )?; Self::new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class, + Some(sierra_contract_class.clone()), sierra_class_hash, casm_contract_class, compiled_class_hash, @@ -118,7 +119,7 @@ impl DeclareV2 { /// may not hold. #[allow(clippy::too_many_arguments)] pub fn new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class: &SierraContractClass, + sierra_contract_class: Option, sierra_class_hash: Felt252, casm_contract_class: Option, compiled_class_hash: Felt252, @@ -184,7 +185,7 @@ impl DeclareV2 { let sierra_class_hash = compute_sierra_class_hash(sierra_contract_class)?; Self::new_with_sierra_class_hash_and_tx_hash( - sierra_contract_class, + Some(sierra_contract_class.clone()), sierra_class_hash, casm_contract_class, compiled_class_hash, @@ -211,7 +212,7 @@ impl DeclareV2 { /// - nonce: The nonce of the contract. #[allow(clippy::too_many_arguments)] pub fn new_with_sierra_class_hash( - sierra_contract_class: &SierraContractClass, + sierra_contract_class: Option, sierra_class_hash: Felt252, casm_contract_class: Option, compiled_class_hash: Felt252, @@ -296,11 +297,21 @@ impl DeclareV2 { /// ## Parameter: /// - state: An state that implements the State and StateReader traits. /// - block_context: The block that contains the execution context + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::Declare, + self.version = ?self.version, + self.sierra_class_hash = ?self.sierra_class_hash, + self.compiled_class_hash = ?self.compiled_class_hash, + self.hash_value = ?self.hash_value, + self.sender_address = ?self.sender_address, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, block_context: &BlockContext, ) -> Result { + self.handle_nonce(state)?; verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; let initial_gas = INITIAL_GAS_COST; @@ -318,11 +329,13 @@ impl DeclareV2 { )?; (info, gas) }; + self.compile_and_store_casm_class(state)?; - let storage_changes = state.count_actual_storage_changes(Some(( + let storage_changes = state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.sender_address, )))?; + let actual_resources = calculate_tx_resources( resources_manager, &[execution_result.call_info.clone()], @@ -342,7 +355,6 @@ impl DeclareV2 { &mut tx_execution_context, self.skip_fee_transfer, )?; - self.compile_and_store_casm_class(state)?; let mut tx_exec_info = TransactionExecutionInfo::new_without_fee_info( execution_result.call_info, @@ -361,10 +373,13 @@ impl DeclareV2 { state: &mut S, ) -> Result<(), TransactionError> { let casm_class = match &self.casm_class { - None => { - CasmContractClass::from_contract_class(self.sierra_contract_class.clone(), true) - .map_err(|e| TransactionError::SierraCompileError(e.to_string()))? - } + None => CasmContractClass::from_contract_class( + self.sierra_contract_class + .clone() + .ok_or(TransactionError::DeclareV2NoSierraOrCasm)?, + true, + ) + .map_err(|e| TransactionError::SierraCompileError(e.to_string()))?, Some(casm_contract_class) => casm_contract_class.clone(), }; @@ -375,8 +390,11 @@ impl DeclareV2 { self.compiled_class_hash.to_string(), )); } - state.set_compiled_class_hash(&self.sierra_class_hash, &self.compiled_class_hash)?; + if let Some(ref class) = self.sierra_contract_class { + state.set_sierra_program(&self.sierra_class_hash, class.sierra_program.clone())?; + } + state.set_compiled_class_hash(&self.sierra_class_hash, &self.compiled_class_hash)?; state.set_contract_class( &self.compiled_class_hash.to_be_bytes(), &CompiledClass::Casm(Arc::new(casm_class)), @@ -433,7 +451,7 @@ impl DeclareV2 { // --------------- // Simulation // --------------- - pub(crate) fn create_for_simulation( + pub fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -527,7 +545,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap().clone(), true, ) .unwrap(); @@ -596,7 +614,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap(), true, ) .unwrap(); @@ -619,13 +637,13 @@ mod tests { let path; #[cfg(not(feature = "cairo_1_tests"))] { - version = &2.into() | &QUERY_VERSION_BASE.clone(); + version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); path = PathBuf::from("starknet_programs/cairo2/fibonacci.sierra"); } #[cfg(feature = "cairo_1_tests")] { - version = &1.into() | &QUERY_VERSION_BASE.clone(); + version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); path = PathBuf::from("starknet_programs/cairo1/fibonacci.sierra"); } @@ -642,7 +660,7 @@ mod tests { // create internal declare v2 let internal_declare = DeclareV2::new_with_sierra_class_hash_and_tx_hash( - &sierra_contract_class, + Some(sierra_contract_class), sierra_class_hash, Some(casm_class), casm_class_hash, @@ -667,7 +685,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap(), true, ) .unwrap(); @@ -736,7 +754,7 @@ mod tests { // test we can retreive the data let expected_casm_class = CasmContractClass::from_contract_class( - internal_declare.sierra_contract_class.clone(), + internal_declare.sierra_contract_class.unwrap().clone(), true, ) .unwrap(); diff --git a/src/transaction/deploy.rs b/src/transaction/deploy.rs index 32bf9feb3..47168dfc4 100644 --- a/src/transaction/deploy.rs +++ b/src/transaction/deploy.rs @@ -34,6 +34,8 @@ use cairo_vm::felt::Felt252; use num_traits::Zero; use std::sync::Arc; +use std::fmt::Debug; + /// Represents a Deploy Transaction in the starknet network #[derive(Debug, Clone)] pub struct Deploy { @@ -138,6 +140,7 @@ impl Deploy { .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } /// Deploys the contract in the starknet network and calls its constructor if it has one. @@ -149,7 +152,13 @@ impl Deploy { state: &mut CachedState, block_context: &BlockContext, ) -> Result { - state.set_contract_class(&self.contract_hash, &self.contract_class)?; + match self.contract_class { + CompiledClass::Sierra(_) => todo!(), + _ => { + state.set_contract_class(&self.contract_hash, &self.contract_class)?; + } + } + state.deploy_contract(self.contract_address.clone(), self.contract_hash)?; if self.constructor_entry_points_empty(self.contract_class.clone())? { @@ -180,7 +189,7 @@ impl Deploy { let resources_manager = ExecutionResourcesManager::default(); - let changes = state.count_actual_storage_changes(None)?; + let changes = state.count_actual_state_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[Some(call_info.clone())], @@ -243,7 +252,7 @@ impl Deploy { block_context.validate_max_n_steps, )?; - let changes = state.count_actual_storage_changes(None)?; + let changes = state.count_actual_state_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[call_info.clone()], @@ -267,6 +276,14 @@ impl Deploy { /// ## Parameters /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::Deploy, + self.version = ?self.version, + self.contract_hash = ?self.contract_hash, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.contract_address_salt = ?self.contract_address_salt, + ))] pub fn execute( &self, state: &mut CachedState, diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index b537c6f99..978cbcca0 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -40,6 +40,7 @@ use crate::{ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; +use std::fmt::Debug; #[derive(Clone, Debug, PartialEq, Eq)] pub struct StateSelector { @@ -156,6 +157,15 @@ impl DeployAccount { } } + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::DeployAccount, + self.version = ?self.version, + self.class_hash = ?self.class_hash, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.contract_address_salt = ?self.contract_address_salt, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, @@ -163,7 +173,7 @@ impl DeployAccount { ) -> Result { self.handle_nonce(state)?; - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; let mut tx_exec_info = self.apply(&mut transactional_state, block_context)?; let actual_fee = calculate_tx_fee( @@ -215,6 +225,7 @@ impl DeployAccount { .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(_) => todo!(), } } @@ -243,7 +254,7 @@ impl DeployAccount { resources_manager, &[Some(constructor_call_info.clone()), validate_info.clone()], TransactionType::DeployAccount, - state.count_actual_storage_changes(Some(( + state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.contract_address, )))?, @@ -393,7 +404,7 @@ impl DeployAccount { Ok(call_info) } - pub(crate) fn create_for_simulation( + pub fn create_for_simulation( &self, skip_validate: bool, skip_execute: bool, @@ -414,6 +425,42 @@ impl DeployAccount { Transaction::DeployAccount(tx) } + + pub fn from_sn_api_transaction( + value: starknet_api::transaction::DeployAccountTransaction, + chain_id: Felt252, + ) -> Result { + let max_fee = value.max_fee.0; + let version = Felt252::from_bytes_be(value.version.0.bytes()); + let nonce = Felt252::from_bytes_be(value.nonce.0.bytes()); + let class_hash: [u8; 32] = value.class_hash.0.bytes().try_into().unwrap(); + let contract_address_salt = Felt252::from_bytes_be(value.contract_address_salt.0.bytes()); + + let signature = value + .signature + .0 + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(); + let constructor_calldata = value + .constructor_calldata + .0 + .as_ref() + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(); + + DeployAccount::new( + class_hash, + max_fee, + version, + nonce, + constructor_calldata, + signature, + contract_address_salt, + chain_id, + ) + } } // ---------------------------------- diff --git a/src/transaction/error.rs b/src/transaction/error.rs index c254dd152..87a1f76a5 100644 --- a/src/transaction/error.rs +++ b/src/transaction/error.rs @@ -147,4 +147,6 @@ pub enum TransactionError { InvalidCompiledClassHash(String, String), #[error(transparent)] FromByteArrayError(#[from] FromByteArrayError), + #[error("DeclareV2 transaction has neither Sierra nor Casm contract class set")] + DeclareV2NoSierraOrCasm, } diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index 9808591be..aa04a6e38 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -73,11 +73,9 @@ pub(crate) fn execute_fee_transfer( call_info.ok_or(TransactionError::CallInfoIsNone) } -// ---------------------------------------------------------------------------------------- /// Calculates the fee of a transaction given its execution resources. /// We add the l1_gas_usage (which may include, for example, the direct cost of L2-to-L1 /// messages) to the gas consumed by Cairo resource and multiply by the L1 gas price. - pub fn calculate_tx_fee( resources: &HashMap, gas_price: u128, @@ -94,11 +92,9 @@ pub fn calculate_tx_fee( Ok(total_l1_gas_usage.ceil() as u128 * gas_price) } -// ---------------------------------------------------------------------------------------- /// Calculates the L1 gas consumed when submitting the underlying Cairo program to SHARP. /// I.e., returns the heaviest Cairo resource weight (in terms of L1 gas), as the size of /// a proof is determined similarly - by the (normalized) largest segment. - pub(crate) fn calculate_l1_gas_by_cairo_usage( block_context: &BlockContext, cairo_resource_usage: &HashMap, @@ -117,6 +113,7 @@ pub(crate) fn calculate_l1_gas_by_cairo_usage( )) } +/// Calculates the maximum weighted value from a given resource usage mapping. fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap) -> f64 { let mut max = 0.0_f64; for (k, v) in weights { @@ -136,6 +133,11 @@ fn max_of_keys(cairo_rsc: &HashMap, weights: &HashMap( state: &mut CachedState, resources: &HashMap, @@ -195,6 +197,8 @@ mod tests { }; use std::{collections::HashMap, sync::Arc}; + /// Tests the behavior of the charge_fee function when the actual fee exceeds the maximum fee + /// for version 0. It expects to return an ActualFeeExceedsMaxFee error. #[test] fn charge_fee_v0_max_fee_exceeded_should_charge_nothing() { let mut state = CachedState::new( @@ -224,6 +228,8 @@ mod tests { assert_eq!(result.1, 0); } + /// Tests the behavior of the charge_fee function when the actual fee exceeds the maximum fee + /// for version 1. It expects the function to return the maximum fee. #[test] fn charge_fee_v1_max_fee_exceeded_should_charge_max_fee() { let mut state = CachedState::new( diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 877131c0f..1f8a0937c 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -28,6 +28,7 @@ use crate::{ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; +use std::fmt::Debug; /// Represents an InvokeFunction transaction in the starknet network. #[derive(Debug, Getters, Clone)] @@ -244,8 +245,12 @@ impl InvokeFunction { remaining_gas: u128, ) -> Result { let mut resources_manager = ExecutionResourcesManager::default(); - let validate_info = - self.run_validate_entrypoint(state, &mut resources_manager, block_context)?; + let validate_info = if self.skip_validation { + None + } else { + self.run_validate_entrypoint(state, &mut resources_manager, block_context)? + }; + // Execute transaction let ExecutionResult { call_info, @@ -261,7 +266,7 @@ impl InvokeFunction { remaining_gas, )? }; - let changes = state.count_actual_storage_changes(Some(( + let changes = state.count_actual_state_changes(Some(( &block_context.starknet_os_config.fee_token_address, &self.contract_address, )))?; @@ -289,6 +294,14 @@ impl InvokeFunction { /// - state: A state that implements the [`State`] and [`StateReader`] traits. /// - block_context: The block's execution context. /// - remaining_gas: The amount of gas that the transaction disposes. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::InvokeFunction, + self.version = ?self.version, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.entry_point_selector = ?self.entry_point_selector, + self.entry_point_type = ?self.entry_point_type, + ))] pub fn execute( &self, state: &mut CachedState, @@ -299,7 +312,7 @@ impl InvokeFunction { self.handle_nonce(state)?; } - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; let mut tx_exec_info = self.apply(&mut transactional_state, block_context, remaining_gas)?; @@ -659,7 +672,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) @@ -804,7 +817,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); let expected_error = internal_invoke_function.apply(&mut transactional, &BlockContext::default(), 0); @@ -867,7 +880,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let result = internal_invoke_function .apply(&mut transactional, &BlockContext::default(), 0) @@ -940,7 +953,7 @@ mod tests { ) .unwrap(); - let mut transactional = state.create_transactional(); + let mut transactional = state.create_transactional().unwrap(); // Invoke result let expected_error = internal_invoke_function.apply(&mut transactional, &BlockContext::default(), 0); @@ -1291,7 +1304,7 @@ mod tests { ) .unwrap(), None, - &1.into() | &QUERY_VERSION_BASE.clone(), + &Into::::into(1) | &QUERY_VERSION_BASE.clone(), ); assert!(expected_error.is_err()); } @@ -1342,7 +1355,7 @@ mod tests { let mut state = CachedState::new(Arc::new(state_reader), Arc::new(casm_contract_class_cache)); - let state_before_execution = state.clone(); + let state_before_execution = state.clone_for_testing(); let result = internal_invoke_function .execute(&mut state, &BlockContext::default(), 0) diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index fbae7e3e6..f01031436 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -7,6 +7,7 @@ use cairo_vm::felt::Felt252; use getset::Getters; use num_traits::Zero; +use super::Transaction; use crate::{ core::transaction_hash::{calculate_transaction_hash_common, TransactionHashPrefix}, definitions::{ @@ -25,10 +26,9 @@ use crate::{ utils::{calculate_tx_resources, Address}, }; -use super::Transaction; - #[allow(dead_code)] #[derive(Debug, Getters, Clone)] +/// Represents an L1Handler transaction in the StarkNet network. pub struct L1Handler { #[getset(get = "pub")] hash_value: Felt252, @@ -43,6 +43,7 @@ pub struct L1Handler { } impl L1Handler { + /// Constructor creates a new [L1Handler] instance. pub fn new( contract_address: Address, entry_point_selector: Felt252, @@ -71,7 +72,12 @@ impl L1Handler { hash_value, ) } - + /// Creates a new [L1Handler] instance with a specified transaction hash. + /// + /// # Safety + /// + /// `tx_hash` will be assumed to be the same as would result from calling + /// `calculate_transaction_hash_common`. Non-compliance will result in silent misbehavior. pub fn new_with_tx_hash( contract_address: Address, entry_point_selector: Felt252, @@ -93,6 +99,13 @@ impl L1Handler { } /// Applies self to 'state' by executing the L1-handler entry point. + #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( + tx_type = ?TransactionType::L1Handler, + self.hash_value = ?self.hash_value, + self.contract_address = ?self.contract_address, + self.entry_point_selector = ?self.entry_point_selector, + self.nonce = ?self.nonce, + ))] pub fn execute( &self, state: &mut CachedState, @@ -128,7 +141,7 @@ impl L1Handler { )? }; - let changes = state.count_actual_storage_changes(None)?; + let changes = state.count_actual_state_changes(None)?; let actual_resources = calculate_tx_resources( resources_manager, &[call_info.clone()], @@ -189,11 +202,9 @@ impl L1Handler { L1_HANDLER_VERSION.into(), )) } - pub(crate) fn create_for_simulation( - &self, - skip_validate: bool, - skip_execute: bool, - ) -> Transaction { + + /// Creates a L1Handler for simulation purposes. + pub fn create_for_simulation(&self, skip_validate: bool, skip_execute: bool) -> Transaction { let tx = L1Handler { skip_validate, skip_execute, @@ -202,6 +213,27 @@ impl L1Handler { Transaction::L1Handler(tx) } + + /// Creates a `L1Handler` from a starknet api `L1HandlerTransaction`. + pub fn from_sn_api_tx( + tx: starknet_api::transaction::L1HandlerTransaction, + tx_hash: Felt252, + paid_fee_on_l1: Option, + ) -> Result { + L1Handler::new_with_tx_hash( + Address(Felt252::from_bytes_be(tx.contract_address.0.key().bytes())), + Felt252::from_bytes_be(tx.entry_point_selector.0.bytes()), + tx.calldata + .0 + .as_ref() + .iter() + .map(|f| Felt252::from_bytes_be(f.bytes())) + .collect(), + Felt252::from_bytes_be(tx.nonce.0.bytes()), + paid_fee_on_l1, + tx_hash, + ) + } } #[cfg(test)] @@ -230,6 +262,7 @@ mod test { sync::Arc, }; + /// Test the correct execution of the L1Handler. #[test] fn test_execute_l1_handler() { let l1_handler = L1Handler::new( @@ -289,6 +322,8 @@ mod test { assert_eq!(tx_exec, expected_tx_exec) } + /// Helper function to construct the expected transaction execution info. + /// Expected output of the L1Handler's execution. fn expected_tx_exec_info() -> TransactionExecutionInfo { TransactionExecutionInfo { validate_info: None, @@ -311,14 +346,14 @@ mod test { 10.into(), ], retdata: vec![], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 141, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 6), ("pedersen_builtin".to_string(), 2), ]), - }, + }), events: vec![], l2_to_l1_messages: vec![], storage_read_values: vec![0.into(), 0.into()], diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index 5584aa940..3d75e4266 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -82,6 +82,7 @@ impl Transaction { Transaction::L1Handler(tx) => tx.execute(state, block_context, remaining_gas), } } + /// It creates a new transaction structure modificating the skip flags. It is meant to be used only to run a simulation ///## Parameters: ///- skip_validate: the transaction will not be verified. diff --git a/src/transaction/verify_version.rs b/src/transaction/verify_version.rs index 8787b09b9..2f9abecdb 100644 --- a/src/transaction/verify_version.rs +++ b/src/transaction/verify_version.rs @@ -31,6 +31,8 @@ pub fn verify_version( #[cfg(test)] mod test { + use cairo_vm::felt::Felt252; + // TODO: fixture tests would be better here use crate::{definitions::constants::QUERY_VERSION_BASE, transaction::error::TransactionError}; @@ -109,7 +111,7 @@ mod test { #[test] fn version_0_with_max_fee_0_nonce_0_and_empty_signature_and_query_version_set_should_return_ok() { - let version = &0.into() | &QUERY_VERSION_BASE.clone(); + let version = &Into::::into(0) | &QUERY_VERSION_BASE.clone(); let max_fee = 0; let nonce = 0.into(); let signature = vec![]; @@ -119,7 +121,7 @@ mod test { #[test] fn version_1_with_query_version_set_should_return_ok() { - let version = &1.into() | &QUERY_VERSION_BASE.clone(); + let version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); let max_fee = 2; let nonce = 3.into(); let signature = vec![5.into()]; @@ -129,7 +131,7 @@ mod test { #[test] fn version_2_with_query_version_set_should_return_ok() { - let version = &2.into() | &QUERY_VERSION_BASE.clone(); + let version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); let max_fee = 43; let nonce = 4.into(); let signature = vec![6.into()]; diff --git a/src/utils.rs b/src/utils.rs index b1736f852..dfa67e6d4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ use crate::core::errors::hash_errors::HashError; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; -use crate::state::state_api::State; +use crate::state::state_api::{State, StateChangesCount}; use crate::{ definitions::transaction_type::TransactionType, execution::{ @@ -16,6 +16,7 @@ use cairo_vm::{ felt::Felt252, serde::deserialize_program::BuiltinName, vm::runners::builtin_runner, }; use cairo_vm::{types::relocatable::Relocatable, vm::vm_core::VirtualMachine}; +use core::fmt; use num_integer::Integer; use num_traits::{Num, ToPrimitive}; use serde::{Deserialize, Serialize}; @@ -36,9 +37,21 @@ pub type CompiledClassHash = [u8; 32]; //* Address //* ------------------- -#[derive(Debug, Clone, PartialEq, Hash, Eq, Default, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Hash, Eq, Default, Serialize, Deserialize)] pub struct Address(pub Felt252); +impl fmt::Display for Address { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "0x{}", self.0.to_str_radix(16)) + } +} + +impl fmt::Debug for Address { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self) + } +} + //* ------------------- //* Helper Functions //* ------------------- @@ -135,17 +148,17 @@ pub fn string_to_hash(class_string: &String) -> ClassHash { /// Converts CachedState storage mapping to StateDiff storage mapping. pub fn to_state_diff_storage_mapping( - storage_writes: HashMap, + storage_writes: &HashMap, ) -> HashMap> { let mut storage_updates: HashMap> = HashMap::new(); - for ((address, key), value) in storage_writes.into_iter() { + for ((address, key), value) in storage_writes.iter() { storage_updates - .entry(address) + .entry(address.clone()) .and_modify(|updates_for_address: &mut HashMap| { - let key_fe = Felt252::from_bytes_be(&key); + let key_fe = Felt252::from_bytes_be(key); updates_for_address.insert(key_fe, value.clone()); }) - .or_insert_with(|| HashMap::from([(Felt252::from_bytes_be(&key), value)])); + .or_insert_with(|| HashMap::from([(Felt252::from_bytes_be(key), value.clone())])); } storage_updates } @@ -169,14 +182,11 @@ pub fn calculate_tx_resources( resources_manager: ExecutionResourcesManager, call_info: &[Option], tx_type: TransactionType, - storage_changes: (usize, usize), + state_changes: StateChangesCount, l1_handler_payload_size: Option, n_reverted_steps: usize, ) -> Result, TransactionError> { - let (n_modified_contracts, n_storage_changes) = storage_changes; - let non_optional_calls: Vec = call_info.iter().flatten().cloned().collect(); - let n_deployments = non_optional_calls.iter().map(get_call_n_deployments).sum(); let mut l2_to_l1_messages = Vec::new(); @@ -184,13 +194,8 @@ pub fn calculate_tx_resources( l2_to_l1_messages.extend(call_info.get_sorted_l2_to_l1_messages()?) } - let l1_gas_usage = calculate_tx_gas_usage( - l2_to_l1_messages, - n_modified_contracts, - n_storage_changes, - l1_handler_payload_size, - n_deployments, - ); + let l1_gas_usage = + calculate_tx_gas_usage(l2_to_l1_messages, &state_changes, l1_handler_payload_size); let cairo_usage = resources_manager.cairo_usage.clone(); let tx_syscall_counter = resources_manager.syscall_counter; @@ -301,7 +306,7 @@ pub fn get_storage_var_address( let args = args .iter() - .map(|felt| felt_to_field_element(felt)) + .map(felt_to_field_element) .collect::, _>>()?; let storage_var_name_hash = @@ -488,6 +493,7 @@ pub mod test_utils { macro_rules! ids_data { ( $( $name: expr ),* ) => { { + #[allow(clippy::useless_vec)] let ids_names = vec![$( $name ),*]; let references = $crate::utils::test_utils::references!(ids_names.len() as i32); let mut ids_data = HashMap::::new(); @@ -810,7 +816,7 @@ mod test { storage.insert((address1.clone(), key1), value1.clone()); storage.insert((address2.clone(), key2), value2.clone()); - let map = to_state_diff_storage_mapping(storage); + let map = to_state_diff_storage_mapping(&storage); let key1_fe = Felt252::from_bytes_be(key1.as_slice()); let key2_fe = Felt252::from_bytes_be(key2.as_slice()); @@ -881,7 +887,7 @@ mod test { storage.insert((address1.clone(), key1), value1.clone()); storage.insert((address2.clone(), key2), value2.clone()); - let state_dff = to_state_diff_storage_mapping(storage); + let state_dff = to_state_diff_storage_mapping(&storage); let cache_storage = to_cache_state_storage_mapping(&state_dff); let mut expected_res = HashMap::new(); @@ -920,4 +926,10 @@ mod test { ], ); } + + #[test] + fn test_address_display() { + let address = Address(Felt252::from(123456789)); + assert_eq!(format!("{}", address), "0x75bcd15".to_string()); + } } diff --git a/starknet_programs/cairo1/square_root_recursive.cairo b/starknet_programs/cairo1/square_root_recursive.cairo new file mode 100644 index 000000000..a38b7e1fe --- /dev/null +++ b/starknet_programs/cairo1/square_root_recursive.cairo @@ -0,0 +1,24 @@ +#[abi] +trait Math { + #[external] + fn square_root(n: felt252) -> felt252; +} + +#[contract] +mod SquareRoot { + use super::MathDispatcherTrait; + use super::MathLibraryDispatcher; + use starknet::ClassHash; + + #[external] + fn square_root_recursive(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + square_root_recursive_inner(n, math_class_hash, n_iterations) + } + + fn square_root_recursive_inner(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + if n_iterations == 0 { + return n; + } + square_root_recursive_inner(MathLibraryDispatcher {class_hash: math_class_hash}.square_root(n), math_class_hash, n_iterations - 1) + } +} diff --git a/starknet_programs/cairo1/wallet_wrapper.cairo b/starknet_programs/cairo1/wallet_wrapper.cairo index d3557a309..ca65cef90 100644 --- a/starknet_programs/cairo1/wallet_wrapper.cairo +++ b/starknet_programs/cairo1/wallet_wrapper.cairo @@ -22,4 +22,13 @@ mod WalletWrapper { fn increase_balance(amount: felt252, simple_wallet_contract_address: ContractAddress) { SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(amount) } + + #[external] + fn increase_balance_recursive(amount: felt252, simple_wallet_contract_address: ContractAddress) { + if amount == 0 { + return(); + } + SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(1); + increase_balance_recursive(amount - 1, simple_wallet_contract_address) + } } diff --git a/starknet_programs/cairo2/account_panic.cairo b/starknet_programs/cairo2/account_panic.cairo new file mode 100644 index 000000000..3cb051250 --- /dev/null +++ b/starknet_programs/cairo2/account_panic.cairo @@ -0,0 +1,148 @@ +use starknet::account::Call; + +mod SUPPORTED_TX_VERSION { + const DEPLOY_ACCOUNT: felt252 = 1; + const DECLARE: felt252 = 2; + const INVOKE: felt252 = 1; +} + +#[starknet::interface] +trait IAccount { + fn is_valid_signature(self: @T, hash: felt252, signature: Array) -> felt252; + fn supports_interface(self: @T, interface_id: felt252) -> bool; + fn public_key(self: @T) -> felt252; +} + +#[starknet::contract] +mod Account { + use super::{Call, IAccount, SUPPORTED_TX_VERSION}; + use starknet::{get_caller_address, call_contract_syscall, get_tx_info, VALIDATED}; + use zeroable::Zeroable; + use array::{ArrayTrait, SpanTrait}; + use ecdsa::check_ecdsa_signature; + use box::BoxTrait; + use result::ResultTrait; + + const SIMULATE_TX_VERSION_OFFSET: felt252 = 340282366920938463463374607431768211456; // 2**128 + const SRC6_TRAIT_ID: felt252 = 1270010605630597976495846281167968799381097569185364931397797212080166453709; // hash of SNIP-6 trait + + #[storage] + struct Storage { + public_key: felt252 + } + + #[constructor] + fn constructor(ref self: ContractState, public_key: felt252) { + self.public_key.write(public_key); + } + + #[external(v0)] + impl AccountImpl of IAccount { + fn is_valid_signature(self: @ContractState, hash: felt252, signature: Array) -> felt252 { + let is_valid = self.is_valid_signature_bool(hash, signature.span()); + if is_valid { VALIDATED } else { 0 } + } + + fn supports_interface(self: @ContractState, interface_id: felt252) -> bool { + interface_id == SRC6_TRAIT_ID + } + + fn public_key(self: @ContractState) -> felt252 { + self.public_key.read() + } + } + + #[external(v0)] + #[generate_trait] + impl ProtocolImpl of ProtocolTrait { + fn __execute__(ref self: ContractState, calls: Array) -> Array> { + let arr = ArrayTrait::new(); + panic_with_felt252('panic'); + arr + //self.only_protocol(); + // self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); + // self.execute_multiple_calls(calls) + } + + fn __validate__(self: @ContractState, calls: Array) -> felt252 { + panic_with_felt252('panic'); + 0 +// self.only_protocol(); +// self.only_supported_tx_version(SUPPORTED_TX_VERSION::INVOKE); +// self.validate_transaction() + } + + fn __validate_declare__(self: @ContractState, class_hash: felt252) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::DECLARE); + self.validate_transaction() + } + + fn __validate_deploy__(self: @ContractState, class_hash: felt252, salt: felt252, public_key: felt252) -> felt252 { + self.only_protocol(); + self.only_supported_tx_version(SUPPORTED_TX_VERSION::DEPLOY_ACCOUNT); + self.validate_transaction() + } + } + + #[generate_trait] + impl PrivateImpl of PrivateTrait { + fn only_protocol(self: @ContractState) { + let sender = get_caller_address(); + assert(sender.is_zero(), 'Account: invalid caller'); + } + + fn is_valid_signature_bool(self: @ContractState, hash: felt252, signature: Span) -> bool { + let is_valid_length = signature.len() == 2_u32; + + if !is_valid_length { + return false; + } + + check_ecdsa_signature( + hash, self.public_key.read(), *signature.at(0_u32), *signature.at(1_u32) + ) + } + + fn validate_transaction(self: @ContractState) -> felt252 { + let tx_info = get_tx_info().unbox(); + let tx_hash = tx_info.transaction_hash; + let signature = tx_info.signature; + + let is_valid = self.is_valid_signature_bool(tx_hash, signature); + assert(is_valid, 'Account: Incorrect tx signature'); + VALIDATED + } + + fn execute_single_call(self: @ContractState, call: Call) -> Span { + let Call{to, selector, calldata} = call; + call_contract_syscall(to, selector, calldata.span()).unwrap() + } + + fn execute_multiple_calls(self: @ContractState, mut calls: Array) -> Array> { + let mut res = ArrayTrait::new(); + loop { + match calls.pop_front() { + Option::Some(call) => { + let _res = self.execute_single_call(call); + res.append(_res); + }, + Option::None(_) => { + break (); + }, + }; + }; + res + } + + fn only_supported_tx_version(self: @ContractState, supported_tx_version: felt252) { + let tx_info = get_tx_info().unbox(); + let version = tx_info.version; + assert( + version == supported_tx_version || + version == SIMULATE_TX_VERSION_OFFSET + supported_tx_version, + 'Account: Unsupported tx version' + ); + } + } +} diff --git a/starknet_programs/cairo2/callee.cairo b/starknet_programs/cairo2/callee.cairo new file mode 100644 index 000000000..3a71ab549 --- /dev/null +++ b/starknet_programs/cairo2/callee.cairo @@ -0,0 +1,22 @@ +#[starknet::contract] +mod Callee { + #[storage] + struct Storage { + balance: felt252, + } + + #[constructor] + fn constructor(ref self: ContractState, initial_balance: felt252) { + self.balance.write(initial_balance); + } + + #[external(v0)] + fn return_42(ref self: ContractState) -> felt252 { + 42 + } + + #[external(v0)] + fn return_44(ref self: ContractState) -> felt252 { + 44 + } +} \ No newline at end of file diff --git a/starknet_programs/cairo2/caller.cairo b/starknet_programs/cairo2/caller.cairo new file mode 100644 index 000000000..179478d46 --- /dev/null +++ b/starknet_programs/cairo2/caller.cairo @@ -0,0 +1,19 @@ +#[starknet::contract] +mod Caller { + use starknet::call_contract_syscall; + use core::array; + use core::result::ResultTrait; + + #[storage] + struct Storage { + balance: felt252, + } + + #[external(v0)] + fn call_callee_contract(ref self: ContractState, function_selector: felt252) -> felt252 { + let calldata: Array = ArrayTrait::new(); + let callee_addr = starknet::get_contract_address(); + let return_data = call_contract_syscall(callee_addr, function_selector, calldata.span()).unwrap(); + *return_data.get(0_usize).unwrap().unbox() + } +} diff --git a/starknet_programs/cairo2/deploy.cairo b/starknet_programs/cairo2/deploy.cairo index b773e94bb..8025d11aa 100644 --- a/starknet_programs/cairo2/deploy.cairo +++ b/starknet_programs/cairo2/deploy.cairo @@ -1,6 +1,8 @@ +use starknet::class_hash::ClassHash; + #[starknet::interface] trait IDeployTest { - fn deploy_test(self: @TContractState, class_hash: felt252, contract_address_salt: felt252) -> starknet::contract_address::ContractAddress; + fn deploy_test(self: @TContractState, class_hash: ClassHash, contract_address_salt: felt252) -> starknet::contract_address::ContractAddress; } #[starknet::contract] @@ -21,10 +23,10 @@ mod DeployTest { #[external(v0)] impl DeployTest of super::IDeployTest { - fn deploy_test(self: @ContractState, class_hash: felt252, contract_address_salt: felt252) -> ContractAddress { + fn deploy_test(self: @ContractState, class_hash: ClassHash, contract_address_salt: felt252) -> ContractAddress { let mut calldata = ArrayTrait::new(); calldata.append(100); - let (address0, _) = deploy_syscall(class_hash.try_into().unwrap(), contract_address_salt, calldata.span(), false).unwrap(); + let (address0, _) = deploy_syscall(class_hash, contract_address_salt, calldata.span(), false).unwrap(); address0 } } diff --git a/starknet_programs/cairo2/echo.cairo b/starknet_programs/cairo2/echo.cairo new file mode 100644 index 000000000..1cf32b282 --- /dev/null +++ b/starknet_programs/cairo2/echo.cairo @@ -0,0 +1,17 @@ +#[starknet::contract] +mod Echo { + #[storage] + struct Storage { + balance: felt252, + } + + #[constructor] + fn constructor(ref self: ContractState, initial_balance: felt252) { + self.balance.write(initial_balance); + } + + #[external(v0)] + fn echo(ref self: ContractState, value: felt252) -> felt252 { + value + } +} \ No newline at end of file diff --git a/starknet_programs/cairo2/echo_caller.cairo b/starknet_programs/cairo2/echo_caller.cairo new file mode 100644 index 000000000..80e29eb18 --- /dev/null +++ b/starknet_programs/cairo2/echo_caller.cairo @@ -0,0 +1,20 @@ +#[starknet::contract] +mod EchoCaller { + use starknet::call_contract_syscall; + use core::array; + use core::result::ResultTrait; + + #[storage] + struct Storage { + balance: felt252, + } + + #[external(v0)] + fn call_echo_contract(ref self: ContractState, function_selector: felt252, value: felt252) -> felt252 { + let mut calldata: Array = ArrayTrait::new(); + calldata.append(value); + let callee_addr = starknet::get_contract_address(); + let return_data = call_contract_syscall(callee_addr, function_selector, calldata.span()).unwrap(); + *return_data.get(0_usize).unwrap().unbox() + } +} diff --git a/starknet_programs/cairo2/erc20.cairo b/starknet_programs/cairo2/erc20.cairo index c17e9b2f3..464cf5d7d 100644 --- a/starknet_programs/cairo2/erc20.cairo +++ b/starknet_programs/cairo2/erc20.cairo @@ -67,7 +67,7 @@ mod erc_20 { self.name.write(name); self.symbol.write(symbol); self.decimals.write(decimals); - assert(!recipient.is_zero(), 'ERC20: mint to the 0 address'); + // assert(!recipient.is_zero(), 'ERC20: mint to the 0 address'); self.total_supply.write(initial_supply); self.balances.write(recipient, initial_supply); self diff --git a/starknet_programs/cairo2/event_emitter.cairo b/starknet_programs/cairo2/event_emitter.cairo new file mode 100644 index 000000000..fd5bb8129 --- /dev/null +++ b/starknet_programs/cairo2/event_emitter.cairo @@ -0,0 +1,30 @@ +#[starknet::contract] +mod EventTest { + use starknet::syscalls::emit_event_syscall; + + #[storage] + struct Storage { + balance: felt252, + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + EmitEvent: EmitEvent + } + + #[derive(Drop, starknet::Event)] + struct EmitEvent { + n: u128, + } + + #[external(v0)] + fn trigger_event(ref self: ContractState) -> felt252 { + let mut keys = ArrayTrait::new(); + keys.append('n'); + let mut values = ArrayTrait::new(); + values.append(1); + emit_event_syscall(keys.span(), values.span()).unwrap(); + 1234 + } +} diff --git a/starknet_programs/cairo2/hello_world_account.cairo b/starknet_programs/cairo2/hello_world_account.cairo index c87651795..c98ded486 100644 --- a/starknet_programs/cairo2/hello_world_account.cairo +++ b/starknet_programs/cairo2/hello_world_account.cairo @@ -108,7 +108,7 @@ mod Account { // Call the target contract starknet::call_contract_syscall( address: to, entry_point_selector: selector, calldata: calldata.span() - ).unwrap_syscall() + ).unwrap() } } } diff --git a/starknet_programs/cairo2/square_root_recursive.cairo b/starknet_programs/cairo2/square_root_recursive.cairo new file mode 100644 index 000000000..a960e572e --- /dev/null +++ b/starknet_programs/cairo2/square_root_recursive.cairo @@ -0,0 +1,37 @@ +use starknet::ClassHash; + +#[starknet::interface] +trait Math { + fn square_root(self: @TContractState, n: felt252) -> felt252; +} + +#[starknet::interface] +trait ISquareRoot { + fn square_root(self: @TContractState, n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252; +} + + +#[starknet::contract] +mod SquareRoot { + use super::MathDispatcherTrait; + use super::MathLibraryDispatcher; + use starknet::ClassHash; + + #[storage] + struct Storage{ + } + + #[external(v0)] + impl SquareRoot of super::ISquareRoot { + fn square_root(self: @ContractState, n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + square_root_recursive_inner(n, math_class_hash, n_iterations) + } + } + + fn square_root_recursive_inner(n: felt252, math_class_hash: ClassHash, n_iterations: u32) -> felt252 { + if n_iterations == 0 { + return n; + } + square_root_recursive_inner(MathLibraryDispatcher {class_hash: math_class_hash}.square_root(n), math_class_hash, n_iterations - 1) + } +} diff --git a/starknet_programs/cairo2/wallet_wrapper.cairo b/starknet_programs/cairo2/wallet_wrapper.cairo index 5208f8f73..d4a4a241b 100644 --- a/starknet_programs/cairo2/wallet_wrapper.cairo +++ b/starknet_programs/cairo2/wallet_wrapper.cairo @@ -7,7 +7,8 @@ trait SimpleWallet { #[starknet::interface] trait IWalletWrapper { fn get_balance(self: @TContractState, simple_wallet_contract_address: starknet::ContractAddress) -> felt252; - fn increase_balance(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); + fn increase_balance(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); + fn increase_balance_recursive(ref self: TContractState, amount: felt252, simple_wallet_contract_address: starknet::ContractAddress); } #[starknet::contract] @@ -28,5 +29,16 @@ mod WalletWrapper { fn increase_balance(ref self: ContractState, amount: felt252, simple_wallet_contract_address: ContractAddress) { SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(amount) } + fn increase_balance_recursive(ref self: ContractState, amount: felt252, simple_wallet_contract_address: ContractAddress) { + increase_balance_recursive_inner(amount, simple_wallet_contract_address) + } + } + + fn increase_balance_recursive_inner(amount: felt252, simple_wallet_contract_address: ContractAddress) { + if amount == 0 { + return(); + } + SimpleWalletDispatcher {contract_address: simple_wallet_contract_address}.increase_balance(1); + increase_balance_recursive_inner(amount - 1, simple_wallet_contract_address) } } diff --git a/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra b/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra new file mode 100644 index 000000000..0925ceabe --- /dev/null +++ b/starknet_programs/raw_contract_classes/0x113bf26d112a164297e04381212c9bd7409f07591f0a04f539bdf56693eaaf3.sierra @@ -0,0 +1,687 @@ +{ + "sierra_program": [ + "0x1", + "0x2", + "0x0", + "0x2", + "0x0", + "0x0", + "0x13e", + "0xc2", + "0x2a", + "0x52616e6765436865636b", + "0x0", + "0x4761734275696c74696e", + "0x66656c74323532", + "0x4172726179", + "0x1", + "0x2", + "0x536e617073686f74", + "0x3", + "0x537472756374", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x4", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x456e756d", + "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", + "0x6", + "0x2d7b9ba5597ffc180f5bbd030da76b84ecf1e4f1311043a0a15295f29ccc1b0", + "0x7", + "0x753332", + "0x4275696c74696e436f737473", + "0xa5a3299e5660d06bfa52eacd3a1fcd165ecd6f0cbac6f443fe26f6f68c70f3", + "0x38c95698b12086e50047d206c91c7248ef6f3427861aea1234b080c80fddf35", + "0xb", + "0x53797374656d", + "0xc", + "0x14de46c93830b854d231d540339ee8ae16bb18830a375fe81572a472d5945f1", + "0xf", + "0x3b5488061ac7a66f24fcbc888e7d6d5454df009b3abc2572f25f2400cfac629", + "0xe", + "0x10", + "0x5", + "0x19b3b4955bdcfa379bfc5a4949111c4efdd79128f8676f4d0895419b22e2ad7", + "0x12", + "0x426f78", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x14", + "0x4e6f6e5a65726f", + "0x464c55b21b6d3dadb22fd8587d389a14c0e53182f19e003bdf15db3ecb1676", + "0x75313238", + "0x16c8ea90dd6c64f624ab9863dc00b8f2c35a45fb64a97fa4bac6359fba975ec", + "0x18", + "0x3610c7cf372ee49406b6d03ec0b82f790884fb8652a25c91b2a749ad8982bc5", + "0x19", + "0x17", + "0xcfb175da425fe9834ebf5c4c2342c0507188ad820763d15abada732ab9341a", + "0x1b", + "0x20df6a887dc282129d37d7fa362eda55eb38e5c74604aff8fd97f11e3e79a2f", + "0x1d", + "0x101dc0399934cc08fa0d6f6f2daead4e4a38cabeea1c743e1fc28d2d6e58e99", + "0xd3a26a7712a33547a4a74e7594a446ca400cb36a0c2c307b92eff9ce82ff8", + "0x20", + "0x53746f726167654261736541646472657373", + "0x2cf4ead4392e987c9b56754a10f0a8e0f13776791e096fa6503893f05582c51", + "0x23", + "0x1586938debaf5e59bfb4e9f27763dc7b3da65f9737172ffde9ff9b65b55d857", + "0x24", + "0x1ca27f4a416836d321a19551a437aeb9946fde25373762126dda39b53c0bd11", + "0x53746f7261676541646472657373", + "0x1909a2057b9c1373b889e003e050a09f431d8108e0659d03444ced99a6eea68", + "0xb1", + "0x7265766f6b655f61705f747261636b696e67", + "0x656e61626c655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x73746f72655f74656d70", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x8", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x9", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x7533325f6571", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x6a756d70", + "0x626f6f6c5f6e6f745f696d706c", + "0x6765745f6275696c74696e5f636f737473", + "0xa", + "0x77697468647261775f6761735f616c6c", + "0x64697361626c655f61705f747261636b696e67", + "0xd", + "0x11", + "0x61727261795f6e6577", + "0x13", + "0x66656c743235325f636f6e7374", + "0x4f7574206f6620676173", + "0x61727261795f617070656e64", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x15", + "0x756e626f78", + "0x66656c743235325f737562", + "0x66656c743235325f69735f7a65726f", + "0x16", + "0x1a", + "0x1c", + "0x753132385f636f6e7374", + "0x1e", + "0x656d69745f6576656e745f73797363616c6c", + "0x1f", + "0x21", + "0x73746f726167655f626173655f616464726573735f636f6e7374", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x22", + "0x25", + "0x753132385f6f766572666c6f77696e675f616464", + "0x26", + "0x753132385f616464204f766572666c6f77", + "0x753132385f746f5f66656c74323532", + "0x73746f726167655f616464726573735f66726f6d5f62617365", + "0x27", + "0x73746f726167655f77726974655f73797363616c6c", + "0x477e157efde59c5531277ede78acb3e03ef69508c6c35fde3495aa0671d227", + "0x1d3bd105efd11cb4e1d188c3f2b302935b4db511160389bd8b0a936ce967708", + "0x73746f726167655f726561645f73797363616c6c", + "0x28", + "0x53746f7261676541636365737355313238202d206e6f6e2075313238", + "0x75313238735f66726f6d5f66656c74323532", + "0x29", + "0x304", + "0xffffffffffffffff", + "0x76", + "0x66", + "0x53", + "0x44", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x3d", + "0x2f", + "0x30", + "0x31", + "0x32", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x39", + "0x3a", + "0x3b", + "0x3c", + "0x3e", + "0x3f", + "0x40", + "0x41", + "0x42", + "0x43", + "0x45", + "0x46", + "0x47", + "0x48", + "0x4b", + "0x49", + "0x4a", + "0x4c", + "0x4d", + "0x4e", + "0x4f", + "0x50", + "0x51", + "0x52", + "0x54", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5b", + "0x5c", + "0x5d", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x62", + "0x63", + "0x64", + "0x65", + "0x67", + "0x68", + "0x69", + "0xe3", + "0x9a", + "0x9e", + "0xd1", + "0xc4", + "0xbd", + "0xf9", + "0xfe", + "0x124", + "0x11a", + "0x11f", + "0x145", + "0x13e", + "0x17d", + "0x1a3", + "0x19c", + "0x194", + "0x18c", + "0x185", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x70", + "0x71", + "0x72", + "0x73", + "0x74", + "0x75", + "0x77", + "0x78", + "0x79", + "0x7a", + "0x7b", + "0x1c2", + "0x1e3", + "0x1e8", + "0x1f3", + "0x219", + "0x212", + "0x226", + "0x7c", + "0x7d", + "0x22a", + "0x7e", + "0x7f", + "0x80", + "0x81", + "0x236", + "0x82", + "0x83", + "0x84", + "0x85", + "0x24b", + "0x250", + "0x25b", + "0x86", + "0x87", + "0x88", + "0x89", + "0x8a", + "0x271", + "0x8b", + "0x8c", + "0x8d", + "0x27c", + "0x8e", + "0x8f", + "0x90", + "0x91", + "0x92", + "0x287", + "0x93", + "0x94", + "0x95", + "0x96", + "0x97", + "0x2ad", + "0x98", + "0x99", + "0x29f", + "0x9b", + "0x9c", + "0x9d", + "0x9f", + "0xa0", + "0xa1", + "0x2bc", + "0xa2", + "0x2c9", + "0xa3", + "0xa4", + "0xa5", + "0xa6", + "0xa7", + "0x2e8", + "0xa8", + "0xa9", + "0x2ef", + "0xaa", + "0xab", + "0xac", + "0xad", + "0xae", + "0xaf", + "0xb0", + "0xf2", + "0x12b", + "0x1ab", + "0x1af", + "0x1c8", + "0x1fa", + "0x220", + "0x23b", + "0x262", + "0x264", + "0x281", + "0x28d", + "0x2b6", + "0x2c2", + "0x2d2", + "0x2dc", + "0x2e2", + "0x2f2", + "0x2fe", + "0x1c1c", + "0x241c0d01018140c0302c0407050240c060401c0c06028080802018080200", + "0x182c02038282a020302804140104c2006090182202048382006080181e02", + "0x700409070240c1b030340409050680406050400c19030340409050083017", + "0x184602048380e06030883c06108184002048383e06068080e0a0f0183a06", + "0xb00c2b030a80409070a40c280101c14021389804060501c0c06128400c24", + "0x185e020483820060b8181a02048283c06170185a02048385206068080e0a", + "0x8681e030cc0c32010241c10030340407050240c10030c40409070780c30", + "0x187202048383c061c0186e02048386c06068080e0a0481852061a808120e", + "0xfc043e010f47829030a40c0d010241410030a40c3b010241c021d0a40c29", + "0x1c0c062307c0c06229100c06218080c062081c12062107c0c06208088002", + "0x138200603134044c240180c41240180c4b0101c0c4a240180c49240180c47", + "0x400c06248480c0621808a006038480c07270089e12030188202038480c07", + "0x104aa06031040c06031043206031342e060313404540114ca406031040451", + "0x240c06248240c062381c0c062b8740c06249580c06218241206210640c06", + "0x180c490301cb00603938b0060310404072c0180e4e108180c4d0f8180c4d", + "0x18b20c04818841e030189a1b030189a0703018b60703018825a03818b212", + "0x180c410101cbe06039380e06031783e0903108ba07031643e0603124b807", + "0x1c0c062381c0c062581c0c063017c0c06218180e5f0301c9c5f03018820c", + "0x1388806031040407220180e4e318180c490118804610101c0c59038180c49", + "0x740c06228401206211900c06208180e640301c9c2c030189a06039100c07", + "0x10c2409031082e06031042e060311c320603114ac06031040c072b0180e4e", + "0x18842903018820603818cc02039900c07270ac0c06268b80c06229940c06", + "0x180c490101cac06039383a0603134600603114ce060310c9009031088809", + "0x188409030188264030189264030188e5204818840203818cc10030188217", + "0x240c42348180c4b0301cd20603938d206031040407348180e4e011a02e09", + "0x18865504818846d03018826c03818d619030189233030188a6a030188619", + "0x180c410101cca06039385c06031343a09031086c0603104700603114dc06", + "0x18b206039c00c07271c00c06208080e700301c9c02378180e650301c9c65", + "0x180e4e180180c4d011d4e806031040473011c8360903108e0060312ce207", + "0x18842b03018827603818b2640301886060399c0c072719c0c06208080e67", + "0x138660603134d2060310c12060312cac0903108580603104ee07031643c09", + "0x1c9c790301886210481884023c0180e6a0301c9c6a030188202039a80c07", + "0x1cdc0603938f40703164dc06031040407370180e4e1c0180c4d0101c6c06", + "0x1601206210ac0c06228a40c06249c00c06218d80c06218180e360301c9c06", + "0x180e4e3e0180c493e0180c4d3c8180c410101cf20603938047b160180c49", + "0x8047e0300804023e8901206210a40c06259e40c06258080c06258180e79", + "0x3004023f01804090104820073f87c18073f01c0c020381c04023f0180406", + "0x1200c12010300c7e030300c100112088073f018a4060f808a4063f0181206", + "0x1f80c55031200455031f80c440311004023f0180409010640c800b818fc07", + "0x1480456031f80c020c808047e0306c0c170107836073f0183a06290083a06", + "0x18b0062a80848063f0183c062a808047e030840c170116042073f018ac06", + "0x8fc0601024040215808fc072f8900e1b010900c7e030900c1d0117c0c7e", + "0x180458010a40c7e030b00c21010b00c7e0318c0c560118c0c7e030083c02", + "0x1900c21011900c7e030ac0c24010ac0c7e030083c02011f80c02048080430", + "0x18fc0717018c60217018fc0617018420217018fc0614818be0214818fc06", + "0x18560233818fc06010a404023f018ca0616008047e030081202180190265", + "0x8047e030081202369a80e82199a40e7e0399c3e0c049900467031f80c67", + "0x18fc063481820021c018fc061b01860021b018fc060119404023f018042e", + "0x840484031f80c38030cc0483031f80c07031a40400031f80c330319c047c", + "0x1f80e79031b404793a1c0dc0c3f0190a8441800f81f350090a063f0182e06", + "0x1b80489031f80c021c008047e032180c3601008fc060102404880321d0c06", + "0x1918063c80918063f01916063a008047e032280c700122d14073f0191206", + "0x2400c7e031c00c670123c0c7e031b80c10012380c7e032340c7c012340c7e", + "0x1f80c020480924914823c180649018fc0647018000248818fc063a018d202", + "0x1a40495031f80c700319c0494031f80c6e030400493031f80c880320c0402", + "0x8047e0300812024b21d2a94060192c063f0192606000090e063f018e806", + "0x930063f01804850125c0c7e030087002011f80c170321004023f018042e", + "0x2680e8a012680c7e0300912024c818fc064c25c0e88012600c7e032600c86", + "0x1f80c6d0319c049c031f80c6a030400482031f80c9b0320c049b031f80c99", + "0x812024fa793a9c060193e063f0190406000093c063f0180e06348093a06", + "0x1c0c6901008fc060b8190802011f80c30030b004023f018042e01008fc06", + "0x28c0c7e030087002011f80ca2030b004a25081cfc0650019160250018fc06", + "0x9120252818fc065228c0e88012900c7e032900c86012900c7e030091802", + "0x1f80c0c0304004a8031f80ca70320c04a7031f80ca55301d140253018fc06", + "0x1956063f01950060000954063f01942063480902063f0183e06338095206", + "0x191a02011f80c19030b004023f018042e01008fc060102404ab55205520c", + "0x95a063f0195a06430095a063f018048e012b00c7e030087002011f80c44", + "0x19060258018fc06572bc0e8a012bc0c7e03009120257018fc0656ab00e88", + "0x1f80c07031a404b3031f80c1f0319c04b2031f80c0c0304004b1031f80cb0", + "0x1f80c0217008047e0300812025aad166b2060196a063f0196206000096806", + "0x196e06430096e063f0180485012d80c7e030087002011f80c09032340402", + "0x18fc065c2e40e8a012e40c7e0300912025c018fc065bad80e88012dc0c7e", + "0x1a404bc031f80c120319c0480031f80c100304004bb031f80cba0320c04ba", + "0x8047e0300804025f2f57880060197c063f0197606000097a063f0180e06", + "0x11004023f01804090104820075f87c18073f01c0c020381c04023f0180406", + "0x1480c170105ca4073f01890062900890063f01888062400888063f0181206", + "0x8047e031540c1701074aa073f01832062900832063f018041901008fc06", + "0x300c100106c0c7e0306c0c1d010780c7e030740c550106c0c7e0305c0c55", + "0x1580c7e030083c02011f80c020480804c0011f80e1e0d81c360206018fc06", + "0x1f80c020480804c103008b0022c018fc0610818420210818fc062b018ac02", + "0x18be022c018fc062f81842022f818fc0612018480212018fc06010780402", + "0x8120214819842c031f80e630318c0463031f80c63030840463031f80c58", + "0xac0c2b010ac0c7e030085202011f80c2c030b004023f018042e01008fc06", + "0x19404023f0180409010c0ca07618b8c8073f01c561f06024c80215818fc06", + "0x1f80c07031a40436031f80c2e0319c0469031f80c67030c00467031f80c02", + "0x18c80608008da6a19824fc06370e06c0947808dc063f018d206198087006", + "0x8fc06380186c02011f80c0204808e806621c00c7e039b40c6d011900c7e", + "0xc7401008fc063e018e002001f00e7e031e40c6e011e40c7e030087002", + "0x18fc0632018200242818fc0642018f80242018fc0641818f20241818fc06", + "0x300c8a031f80c85030000489031f80c6a031a40488031f80c330319c0486", + "0x918063f018c8060800916063f018e80641808047e030081202452251086", + "0x235180c0323c0c7e0322c0c00012380c7e031a80c69012340c7e030cc0c67", + "0x1922064300922063f0180485012400c7e030087002011f80c02048091e8e", + "0x18fc064924c0e8a0124c0c7e03009120249018fc0648a400e88012440c7e", + "0x1a40496031f80c300319c0487031f80c65030400495031f80c940320c0494", + "0x8047e0300812024c25d2c870601930063f0192a06000092e063f0180e06", + "0x1cfc064d81916024d818fc0603818d202011f80c29030b004023f018042e", + "0x2700c86012700c7e03009180241018fc06010e004023f0193406160093499", + "0x1f80c9d4f01d14024f018fc0601224049d031f80c9c4101d10024e018fc06", + "0x940063f0183e063380944063f01818060800942063f0193e06418093e06", + "0x8fc060102404a451a81440c032900c7e032840c000128c0c7e032640c69", + "0x2980c7e030090a0252818fc06010e004023f018120646808047e030085c02", + "0x1d140254018fc060122404a7031f80ca65281d100253018fc06530190c02", + "0x1824063380954063f01820060800902063f01952064180952063f0194ea8", + "0x11004ad562ad540c032b40c7e032040c00012b00c7e0301c0c69012ac0c7e", + "0x192202011f80c02048081806628240e073f01c0c06480080c063f0180406", + "0x98c06011600412031f80c1f0324c0410031f80c0703248041f031f80c09", + "0x1f80c0c032480448031f80c44032500444031f80c020f008047e030081202", + "0x8a4063f018a40606008a4063f01820063a00824063f0189006498082006", + "0x192c022a818fc060b8190e02011f80c020480832066385c0c7e038480c95", + "0x18fc060126404023f01836064c0083c1b039f80c1d0325c041d031f80c55", + "0x25c0424031f80c1e0325804023f01842064c008b021039f80c560325c0456", + "0x1858064b80858063f018b0064b008047e0317c0c980118cbe073f0184806", + "0xb80c7e030ac0c96011900c7e0318c0c9601008fc06148193002158a40e7e", + "0x26c0465031f80c65032180465031f80c2e3201d340232018fc06320190c02", + "0x1f80c67030900467031f80c020f008047e0300812021801990023f01cca06", + "0x18600641008047e030081202013240c022c00866063f018d20610808d206", + "0x17c0433031f80c6d03084046d031f80c6a03158046a031f80c020f008047e", + "0x1870064e808dc063f018a4060600870063f0186c064e0086c063f0186606", + "0x1d00c7e030083c02011f80c19030b004023f0180409011c0dc07031c00c7e", + "0x1f00e0600018fc063c8193a023e018fc062901818023c818fc063a0193c02", + "0x27c04023f0183e0616008047e03008120208019941f031f80e0c0318c0400", + "0x1f80c07031a40419031f80c060319c0444031f80c12032840412031f80c02", + "0x1f80c1b0e954320c5000836063f0188806510083a063f018120619808aa06", + "0x1f80c1e0328c04023f0180409011580ccb0f018fc070b818da020b9489009", + "0x8be063f01890063380848063f018040608008047e031600c2c011604207", + "0x8fc06010240402660180458010b00c7e030840c330118c0c7e031480c69", + "0x18d20232018fc0624018ce0215818fc0601018200214818fc062b0194802", + "0xb004023f0180409011945c64158300c65031f80c2903294042e031f80c52", + "0x18040608008d267039f80c300329c0430031f80c090329804023f0182006", + "0x1d00c7e031a40ca8011c00c7e0301c0c69011b80c7e030180c67010e00c7e", + "0x24047c03334f2063f01c6c06408086c6d350cc187e031d0e06e1c0315202", + "0x18fc0641819580241818fc0600019560200018fc063c8195402011f80c02", + "0xcc048b031f80c6d031a4048a031f80c6a0319c0485031f80c67030c00484", + "0x2251086049f80c8d4622d140c500091a063f01908065100918063f0190a06", + "0x92290039f80c8e0328c04023f01804090123c0cce47018fc0744818da02", + "0xcc0c100125126073f01924065380924063f019200653008047e032440c2c", + "0x18fc064a01950024d018fc0644018d2024c818fc0643018ce024c018fc06", + "0x9380667a080c7e03a5c0c810125d2c874a830fc064da693298062a4049b", + "0x18fc064a81820024f018fc06012b4049d031f80c82032a804023f0180409", + "0x27c0e7e0328d40a204abc04a3031f80c9e032b804a0031f80c9d032b804a2", + "0x94c063f019480655008047e03008120252819a0a4031f80ea10320404a1", + "0x2980cae012ac0c7e0324c0ca8012a80c7e032580c69012040c7e0321c0c67", + "0x19a2ad031f80ea9032c404a95429c127e032b156aa40831600256018fc06", + "0x2bc0c3001008fc06580185802582bc0e7e032b40cb201008fc060102404ae", + "0x18fc0654018d2022f818fc0653818ce0212018fc064f818200258818fc06", + "0x2d004b3031f80cb21601d660259018fc0601078042c031f80cb1030cc0463", + "0x18c606348096c063f018be06338096a063f01848060800968063f0196606", + "0x2b80ca401008fc060102404b85bad96a0c032e00c7e032d00ca5012dc0c7e", + "0x18fc0654018d2025d818fc0653818ce025d018fc064f81820025c818fc06", + "0x1f80c93032d404023f0180409012f100bb5d0300cbc031f80cb9032940480", + "0x1a404d2031f80c870319c04be031f80c9f0304004bd031f80ca5032900402", + "0x8047e0300812026a34da4be06019a8063f0197a0652809a6063f0192c06", + "0x190e0633809ac063f0192a0608009aa063f019380652008047e0324c0cb5", + "0x2404d96c35dac0c033640c7e033540ca5013600c7e032580c690135c0c7e", + "0x18fc0643018ce026d818fc061981820026d018fc06478194802011f80c02", + "0x180409011fdbadc6d8300c7f031f80cda0329404dd031f80c88031a404dc", + "0x19c04df031f80c330304004de031f80c7c0329004023f018ce065a808047e", + "0x385c0df06019c4063f019bc0652809c2063f018da0634809c0063f018d406", + "0x1c0e0604818fc06030196c0203818fc0601018d20203018fc060107804e2", + "0x18d20222018fc0601018ce0206018fc06012dc0409031f80c07032980409", + "0x1489044062c00417031f80c0c032b80452031f80c09032a00448031f80c06", + "0x196402011f80c0204808aa06718640c7e038480cb101048201f049f80c17", + "0x18fc0601078041e031f80c1d030c004023f018360616008361d039f80c19", + "0x848063f0183e0633808b0063f01842065a00842063f018ac1e03acc0456", + "0x8047e0300812023197c48090318c0c7e031600ca50117c0c7e030400c69", + "0xb00ca5010ac0c7e030400c69010a40c7e0307c0c67010b00c7e031540ca4", + "0xe0040c031f80c1f032e0041f031f80c09032880464158a4120632018fc06", + "0x1f80c44032e804482201cfc0606019720209018fc06010e00410031f80c02", + "0x200041b031f80c12032ec041d031f80c10032ec0455031f80c48032880402", + "0x8ac1e039f80c52031b804023f018320616008321729024fc060d874aa09", + "0x1600c7001090b0073f0182e063700842063f018ac063a008047e030780c70", + "0x17c0c7e0317c0c0c010840c7e030840c0c0117c0c7e030900c7401008fc06", + "0x18041e01008fc06010240464158a412e41618c0e7e0397c4206010317802", + "0x19c0c7e030b00c69010c00c7e0318c0c67011940c7e030b80cbd010b80c7e", + "0x18fc0632019a402011f80c020480804e503008b00234818fc06328197c02", + "0x34c0469031f80c33032f80467031f80c2b031a40430031f80c290319c0433", + "0x240438033986c063f01cd4066a808d4063f018da066a008da063f018d206", + "0x1f80c70032d00470031f80c6e0381d660237018fc061b019ac02011f80c02", + "0x1800063f018e80652808f8063f018ce0634808f2063f018600633808e806", + "0x19c0483031f80c380329004023f0180e066b808047e030081202001f0f209", + "0x2190a84048190c063f0190606528090a063f018ce063480908063f0186006", + "0x1f80c0203040041f031f80c020c80818063f01804d801008fc06048196a02", + "0x8aa063f0183e060e80832063f0180e06348082e063f0180c0633808a406", + "0x1c90066d808904409040187e03074aa190b9483eda010740c7e030300cd9", + "0x18fc062b019ba022b018fc060d819b802011f80c02048083c067386c0c7e", + "0x8047e0300812022f819d024031f80e21032040421031f80c58031fc0458", + "0x400c10010a40c7e030b00cdf010b00c7e0318c0cde0118c0c7e030900caa", + "0x18fc0614819c00217018fc0622018d20232018fc0609018ce0215818fc06", + "0x1f80c10030400430031f80c5f0338404023f0180409011945c64158300c65", + "0x18d4063f01860067000866063f018880634808d2063f018240633808ce06", + "0xd80c7e030400c10011b40c7e030780ce101008fc0601024046a199a4ce0c", + "0xd8180638018fc0636819c00237018fc0622018d2021c018fc0609018ce02", + "0x19d402011f80c0204808201f03ba41809039f80e070300812e2011c0dc38", + "0x9d806011600448031f80c12033ac0444031f80c09030400412031f80c0c", + "0x18a4067580888063f0183e0608008a4063f018200676808047e030081202", + "0x83a063f0182e0643008aa063f0189006778082e063f01804ee011200c7e", + "0x2a804023f0180409010780cf10d818fc070c81902020c818fc060e9540ef0", + "0x18880608008b0063f01842066f80842063f018ac066f008ac063f0183606", + "0x1f80c1e0338404023f01804090117c48070317c0c7e031600ce0010900c7e", + "0x180e0653808522c0381852063f018c6067000858063f018880608008c606", + "0x824063f01812067900820063f01804d801008fc060f8196a020f8300e7e", + "0x1888067a00890063f01890060e80890063f0180419011100c7e030400cf3", + "0x8fc0601024041d2a86412f60b9480e7e038488848030083ef5011100c7e", + "0x5c0c69011580c7e031480c67010780c7e0306c0cbd0106c0c7e030083c02", + "0x19a402011f80c020480804f703008b0022c018fc060f0197c0210818fc06", + "0x1f80c24032f80421031f80c55031a40456031f80c190319c0424031f80c1d", + "0x3e058063f01cbe066a808be063f018c6066a008c6063f018b00669808b006", + "0x3e80464031f80c2b0601df20215818fc0616019ac02011f80c02048085206", + "0x185c067d80860063f018420634808ca063f018ac06338085c063f018c806", + "0x1f80c29033f004023f01818065a808047e030081202338c0ca090319c0c7e", + "0x18da063f018d2067d808d4063f01842063480866063f018ac0633808d206", + "0x818067f0240c7e038080cfd010180c0603018fc06010194402369a86609", + "0x1f80c1f0301d10020f818fc060f8190c020f818fc06013fc04023f0180409", + "0x832063f0180e065d8082e063f01820065d808a4063f0181206800082006", + "0x8aa063f01824065d808047e031200c2c011208812049f80c190b9481301", + "0x836063f018050301008fc06010240402810180458010740c7e031100cbb", + "0x19760212018fc060601a08020f018fc060d8180e880106c0c7e0306c0c86", + "0xb0045810958127e0318cbe2404c140463031f80c07032ec045f031f80c1e", + "0x18fc0601078041d031f80c21032ec0455031f80c56032ec04023f018b006", + "0x240c64031f80c2c032d8042b031f80c1d034180429031f80c5503418042c", + "0x18fc060301a1202011f80c02048080e06840180c7e038080d07011905629", + "0x8047e0300812020f8180c1f031f80c0c0342c040c031f80c09034280409", + "0x1100d0b011100c7e030480d0c010480c7e0301c20074500820063f0180489", + "0x4820093f01c3e0903818190d0107c0c7e030300cf3011200c0624018fc06", + "0x18fc06220190c020e818fc06010182002011f80c02048082e52240261c44", + "0x480c7e030480c69010400c7e030400c670115432073f018361d03c3c041b", + "0x4480421031f80c1e0330004023f0180409011580d110f018fc072a81a2002", + "0x18200633808be063f01832060800848063f018b00689808b0063f0184206", + "0x2404291618cbe0c030a40c7e030900d14010b00c7e030480c690118c0c7e", + "0x2180464031f80c026080856063f018043801008fc062b0185802011f80c02", + "0xb8ca0745008ca063f0180489010b80c7e03190560744008c8063f018c806", + "0x18fc0608018ce0234818fc060c818200233818fc061801a2a0218018fc06", + "0x180409011b4d433348300c6d031f80c6703450046a031f80c12031a40433", + "0x8dc063f01870068980870063f0186c06890086c063f0182e068b008047e", + "0x1b80d14011e40c7e031480c69011d00c7e031200c67011c00c7e030080c10", + "0x8fc06010240407034600c063f01c04068b808f8793a1c018063e018fc06", + "0x7c0c060f818fc0606019c00206018fc0604819be0204818fc0603019bc02", + "0x1824067080824063f0180e1003a280410031f80c0244808047e030081202", + "0x240409034680e063f01c04068c8089006031200c7e031100ce0011100c7e", + "0x7c0c7e030300cdf010300c7e0301c0cde01008fc06030193002011f80c02", + "0x87002011f80c090346c04023f0180409010400c0608018fc060f819c002", + "0x1f80c442401d140224018fc06012240444031f80c060901d100209018fc06", + "0x1f80c020347004190301832063f0182e06700082e063f018a40670808a406", + "0x300e7e0304820078e80824063f0180e065d80820063f0181206570081206", + "0x300cbb011200c7e030180cbb011100c7e030083c02011f80c1f030b0041f", + "0x83c02011f80c020347804172912012060b818fc06220196c0229018fc06", + "0x18fc06048196c020f818fc0603819760206018fc0603019760204818fc06", + "0x8fc060102404100f83013200481c0e7e0381804078f808201f060240c10", + "0x8b00224018fc060901a440222018fc0603818200209018fc060481a4202", + "0x7804023f018a40692808a4063f018201f03c9004023f01804090100a4606", + "0x1f80c19034880444031f80c0c030400419031f80c17034980417031f80c02", + "0x180406948083a55038183a063f018900694008aa063f0188806938089006", + "0x8fc060601930020f8300e7e030240c97010240c7e0301c0cf20101c0c7e", + "0x82410039f80c482201e540224018fc0603019760222018fc060f8190c02", + "0x1f80c52032d80417031f80c10032ec0452031f80c020f008047e030480c2c", + "0x18041e010240c7e0301c0c07440080e063f01804064b0083217038183206", + "0x18040c2f8403e07030400c7e030300cb60107c0c7e030240cbb010300c7e", + "0x3d4120703008b05503008181f2a818040c010240e0601160aa06010303e55", + "0x1caa0696030120703008ac550300818120c9540c020fcac04440f81c3e06", + "0x1804562a81812640c9540c0c9701c0c022b1540c090c9540c09968082055", + "0x1804650101c52290102660090381804652a818040c0b9540c02064bc1207", + "0x24120932026660232018c806990240e060119caa06048a42e55030326207", + "0x1c0c02371540c02061b49055030083f35011a80c69034d00e06010401209", + "0x180410048241209048ac133803008ca06039c00f37011940c36034d81809", + "0x1c122903cec0c023c8080e070101e7407030082009048241209160267207", + "0x27a060104012070481c0f3c030082009" + ], + "sierra_program_debug_info": { + "type_names": [], + "libfunc_names": [], + "user_func_names": [] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x966af5d72d3975f70858b044c77785d3710638bbcebbd33cc7001a91025588", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "function_idx": 1 + } + ] + }, + "abi": [ + { + "type": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "function", + "name": "emit_event", + "inputs": [ + { + "name": "incremental", + "type": "core::bool" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "event", + "name": "events::events::ContractWithEvent::IncrementalEvent", + "kind": "struct", + "members": [ + { + "name": "value", + "type": "core::integer::u128", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "events::events::ContractWithEvent::StaticEvent", + "kind": "struct", + "members": [] + }, + { + "type": "event", + "name": "events::events::ContractWithEvent::Event", + "kind": "enum", + "variants": [ + { + "name": "IncrementalEvent", + "type": "events::events::ContractWithEvent::IncrementalEvent", + "kind": "nested" + }, + { + "name": "StaticEvent", + "type": "events::events::ContractWithEvent::StaticEvent", + "kind": "nested" + } + ] + } + ] +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm b/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm new file mode 100644 index 000000000..e8527a982 --- /dev/null +++ b/starknet_programs/raw_contract_classes/0x472a8c75c832b112ac174abc3b46e7e79464ad52ecdad80079ddfe486ca5eef.casm @@ -0,0 +1,1429 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xfffffffffffffffffffffffffffefe08", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x79", + "0x4825800180007ffa", + "0x101f8", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xf9", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x60", + "0x48307ffb80007ffc", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x3d", + "0x1104800180018000", + "0x354", + "0x482480017fff8000", + "0x353", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fe1", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff37fff", + "0x10780017fff7fff", + "0x20", + "0x4824800180007fe1", + "0x0", + "0x400080007ff47fff", + "0x482480017ff48000", + "0x1", + "0x48127ffe7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff07fff8000", + "0x1104800180018000", + "0xfe", + "0x20680017fff7ffd", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff18000", + "0x1", + "0x48127fdc7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x15a", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff47fff8000", + "0x48127fdf7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fe87fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffe3b8", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x64", + "0x4825800180007ffa", + "0x1c48", + "0x400280007ff97fff", + "0x48297ffc80007ffd", + "0x482680017ff98000", + "0x1", + "0x4824800180007ffe", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x3c", + "0x1104800180018000", + "0x2cd", + "0x482480017fff8000", + "0x2cc", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007ff4", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff47fff", + "0x10780017fff7fff", + "0x1f", + "0x4824800180007ff4", + "0x0", + "0x400080007ff57fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xfe", + "0x482480017fd48000", + "0x1", + "0x20680017fff7ffc", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff28000", + "0x1", + "0x48127fef7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xd4", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff57fff8000", + "0x48127ff27fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x15", + "0x480080007ffd8000", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x6", + "0x480680017fff8000", + "0x1", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x48307ffb80007ffc", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x4", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffd", + "0x1d", + "0x40780017fff7fff", + "0x96", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x1104800180018000", + "0x92", + "0x20680017fff7ffd", + "0x7", + "0x480a7ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x10780017fff7fff", + "0x35", + "0x40780017fff7fff", + "0x3", + "0x480a7ffa7fff8000", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0xc1", + "0x20680017fff7ffd", + "0x56", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x1104800180018000", + "0x73", + "0x20680017fff7ffd", + "0x43", + "0x48127fb17fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x1104800180018000", + "0xb1", + "0x20680017fff7ffd", + "0x32", + "0x48127ffa7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x1104800180018000", + "0xd6", + "0x20680017fff7ffd", + "0x20", + "0x48127fe57fff8000", + "0x48127fe57fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xf9", + "0x20680017fff7ffd", + "0xf", + "0x48127fe47fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x3", + "0x48127fe17fff8000", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff77fff8000", + "0x48127ff77fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1b", + "0x48127fe17fff8000", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fdf7fff8000", + "0x48127fdf7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x31", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fc97fff8000", + "0x48127fc97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x65", + "0x48127f4c7fff8000", + "0x48127f957fff8000", + "0x48127f957fff8000", + "0x480680017fff8000", + "0x1", + "0x48127f957fff8000", + "0x48127f957fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0xae", + "0x48127f4c7fff8000", + "0x48127f4c7fff8000", + "0x48127f4c7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127f4c7fff8000", + "0x48127f4c7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x1104800180018000", + "0xb0", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xce", + "0x40780017fff7fff", + "0x1", + "0x40780017fff7fff", + "0x1", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x1104800180018000", + "0xc5", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x480680017fff8000", + "0x456d69744576656e74", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400280027ffb7ffb", + "0x400280037ffb7ffc", + "0x400280047ffb7ffd", + "0x400280057ffb7ffe", + "0x480280077ffb8000", + "0x20680017fff7fff", + "0xd", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0xa", + "0x480680017fff8000", + "0x1", + "0x480280087ffb8000", + "0x480280097ffb8000", + "0x1104800180018000", + "0xc6", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x1104800180018000", + "0xb9", + "0x20680017fff7ffc", + "0x1a", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xee", + "0x20680017fff7ffd", + "0xb", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x8", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff27fff8000", + "0x48127ff27fff8000", + "0x208b7fff7fff7ffe", + "0x482a7ffd7ffc8001", + "0xa0680017fff7fff", + "0x7", + "0x4824800180007fff", + "0x100000000000000000000000000000000", + "0x400280007ffb7fff", + "0x10780017fff7fff", + "0xc", + "0x400280007ffb7fff", + "0x40780017fff7fff", + "0x1", + "0x482680017ffb8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x10780017fff7fff", + "0x7", + "0x482680017ffb8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x753132385f616464204f766572666c6f77", + "0x1104800180018000", + "0xc3", + "0x20680017fff7ffd", + "0x9", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x480680017fff8000", + "0x53746f726167655772697465", + "0x400280007ffc7fff", + "0x400380017ffc7ffb", + "0x400280027ffc7ffd", + "0x400280037ffc7ffe", + "0x400380047ffc7ffd", + "0x480280067ffc8000", + "0x20680017fff7fff", + "0xd", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x7", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x9", + "0x480680017fff8000", + "0x1", + "0x480280077ffc8000", + "0x480280087ffc8000", + "0x1104800180018000", + "0x3b", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ff8", + "0x13", + "0x480680017fff8000", + "0x477e157efde59c5531277ede78acb3e03ef69508c6c35fde3495aa0671d227", + "0x400280007ffb7fff", + "0x480a7ff97fff8000", + "0x480a7ffa7fff8000", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x83", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x10780017fff7fff", + "0x12", + "0x40780017fff7fff", + "0xf", + "0x480680017fff8000", + "0x1d3bd105efd11cb4e1d188c3f2b302935b4db511160389bd8b0a936ce967708", + "0x400280007ffb7fff", + "0x480a7ffa7fff8000", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x7b", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x53746f7261676552656164", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400380027ffb7ffc", + "0x400380037ffb7ffd", + "0x480280057ffb8000", + "0x20680017fff7fff", + "0x28", + "0x480a7ff97fff8000", + "0x480280067ffb8000", + "0x1104800180018000", + "0x60", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x7", + "0x20680017fff7ffc", + "0xf", + "0x40780017fff7fff", + "0x2", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x53746f7261676541636365737355313238202d206e6f6e2075313238", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ff97fff8000", + "0x482480017ff88000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x11", + "0x480a7ff97fff8000", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x480280067ffb8000", + "0x480280077ffb8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0xa", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x400180007fff7ffd", + "0x480680017fff8000", + "0x1", + "0x48127ffe7fff8000", + "0x482480017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ff97fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x33", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x16", + "0x480280007ffc8003", + "0x480280017ffc8003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483180017ffd7ffd", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400280027ffc7ffd", + "0x20680017fff7ffe", + "0xe", + "0x402780017fff7fff", + "0x1", + "0x400380007ffc7ffd", + "0x40780017fff7fff", + "0x5", + "0x482680017ffc8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x10780017fff7fff", + "0x8", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x5", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x101f8" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 41, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -30 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 62, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 80, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 98, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 112, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 126, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 141, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x1c48" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 176, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -11 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 196, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 214, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 232, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 246, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 472, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 474, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 496, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 583, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "AP", + "offset": 0 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": -1 + } + } + } + ] + ], + [ + 635, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -4 + } + } + } + } + ] + ], + [ + 735, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 760, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 812, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 836, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 838, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 66040 <= memory[fp + -6]" + ] + ], + [ + 41, + [ + "memory[ap + 0] = 0 <= memory[ap + -30]" + ] + ], + [ + 62, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 80, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 98, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 112, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 126, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 141, + [ + "memory[ap + 0] = 7240 <= memory[fp + -6]" + ] + ], + [ + 176, + [ + "memory[ap + 0] = 0 <= memory[ap + -11]" + ] + ], + [ + 196, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 214, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 232, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 246, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 472, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 474, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 496, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 583, + [ + "memory[ap + -1] = memory[ap + 0] < 340282366920938463463374607431768211456" + ] + ], + [ + 635, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" + ] + ], + [ + 735, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 760, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 812, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 836, + [ + "memory[ap + 0] = memory[fp + -3] < 340282366920938463463374607431768211456" + ] + ], + [ + 838, + [ + "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -3], 340282366920938463463374607431768211456)" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x966af5d72d3975f70858b044c77785d3710638bbcebbd33cc7001a91025588", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "offset": 141, + "builtins": [ + "range_check" + ] + } + ] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm b/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm new file mode 100644 index 000000000..a3629918d --- /dev/null +++ b/starknet_programs/raw_contract_classes/3010533bd60cb0e70ac1bf776e171713f0e5229a084989d3894c171c160ace2.casm @@ -0,0 +1,524 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffff43f4", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x68", + "0x4825800180007ffa", + "0xbc0c", + "0x400280007ff97fff", + "0x48297ffc80007ffd", + "0x482680017ff98000", + "0x1", + "0x4824800180007ffe", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x40", + "0x1104800180018000", + "0x118", + "0x482480017fff8000", + "0x117", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007ff4", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff47fff", + "0x10780017fff7fff", + "0x23", + "0x4824800180007ff4", + "0x0", + "0x400080007ff57fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x4b", + "0x482480017f268000", + "0x1", + "0x20680017fff7ffc", + "0x10", + "0x40780017fff7fff", + "0x1", + "0x48127fff7fff8000", + "0x48127ffe7fff8000", + "0x1104800180018000", + "0x81", + "0x48127ff87fff8000", + "0x48127ff27fff8000", + "0x48127ff27fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff28000", + "0x1", + "0x48127fef7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x62", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff57fff8000", + "0x48127ff27fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x1104800180018000", + "0x3f", + "0x20680017fff7ffd", + "0x2f", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x2", + "0x1104800180018000", + "0x35", + "0x20680017fff7ffd", + "0x1c", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x3", + "0x1104800180018000", + "0x2b", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x42", + "0x48127fb97fff8000", + "0x48127fb97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fb97fff8000", + "0x48127fb97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x84", + "0x48127f777fff8000", + "0x48127f777fff8000", + "0x480680017fff8000", + "0x1", + "0x48127f777fff8000", + "0x48127f777fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x43", + "0x40780017fff7fff", + "0x1", + "0x40780017fff7fff", + "0x1", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x1104800180018000", + "0x3a", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x480680017fff8000", + "0x456d69744576656e74", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400280027ffb7ffb", + "0x400280037ffb7ffc", + "0x400280047ffb7ffd", + "0x400280057ffb7ffe", + "0x480280077ffb8000", + "0x20680017fff7fff", + "0xd", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280067ffb8000", + "0x482680017ffb8000", + "0xa", + "0x480680017fff8000", + "0x1", + "0x480280087ffb8000", + "0x480280097ffb8000", + "0x1104800180018000", + "0x27", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x363b90c0b8be133a6373701cce2f678d73ec604cb810f4d8b511c6a3ea4fcfd", + "0x400280007ffb7fff", + "0x480a7ff97fff8000", + "0x480a7ffa7fff8000", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x15", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ff97fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x7", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0xbc0c" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 35, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -11 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 55, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 77, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 95, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 109, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 197, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 199, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 221, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 48140 <= memory[fp + -6]" + ] + ], + [ + 35, + [ + "memory[ap + 0] = 0 <= memory[ap + -11]" + ] + ], + [ + 55, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 77, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 95, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 109, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 197, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 199, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 221, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x2e8359222ced3eab92eabe6442847adf1c8234edbdea21c3fa8b2d5573346c4", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm b/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm new file mode 100644 index 000000000..bf0ff34ca --- /dev/null +++ b/starknet_programs/raw_contract_classes/321aadcf42b0a4ad905616598d16c42fa9b87c812dc398e49b57bf77930629f.casm @@ -0,0 +1,1097 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffff8a94", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x7e", + "0x4825800180007ffa", + "0x756c", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x111", + "0x20680017fff7ffe", + "0x65", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x42", + "0x1104800180018000", + "0x25f", + "0x482480017fff8000", + "0x25e", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fd7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fef7fff", + "0x10780017fff7fff", + "0x25", + "0x4824800180007fd7", + "0x0", + "0x400080007ff07fff", + "0x482480017ff08000", + "0x1", + "0x48127ffe7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff17fff8000", + "0x1104800180018000", + "0x11b", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0x13b", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fed8000", + "0x1", + "0x48127fd27fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x121", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff07fff8000", + "0x48127fd57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127fde7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffd346", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x79", + "0x4825800180007ffa", + "0x2cba", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x7f", + "0x20680017fff7ffe", + "0x60", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x3d", + "0x1104800180018000", + "0x1cd", + "0x482480017fff8000", + "0x1cc", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fd7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fef7fff", + "0x10780017fff7fff", + "0x20", + "0x4824800180007fd7", + "0x0", + "0x400080007ff07fff", + "0x48127fff7fff8000", + "0x480a7ffb7fff8000", + "0x48127ff27fff8000", + "0x1104800180018000", + "0xbe", + "0x482480017fce8000", + "0x1", + "0x20680017fff7ffc", + "0xc", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff87fff8000", + "0x48127ff87fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127fff7fff8000", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff97fff8000", + "0x48127ff97fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fed8000", + "0x1", + "0x48127fd27fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x94", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff07fff8000", + "0x48127fd57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127fde7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x17", + "0x480a7ffb7fff8000", + "0x480080007ffc8000", + "0x1104800180018000", + "0x67", + "0x20680017fff7ffe", + "0x9", + "0x48127ffd7fff8000", + "0x48127ff07fff8000", + "0x48127ff07fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffd7fff8000", + "0x48127ff07fff8000", + "0x48127ff07fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0xd", + "0x480a7ffb7fff8000", + "0x48127ff07fff8000", + "0x48127ff07fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0x6e", + "0x20680017fff7ffd", + "0x1a", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x94", + "0x20680017fff7ffd", + "0xb", + "0x48127fe27fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127fe27fff8000", + "0x208b7fff7fff7ffe", + "0x48127fe27fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x18", + "0x48127fe27fff8000", + "0x48127fe27fff8000", + "0x48127fe27fff8000", + "0x480680017fff8000", + "0x1", + "0x48127fe27fff8000", + "0x48127fe27fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xa6", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x68", + "0x20680017fff7ffd", + "0xb", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0xa0680017fff8000", + "0x16", + "0x480280007ffc8003", + "0x480280017ffc8003", + "0x4844800180017ffe", + "0x100000000000000000000000000000000", + "0x483180017ffd7ffd", + "0x482480017fff7ffd", + "0x800000000000010fffffffffffffffff7ffffffffffffef0000000000000001", + "0x20680017fff7ffc", + "0x6", + "0x402480017fff7ffd", + "0xffffffffffffffffffffffffffffffff", + "0x10780017fff7fff", + "0x4", + "0x402480017ffe7ffd", + "0xf7ffffffffffffef0000000000000000", + "0x400280027ffc7ffd", + "0x20680017fff7ffe", + "0xe", + "0x402780017fff7fff", + "0x1", + "0x400380007ffc7ffd", + "0x40780017fff7fff", + "0x5", + "0x482680017ffc8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x10780017fff7fff", + "0x8", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x1104800180018000", + "0x5f", + "0x20680017fff7ffc", + "0x1a", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0x94", + "0x20680017fff7ffd", + "0xb", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x8", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x48127ff17fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ff27fff8000", + "0x48127ff27fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1afeeaff0ed5cee7d05a21078399c2f56226b0cd5657062500cef4c4e736f85", + "0x480680017fff8000", + "0x53746f726167655772697465", + "0x400280007ffc7fff", + "0x400380017ffc7ffb", + "0x400280027ffc7ffd", + "0x400280037ffc7ffe", + "0x400380047ffc7ffd", + "0x480280067ffc8000", + "0x20680017fff7fff", + "0xd", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x7", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x9", + "0x480280057ffc8000", + "0x482680017ffc8000", + "0x9", + "0x480680017fff8000", + "0x1", + "0x480280077ffc8000", + "0x480280087ffc8000", + "0x1104800180018000", + "0x62", + "0x20680017fff7ffd", + "0xb", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x48127ff67fff8000", + "0x48127ff67fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x53746f7261676552656164", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400380027ffb7ffc", + "0x400380037ffb7ffd", + "0x480280057ffb8000", + "0x20680017fff7fff", + "0x28", + "0x480a7ff97fff8000", + "0x480280067ffb8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff69", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x7", + "0x20680017fff7ffc", + "0xf", + "0x40780017fff7fff", + "0x2", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff57fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x53746f7261676541636365737355313238202d206e6f6e2075313238", + "0x400080007ffe7fff", + "0x48127ff97fff8000", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ff97fff8000", + "0x482480017ff88000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x11", + "0x480a7ff97fff8000", + "0x480280047ffb8000", + "0x482680017ffb8000", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x1", + "0x480280067ffb8000", + "0x480280077ffb8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x8", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0x20780017fff7ffb", + "0x9", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x756c" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 41, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -40 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 62, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 85, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 103, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 117, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 131, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 146, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x2cba" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 187, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -40 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 208, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 226, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 244, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 258, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 272, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 415, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 417, + [ + { + "DivMod": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x100000000000000000000000000000000" + }, + "quotient": { + "register": "AP", + "offset": 3 + }, + "remainder": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 510, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -4 + } + } + } + } + ] + ], + [ + 562, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 587, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 30060 <= memory[fp + -6]" + ] + ], + [ + 41, + [ + "memory[ap + 0] = 0 <= memory[ap + -40]" + ] + ], + [ + 62, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 85, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 103, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 117, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 131, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 146, + [ + "memory[ap + 0] = 11450 <= memory[fp + -6]" + ] + ], + [ + 187, + [ + "memory[ap + 0] = 0 <= memory[ap + -40]" + ] + ], + [ + 208, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 226, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 244, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 258, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 272, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 415, + [ + "memory[ap + 0] = memory[fp + -3] < 340282366920938463463374607431768211456" + ] + ], + [ + 417, + [ + "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -3], 340282366920938463463374607431768211456)" + ] + ], + [ + 510, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -4])" + ] + ], + [ + 562, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 587, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x1b1a0649752af1b28b3dc29a1556eee781e4a4c3a1f7f53f90fa834de098c4d", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [ + { + "selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194", + "offset": 146, + "builtins": [ + "range_check" + ] + } + ] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm b/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm new file mode 100644 index 000000000..c4da4fc1c --- /dev/null +++ b/starknet_programs/raw_contract_classes/53ad3bfb13f39cf1a9940108be4f9c6a8d9cc48a59d5f9b3c73432f877f8cf0.casm @@ -0,0 +1,755 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xffffffffffffffffffffffffffffc144", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x93", + "0x4825800180007ffa", + "0x3ebc", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x9b", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x7a", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x1104800180018000", + "0x93", + "0x20680017fff7ffe", + "0x66", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x43", + "0x1104800180018000", + "0x158", + "0x482480017fff8000", + "0x157", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fd6", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fe47fff", + "0x10780017fff7fff", + "0x26", + "0x4824800180007fd6", + "0x0", + "0x400080007fe57fff", + "0x482480017fe58000", + "0x1", + "0x48127ffe7fff8000", + "0x480a7ffb7fff8000", + "0x48127fe17fff8000", + "0x48127ff07fff8000", + "0x1104800180018000", + "0x8a", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xd7", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x48127feb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fe28000", + "0x1", + "0x48127fd17fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xbd", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fe57fff8000", + "0x48127fd47fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fee7fff8000", + "0x48127fdd7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x64", + "0x400080007ffe7fff", + "0x480a7ff97fff8000", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0x59", + "0x48127ff17fff8000", + "0x482480017ff08000", + "0x1", + "0x20680017fff7ffc", + "0x3a", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x4465706c6f79", + "0x400280007ffb7fff", + "0x400380017ffb7ffa", + "0x400280027ffb7ff9", + "0x400380037ffb7ffd", + "0x400280047ffb7ffc", + "0x400280057ffb7ffd", + "0x400280067ffb7ffe", + "0x480280087ffb8000", + "0x20680017fff7fff", + "0xc", + "0x480280077ffb8000", + "0x482680017ffb8000", + "0xc", + "0x480680017fff8000", + "0x0", + "0x480280097ffb8000", + "0x4802800a7ffb8000", + "0x4802800b7ffb8000", + "0x10780017fff7fff", + "0xb", + "0x480280077ffb8000", + "0x482680017ffb8000", + "0xb", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480280097ffb8000", + "0x4802800a7ffb8000", + "0x1104800180018000", + "0x55", + "0x20680017fff7ffc", + "0xb", + "0x48127fde7fff8000", + "0x48127fe77fff8000", + "0x48127fe77fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ff87fff8000", + "0x208b7fff7fff7ffe", + "0x48127fde7fff8000", + "0x48127fe77fff8000", + "0x48127fe77fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1b", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7074696f6e3a3a756e77726170206661696c65642e", + "0x400080007ffe7fff", + "0x48127fde7fff8000", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x44", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe", + "0xa0680017fff8004", + "0xe", + "0x4825800180047ffd", + "0x800000000000000000000000000000000000000000000000000000000000000", + "0x484480017ffe8000", + "0x110000000000000000", + "0x48307ffe7fff8002", + "0x480280007ffc7ffc", + "0x480280017ffc7ffc", + "0x402480017ffb7ffd", + "0xffffffffffffffeeffffffffffffffff", + "0x400280027ffc7ffd", + "0x10780017fff7fff", + "0x13", + "0x484480017fff8001", + "0x8000000000000000000000000000000", + "0x48317fff80007ffd", + "0x480280007ffc7ffd", + "0x480280017ffc7ffd", + "0x402480017ffc7ffe", + "0xf8000000000000000000000000000000", + "0x400280027ffc7ffe", + "0x40780017fff7fff", + "0x1", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x0", + "0x480a7ffd7fff8000", + "0x10780017fff7fff", + "0x8", + "0x482680017ffc8000", + "0x3", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x526573756c743a3a756e77726170206661696c65642e", + "0x1104800180018000", + "0x16", + "0x20680017fff7ffc", + "0x8", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x20780017fff7ff9", + "0xa", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x0", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480a7ffc7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x400180007fff7ffd", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffd7fff8000", + "0x482480017ffc8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x3ebc" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 47, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -41 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 69, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 92, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 110, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 124, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 138, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 152, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 203, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 230, + [ + { + "SystemCall": { + "system": { + "Deref": { + "register": "FP", + "offset": -5 + } + } + } + } + ] + ], + [ + 275, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 299, + [ + { + "TestLessThan": { + "lhs": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "rhs": { + "Immediate": "0x800000000000000000000000000000000000000000000000000000000000000" + }, + "dst": { + "register": "AP", + "offset": 4 + } + } + } + ] + ], + [ + 303, + [ + { + "LinearSplit": { + "value": { + "Deref": { + "register": "AP", + "offset": 3 + } + }, + "scalar": { + "Immediate": "0x110000000000000000" + }, + "max_x": { + "Immediate": "0xffffffffffffffffffffffffffffffff" + }, + "x": { + "register": "AP", + "offset": -2 + }, + "y": { + "register": "AP", + "offset": -1 + } + } + } + ] + ], + [ + 313, + [ + { + "LinearSplit": { + "value": { + "Deref": { + "register": "FP", + "offset": -3 + } + }, + "scalar": { + "Immediate": "0x8000000000000000000000000000000" + }, + "max_x": { + "Immediate": "0xffffffffffffffffffffffffffffffff" + }, + "x": { + "register": "AP", + "offset": -1 + }, + "y": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 375, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 16060 <= memory[fp + -6]" + ] + ], + [ + 47, + [ + "memory[ap + 0] = 0 <= memory[ap + -41]" + ] + ], + [ + 69, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 92, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 110, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 124, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 138, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 152, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 203, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 230, + [ + "syscall_handler.syscall(syscall_ptr=memory[fp + -5])" + ] + ], + [ + 275, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 299, + [ + "memory[ap + 4] = memory[fp + -3] < 3618502788666131106986593281521497120414687020801267626233049500247285301248" + ] + ], + [ + 303, + [ + "\n(value, scalar) = (memory[ap + 3], 313594649253062377472)\nx = min(value // scalar, 340282366920938463463374607431768211455)\ny = value - x * scalar\nmemory[ap + -2] = x\nmemory[ap + -1] = y\n" + ] + ], + [ + 313, + [ + "\n(value, scalar) = (memory[fp + -3], 10633823966279326983230456482242756608)\nx = min(value // scalar, 340282366920938463463374607431768211455)\ny = value - x * scalar\nmemory[ap + -1] = x\nmemory[ap + 0] = y\n" + ] + ], + [ + 375, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x2f459db2a642c91d279cdbe9185f3934bb1cde01b16f89896c71066cf42bb18", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm b/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm new file mode 100644 index 000000000..03cf472ff --- /dev/null +++ b/starknet_programs/raw_contract_classes/6638ce6c9bf336d1781a388668fa2206d928df5d1fa6b92e4cb41004c7e3f89.casm @@ -0,0 +1,557 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0xfffffffffffffffffffffffffffff8ee", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0xa7", + "0x4825800180007ffa", + "0x712", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0xaf", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x8e", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x1104800180018000", + "0xa7", + "0x20680017fff7ffe", + "0x7a", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x1104800180018000", + "0xa1", + "0x20680017fff7ffe", + "0x66", + "0x48307ffc80007ffd", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x43", + "0x1104800180018000", + "0xfa", + "0x482480017fff8000", + "0xf9", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fc7", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007fd57fff", + "0x10780017fff7fff", + "0x26", + "0x4824800180007fc7", + "0x0", + "0x400080007fd67fff", + "0x482480017fd68000", + "0x1", + "0x48127ffe7fff8000", + "0x48127fd37fff8000", + "0x48127fe27fff8000", + "0x48127ff07fff8000", + "0x1104800180018000", + "0x98", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xd3", + "0x48127ff37fff8000", + "0x48127ff37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017fd38000", + "0x1", + "0x48127fc27fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0xb6", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fd67fff8000", + "0x48127fc57fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fdf7fff8000", + "0x48127fce7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127fee7fff8000", + "0x48127fdd7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x4b", + "0x482480017fff8000", + "0x4a", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4825800180007ffa", + "0xa0a", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x2a", + "0x4825800180007ffa", + "0xa0a", + "0x400280007ff97fff", + "0x482680017ff98000", + "0x1", + "0x20780017fff7ffd", + "0x7", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480a7ffb7fff8000", + "0x10780017fff7fff", + "0xf", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480a7ffc7fff8000", + "0x482a7ffc7ffb8000", + "0x4825800180007ffd", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe1", + "0x20680017fff7ffd", + "0xd", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x482480017ffa8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x712" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 53, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -56 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 75, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 98, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 116, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 130, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 144, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 158, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 172, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 228, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0xa0a" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 277, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 1810 <= memory[fp + -6]" + ] + ], + [ + 53, + [ + "memory[ap + 0] = 0 <= memory[ap + -56]" + ] + ], + [ + 75, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 98, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 116, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 130, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 144, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 158, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 172, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 228, + [ + "memory[ap + 0] = 2570 <= memory[fp + -6]" + ] + ], + [ + 277, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x112e35f48499939272000bd72eb840e502ca4c3aefa8800992e8defb746e0c9", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm b/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm new file mode 100644 index 000000000..c2420dff1 --- /dev/null +++ b/starknet_programs/raw_contract_classes/7c48d040ceb3183837a0aff2adf33d879f790e202eb2c4b8622005c12252641.casm @@ -0,0 +1,476 @@ +{ + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "compiler_version": "2.0.0", + "bytecode": [ + "0xa0680017fff8000", + "0x7", + "0x482680017ffa8000", + "0x100000000000000000000000000000000", + "0x400280007ff97fff", + "0x10780017fff7fff", + "0x7d", + "0x4825800180007ffa", + "0x0", + "0x400280007ff97fff", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x85", + "0x482680017ff98000", + "0x1", + "0x20680017fff7ffd", + "0x64", + "0x48307ffb80007ffc", + "0x4824800180007fff", + "0x0", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0x6", + "0x480680017fff8000", + "0x0", + "0x10780017fff7fff", + "0x4", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x1", + "0x48307ffe80007fff", + "0x20680017fff7fff", + "0x41", + "0x1104800180018000", + "0xdb", + "0x482480017fff8000", + "0xda", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4824800180007fe5", + "0x0", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400080007ff37fff", + "0x10780017fff7fff", + "0x24", + "0x4824800180007fe5", + "0x0", + "0x400080007ff47fff", + "0x482480017ff48000", + "0x1", + "0x48127ffe7fff8000", + "0x48127ff17fff8000", + "0x1104800180018000", + "0x7c", + "0x20680017fff7ffd", + "0x11", + "0x40780017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0xb6", + "0x48127ff37fff8000", + "0x48127ff37fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x0", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x48127ffa7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482480017ff18000", + "0x1", + "0x48127fe07fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffb7fff8000", + "0x1104800180018000", + "0x99", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ff47fff8000", + "0x48127fe37fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x400080007ffe7fff", + "0x48127ffd7fff8000", + "0x48127fec7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ff98000", + "0x1", + "0x480a7ffa7fff8000", + "0x480a7ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffa7fff8000", + "0x482480017ff98000", + "0x1", + "0x208b7fff7fff7ffe", + "0x48297ffc80007ffd", + "0x20680017fff7fff", + "0x4", + "0x10780017fff7fff", + "0xa", + "0x482680017ffc8000", + "0x1", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480a7ffc7fff8000", + "0x10780017fff7fff", + "0x8", + "0x480a7ffc7fff8000", + "0x480a7ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x48127ffc7fff8000", + "0x48127ffc7fff8000", + "0x20680017fff7ffc", + "0x8", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x0", + "0x480080007ffa8000", + "0x208b7fff7fff7ffe", + "0x48127ffe7fff8000", + "0x48127ffe7fff8000", + "0x480680017fff8000", + "0x1", + "0x480680017fff8000", + "0x0", + "0x208b7fff7fff7ffe", + "0x1104800180018000", + "0x4a", + "0x482480017fff8000", + "0x49", + "0x480080007fff8000", + "0xa0680017fff8000", + "0x9", + "0x4825800180007ffc", + "0x942", + "0x482480017fff8000", + "0x100000000000000000000000000000000", + "0x400280007ffb7fff", + "0x10780017fff7fff", + "0x29", + "0x4825800180007ffc", + "0x942", + "0x400280007ffb7fff", + "0x482680017ffb8000", + "0x1", + "0x20780017fff7ffd", + "0x8", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x1", + "0x10780017fff7fff", + "0xd", + "0x48127fff7fff8000", + "0x48127ffd7fff8000", + "0x4825800180007ffd", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe2", + "0x20680017fff7ffd", + "0xd", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x48527ffd7ffd8000", + "0x48127ffd7fff8000", + "0x48127ffd7fff8000", + "0x480680017fff8000", + "0x0", + "0x480680017fff8000", + "0x0", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x48127ffb7fff8000", + "0x208b7fff7fff7ffe", + "0x40780017fff7fff", + "0x1", + "0x480680017fff8000", + "0x4f7574206f6620676173", + "0x400080007ffe7fff", + "0x482680017ffb8000", + "0x1", + "0x480a7ffc7fff8000", + "0x480680017fff8000", + "0x1", + "0x48127ffb7fff8000", + "0x482480017ffa8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x400380007ffd7ffb", + "0x480a7ffc7fff8000", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x208b7fff7fff7ffe" + ], + "hints": [ + [ + 0, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -6 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 41, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x0" + }, + "rhs": { + "Deref": { + "register": "AP", + "offset": -26 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 61, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 84, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 102, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 116, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 130, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 186, + [ + { + "TestLessThanOrEqual": { + "lhs": { + "Immediate": "0x942" + }, + "rhs": { + "Deref": { + "register": "FP", + "offset": -4 + } + }, + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ], + [ + 234, + [ + { + "AllocSegment": { + "dst": { + "register": "AP", + "offset": 0 + } + } + } + ] + ] + ], + "pythonic_hints": [ + [ + 0, + [ + "memory[ap + 0] = 0 <= memory[fp + -6]" + ] + ], + [ + 41, + [ + "memory[ap + 0] = 0 <= memory[ap + -26]" + ] + ], + [ + 61, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 84, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 102, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 116, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 130, + [ + "memory[ap + 0] = segments.add()" + ] + ], + [ + 186, + [ + "memory[ap + 0] = 2370 <= memory[fp + -4]" + ] + ], + [ + 234, + [ + "memory[ap + 0] = segments.add()" + ] + ] + ], + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x36fbc999025b89d36d31dc2f9c0a03b4377755e1f27e0e42a385aaba90f61a6", + "offset": 0, + "builtins": [ + "range_check" + ] + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + } +} \ No newline at end of file diff --git a/starknet_programs/raw_contract_classes/fibonacci.sierra b/starknet_programs/raw_contract_classes/fibonacci.sierra new file mode 100644 index 000000000..8cd932a4e --- /dev/null +++ b/starknet_programs/raw_contract_classes/fibonacci.sierra @@ -0,0 +1,373 @@ +{ + "sierra_program": [ + "0x1", + "0x2", + "0x0", + "0x2", + "0x0", + "0x0", + "0xd5", + "0x2b", + "0x16", + "0x52616e6765436865636b", + "0x0", + "0x4761734275696c74696e", + "0x66656c74323532", + "0x4172726179", + "0x1", + "0x2", + "0x536e617073686f74", + "0x3", + "0x537472756374", + "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", + "0x4", + "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", + "0x456e756d", + "0x11c6d8087e00642489f92d2821ad6ebd6532ad1a3b6d12833da6d6810391511", + "0x6", + "0x753332", + "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", + "0x4275696c74696e436f737473", + "0x17bc4bcbb517b92736828af382c42b71df97fe5d0a8db42d13069b34a1ddbe9", + "0x14de46c93830b854d231d540339ee8ae16bb18830a375fe81572a472d5945f1", + "0xd", + "0x2f528e3c691e195fca674982b69c0dc4284f206c3ea4d680220e99b59315a92", + "0xc", + "0xe", + "0x5", + "0x19b3b4955bdcfa379bfc5a4949111c4efdd79128f8676f4d0895419b22e2ad7", + "0x10", + "0x53797374656d", + "0x426f78", + "0x29d7d57c04a880978e7b3689f6218e507f3be17588744b58dc17762447ad0e7", + "0x13", + "0x4e6f6e5a65726f", + "0x50", + "0x7265766f6b655f61705f747261636b696e67", + "0x656e61626c655f61705f747261636b696e67", + "0x77697468647261775f676173", + "0x6272616e63685f616c69676e", + "0x73746f72655f74656d70", + "0x66756e6374696f6e5f63616c6c", + "0x656e756d5f6d61746368", + "0x7", + "0x7374727563745f6465636f6e737472756374", + "0x61727261795f6c656e", + "0x736e617073686f745f74616b65", + "0x8", + "0x64726f70", + "0x7533325f636f6e7374", + "0x72656e616d65", + "0x7533325f6571", + "0x7374727563745f636f6e737472756374", + "0x656e756d5f696e6974", + "0x9", + "0x6a756d70", + "0x626f6f6c5f6e6f745f696d706c", + "0x6765745f6275696c74696e5f636f737473", + "0xa", + "0x77697468647261775f6761735f616c6c", + "0x64697361626c655f61705f747261636b696e67", + "0xb", + "0xf", + "0x61727261795f6e6577", + "0x11", + "0x12", + "0x66656c743235325f636f6e7374", + "0x4f7574206f6620676173", + "0x61727261795f617070656e64", + "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", + "0x496e70757420746f6f2073686f727420666f7220617267756d656e7473", + "0x61727261795f736e617073686f745f706f705f66726f6e74", + "0x14", + "0x756e626f78", + "0x647570", + "0x66656c743235325f69735f7a65726f", + "0x15", + "0x66656c743235325f616464", + "0x66656c743235325f737562", + "0x122", + "0xffffffffffffffff", + "0xad", + "0x9d", + "0x8c", + "0x7a", + "0x17", + "0x18", + "0x19", + "0x1a", + "0x1b", + "0x1c", + "0x1d", + "0x1e", + "0x1f", + "0x21", + "0x20", + "0x22", + "0x25", + "0x23", + "0x24", + "0x26", + "0x65", + "0x27", + "0x28", + "0x29", + "0x2a", + "0x54", + "0x2b", + "0x2c", + "0x2d", + "0x2e", + "0x2f", + "0x33", + "0x34", + "0x35", + "0x36", + "0x37", + "0x38", + "0x30", + "0x31", + "0x32", + "0x39", + "0x4d", + "0x3a", + "0x3b", + "0x3c", + "0x3d", + "0x3e", + "0x41", + "0x42", + "0x3f", + "0x40", + "0x43", + "0x44", + "0x45", + "0x46", + "0x47", + "0x48", + "0x49", + "0x4a", + "0x4b", + "0x4c", + "0x4e", + "0x4f", + "0x51", + "0x52", + "0x53", + "0x55", + "0x56", + "0x57", + "0x58", + "0x59", + "0x5a", + "0x5d", + "0x5b", + "0x5c", + "0x5e", + "0x5f", + "0x60", + "0x61", + "0x62", + "0x63", + "0x64", + "0x66", + "0x67", + "0x68", + "0x69", + "0x6a", + "0x6b", + "0x6c", + "0x6d", + "0x6e", + "0x6f", + "0x70", + "0x71", + "0x72", + "0x73", + "0x74", + "0x75", + "0x76", + "0x77", + "0x78", + "0x79", + "0x7b", + "0x7c", + "0x7d", + "0x7e", + "0x7f", + "0x80", + "0x81", + "0x82", + "0x83", + "0x84", + "0x85", + "0x86", + "0x87", + "0x88", + "0x89", + "0x8a", + "0x8b", + "0x8d", + "0x8e", + "0x8f", + "0xc3", + "0xc8", + "0xd2", + "0x108", + "0xe9", + "0xfc", + "0x102", + "0xbc", + "0xd9", + "0x118", + "0x11e", + "0xa93", + "0x7060f02090e0d02060a0c060b02070a090606080706060502040203020100", + "0x2090a1502060a07060d02070a1402060a0213100610061202090e02111006", + "0x61e021d19061c061b02090e1a060d02070a190618061702090e090616060d", + "0x60906281a06062702260225022402232207060621100620061f02090e0706", + "0x60631020706302e06062f2e06062d0706062c1a06062b2a06062902060627", + "0x2370607350607340236350606270207350607341006063302322e0606272e", + "0x273c06062f3c06062d3c060633023b023a3906062702381006062f35060629", + "0x706062d0706063e1806062b3d06062907090628070606273c060627060606", + "0x607341c0606331a0606330906062f0906062d09090628090606270706062f", + "0x63316060633070606434207064106073f0607343f0606274006062702073f", + "0x6062702074706073407060646450706411a06062f440706410c0906281906", + "0x62702072a060734070606310706064847060629060747060734470606270c", + "0x3418060633024d06070641024c4b06062f024a0706064906072a0607342a06", + "0x4f06020602024f060202024e1006062706073d0607343d06062702073d0607", + "0x1a0239064f0609060c02024f060209022a1007501a0c074f07060207070202", + "0x4f060209021806513c064f0735062a020c064f060c061002352e074f063906", + "0x9023f06521c064f0719062a021916074f063d061a023d064f062e060c0202", + "0x6534b064f0720062a022040074f0647061a0247064f0616060c02024f0602", + "0x56074f065506390255064f065406350254064f0640062e02024f0602090200", + "0x24f0659063c025a59074f065806390258064f06021802024f0656063c0257", + "0x4f075c5b073d025b064f065b0619025c064f065a0616025b064f0657061602", + "0x64f065d0640025d064f065e063f025e064f06021c02024f06020902025d02", + "0x6400262064f066106470261064f06021c02024f060209020260060220025f", + "0x66463064f076006000260064f066006400260064f065f064b025f064f0662", + "0x570266064f066606560266064f06025502024f0663065402024f0602090265", + "0x64f06025902024f06025802024f060209026b6a07696867074f07661a0c09", + "0x4f0668065c026f064f0667061002024f066d065b026e6d074f066c065a026c", + "0x64b065d0273064f061c065d0272064f063c065d0271064f066e065e027006", + "0x9027a067978064f0777066102777675094f0674737271706f105f0274064f", + "0x665027e7d074f067b0663027c064f060260027b064f0678066202024f0602", + "0x28281074f06807f07670280064f067c0666027f064f067e065d02024f067d", + "0x285064f0684066b02024f0683066a028483074f0681066802024f06820654", + "0x89064f0676065c0288064f067506100287064f0686066d0286064f0685066c", + "0x67602024f060209028b8a89880c068b064f06870675028a064f0607066e02", + "0x75028e064f0607066e028d064f0676065c0279064f06750610028c064f067a", + "0x24f064b066502024f06025802024f06020902228e8d790c0622064f068c06", + "0x65d0290064f060277028f064f06026002024f063c066502024f061c066502", + "0x292064f06916907710269064f0602700291064f06908f076f0290064f0690", + "0x96064f0607066e0295064f066b065c0294064f066a06100293064f06920676", + "0x665065402024f06025802024f06020902979695940c0697064f0693067502", + "0x98064f0607066e02024f063c066502024f061c066502024f064b066502024f", + "0x29c064f060273029b064f06026002024f069a0654029a99074f0698067202", + "0x64f069d9e0771029e064f060270029d064f069c9b076f029c064f069c065d", + "0x4f0699066e0264064f061a065c02a1064f060c061002a0064f069f0676029f", + "0x65402024f06025802024f06020902a3a264a10c06a3064f06a0067502a206", + "0x64f06026002024f063c066502024f061c066502024f0640067402024f0600", + "0x64f06027002a6064f06a5a4076f02a5064f06a5065d02a5064f06027802a4", + "0x61a065c02aa064f060c061002a9064f06a8067602a8064f06a6a7077102a7", + "0x24f06020902adacabaa0c06ad064f06a9067502ac064f0607066e02ab064f", + "0x6026002024f063c066502024f0616067402024f063f065402024f06025802", + "0x6027002b0064f06afae076f02af064f06af065d02af064f06027802ae064f", + "0x65c02b4064f060c061002b3064f06b2067602b2064f06b0b1077102b1064f", + "0x6020902b653b5b40c06b6064f06b306750253064f0607066e02b5064f061a", + "0x7802b7064f06026002024f062e067402024f0618065402024f06025802024f", + "0x7102ba064f06027002b9064f06b8b7076f02b8064f06b8065d02b8064f0602", + "0xbe064f061a065c02bd064f060c061002bc064f06bb067602bb064f06b9ba07", + "0x25802024f06020902c0bfbebd0c06c0064f06bc067502bf064f0607066e02", + "0x64f06c2065d02c2064f06027702c1064f06026002024f0609067402024f06", + "0x6c5067602c5064f06c3c4077102c4064f06027002c3064f06c2c1076f02c2", + "0xc6067502c8064f0607066e02c7064f062a065c0252064f0610061002c6064f", + "0x20c06ca0907074f0706067a0206064f0602062e02c9c8c7520c06c9064f06", + "0x20022a064f061a067d0210064f0607067c021a064f0609067b02024f060209", + "0x4f060c067c0235064f062e067e022e064f06021c02024f0602090202cb0602", + "0x72a06810239064f0639060c0239064f0610066b022a064f0635067d021006", + "0x6800219064f0616067f0216064f063c068202024f060209021806cc3c064f", + "0x24f060209023f1c07063f064f063d0683021c064f0639060c023d064f0619", + "0x247064f0639060c0220064f064006840240064f06021c02024f0618065402", + "0x64f061006560210064f06025502024f060258024b4707064b064f06200683", + "0x3c1a074f061a068502024f06020902393507cd2e2a074f0710060209570210", + "0x24f061a066502024f060209021806ce024f073c0686022a064f062a061002", + "0x219064f062e065c0216064f062a061002024f0607065b02024f060c066502", + "0x60c068502024f0618068702024f0602090202cf060220023d064f0609065d", + "0x100220064f06401a078a0240064f060289021c064f063f090788023f0c074f", + "0x257064f060c065d0256064f0607065e0255064f062e065c0254064f062a06", + "0x2004b47094f06595857565554105f0259064f0620065d0258064f061c065d", + "0x64f06470610025c064f065a066202024f060209025b06d05a064f07000661", + "0x4f065e068c025e064f063d068b023d064f065c065d0219064f064b065c0216", + "0x62615f090662064f065d06790261064f0619065c025f064f06160610025d06", + "0x265064f064b065c0263064f064706100260064f065b068d02024f06020902", + "0x4f0607065b02024f060c066502024f06020902666563090666064f06600679", + "0x5d0268064f0602770267064f06026002024f061a066502024f060906650202", + "0x6c064f066a6b0771026b064f060270026a064f066867076f0268064f066806", + "0x64f066d06790275064f0639065c026e064f06350610026d064f066c068d02", + "0x20c064f06021c0209064f060706076f0207064f0602067f0276756e090676", + "0x602066e0206064f06021c02101a070610064f060c068e021a064f06090666", + "0x2090706023f4006020c1a4006020c1a0907070609064f0606068e0207064f", + "0x100907090707d21a0c090706023d0602090707073c060210d1022a1a071a06", + "0xd4021040074006d30602" + ], + "sierra_program_debug_info": { + "type_names": [], + "libfunc_names": [], + "user_func_names": [] + }, + "contract_class_version": "0.1.0", + "entry_points_by_type": { + "EXTERNAL": [ + { + "selector": "0x112e35f48499939272000bd72eb840e502ca4c3aefa8800992e8defb746e0c9", + "function_idx": 0 + } + ], + "L1_HANDLER": [], + "CONSTRUCTOR": [] + }, + "abi": [ + { + "type": "impl", + "name": "Fibonacci", + "interface_name": "fibonacci::fibonacci::IFibonacci" + }, + { + "type": "interface", + "name": "fibonacci::fibonacci::IFibonacci", + "items": [ + { + "type": "function", + "name": "fib", + "inputs": [ + { + "name": "a", + "type": "core::felt252" + }, + { + "name": "b", + "type": "core::felt252" + }, + { + "name": "n", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "fibonacci::fibonacci::Fibonacci::Event", + "kind": "enum", + "variants": [] + } + ] +} \ No newline at end of file diff --git a/tests/account_panic.rs b/tests/account_panic.rs new file mode 100644 index 000000000..195b21d9f --- /dev/null +++ b/tests/account_panic.rs @@ -0,0 +1,117 @@ +use std::sync::Arc; + +use cairo_vm::felt::Felt252; +use starknet_in_rust::{ + core::contract_address::compute_casm_class_hash, + definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, + services::api::contract_classes::compiled_class::CompiledClass, + state::{ + cached_state::CachedState, + contract_class_cache::{ContractClassCache, PermanentContractClassCache}, + in_memory_state_reader::InMemoryStateReader, + }, + transaction::{InvokeFunction, Transaction}, + utils::{calculate_sn_keccak, Address}, + CasmContractClass, +}; + +#[test] +fn account_panic() { + let account_data = include_bytes!("../starknet_programs/cairo2/account_panic.casm"); + let contract_data = include_bytes!("../starknet_programs/cairo2/contract_a.casm"); + + let account_contract_class: CasmContractClass = serde_json::from_slice(account_data).unwrap(); + let account_class_hash = compute_casm_class_hash(&account_contract_class) + .unwrap() + .to_be_bytes(); + + let contract_class: CasmContractClass = serde_json::from_slice(contract_data).unwrap(); + let contract_class_hash_felt = compute_casm_class_hash(&contract_class).unwrap(); + let contract_class_hash = contract_class_hash_felt.to_be_bytes(); + + let account_address = Address(1111.into()); + let contract_address = Address(0000.into()); + let nonce = 0.into(); + + let block_context = BlockContext::default(); + + let contract_class_cache = PermanentContractClassCache::default(); + + contract_class_cache.set_contract_class( + account_class_hash, + CompiledClass::Casm(Arc::new(account_contract_class)), + ); + contract_class_cache.set_contract_class( + contract_class_hash, + CompiledClass::Casm(Arc::new(contract_class.clone())), + ); + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(account_address.clone(), account_class_hash); + state_reader + .address_to_nonce_mut() + .insert(account_address.clone(), nonce); + state_reader + .address_to_class_hash_mut() + .insert(contract_address.clone(), contract_class_hash); + state_reader + .address_to_nonce_mut() + .insert(contract_address, 1.into()); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"__execute__")); + + // arguments of contract_a contract + // calldata is a Vec of Call, which is + /* + #[derive(Drop, Serde)] + struct Call { + to: ContractAddress, + selector: felt252, + calldata: Array + } + */ + let selector_contract = &contract_class + .entry_points_by_type + .external + .get(0) + .unwrap() + .selector; + // calldata of contract_a is 1 value. + let calldata: Vec<_> = [ + 1.into(), + contract_class_hash_felt, + selector_contract.into(), + 1.into(), + 2.into(), + ] + .to_vec(); + + // set up remaining structures + + let invoke = InvokeFunction::new( + account_address, + Felt252::new(selector), + 0, + TRANSACTION_VERSION.clone(), + calldata, + vec![], + block_context.starknet_os_config().chain_id().clone(), + Some(0.into()), + ) + .unwrap(); + + let tx = Transaction::InvokeFunction(invoke); + let exec_info = tx + .execute(&mut state, &block_context, u128::MAX) + .expect("failed to invoke"); + let call_info = exec_info.call_info.as_ref().unwrap(); + + assert_eq!(exec_info.revert_error, None); + + // 482670963043u128 == 'panic' + assert_eq!(call_info.retdata[0], 482670963043u128.into()); + assert!(call_info.failure_flag); +} diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index e4b542843..c43af7bb6 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -5,6 +5,8 @@ use cairo_vm::{ }; use num_bigint::BigUint; use num_traits::{Num, One, Zero}; +use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +use starknet_in_rust::utils::calculate_sn_keccak; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ @@ -276,7 +278,7 @@ fn library_call() { let mut resources_manager = ExecutionResourcesManager::default(); let expected_execution_resources = ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 255, + n_steps: 247, #[cfg(feature = "cairo_1_tests")] n_steps: 259, n_memory_holes: 8, @@ -284,7 +286,7 @@ fn library_call() { }; let expected_execution_resources_internal_call = ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 84, + n_steps: 80, #[cfg(feature = "cairo_1_tests")] n_steps: 85, n_memory_holes: 5, @@ -300,7 +302,7 @@ fn library_call() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [5.into()].to_vec(), - execution_resources: expected_execution_resources, + execution_resources: Some(expected_execution_resources), class_hash: Some(class_hash), internal_calls: vec![CallInfo { caller_address: Address(0.into()), @@ -316,7 +318,7 @@ fn library_call() { entry_point_type: Some(EntryPointType::External), calldata: vec![25.into()], retdata: [5.into()].to_vec(), - execution_resources: expected_execution_resources_internal_call, + execution_resources: Some(expected_execution_resources_internal_call), class_hash: Some(lib_class_hash), gas_consumed: 0, ..Default::default() @@ -327,13 +329,13 @@ fn library_call() { storage_read_values: vec![], accessed_storage_keys: HashSet::new(), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 78650, + gas_consumed: 78250, #[cfg(feature = "cairo_1_tests")] gas_consumed: 78980, ..Default::default() }; - assert_eq!( + assert_eq_sorted!( exec_entry_point .execute( &mut state, @@ -359,9 +361,10 @@ fn call_contract_storage_write_read() { let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let entrypoints = contract_class.clone().entry_points_by_type; - let get_balance_entrypoint_selector = &entrypoints.external.get(1).unwrap().selector; - let increase_balance_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("increase_balance".as_bytes())); // Create state reader with class hash data let contract_class_cache = PermanentContractClassCache::default(); @@ -742,6 +745,7 @@ fn deploy_cairo1_from_cairo1() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -842,6 +846,7 @@ fn deploy_cairo0_from_cairo1_without_constructor() { let ret_class_hash = state.get_class_hash_at(&ret_address).unwrap(); let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), + CompiledClass::Sierra(_) => unreachable!(), CompiledClass::Casm(_) => unreachable!(), }; @@ -943,6 +948,7 @@ fn deploy_cairo0_from_cairo1_with_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), CompiledClass::Casm(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1045,6 +1051,7 @@ fn deploy_cairo0_and_invoke() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Deprecated(class) => class.as_ref().clone(), CompiledClass::Casm(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1156,8 +1163,18 @@ fn test_send_message_to_l1_syscall() { payload: vec![555.into(), 666.into()], }]; + #[cfg(not(feature = "cairo_1_tests"))] + let expected_n_steps = 46; + #[cfg(feature = "cairo_1_tests")] + let expected_n_steps = 50; + + #[cfg(not(feature = "cairo_1_tests"))] + let expected_gas_consumed = 9640; + #[cfg(feature = "cairo_1_tests")] + let expected_gas_consumed = 10040; + let expected_execution_resources = ExecutionResources { - n_steps: 50, + n_steps: expected_n_steps, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 2)]), }; @@ -1170,8 +1187,8 @@ fn test_send_message_to_l1_syscall() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), l2_to_l1_messages, - execution_resources: expected_execution_resources, - gas_consumed: 10040, + execution_resources: Some(expected_execution_resources), + gas_consumed: expected_gas_consumed, ..Default::default() }; @@ -1251,8 +1268,18 @@ fn test_get_execution_info() { address.0.clone(), ]; + #[cfg(not(feature = "cairo_1_tests"))] + let expected_n_steps = 213; + #[cfg(feature = "cairo_1_tests")] + let expected_n_steps = 268; + + #[cfg(not(feature = "cairo_1_tests"))] + let expected_gas_consumed = 22980; + #[cfg(feature = "cairo_1_tests")] + let expected_gas_consumed = 28580; + let expected_execution_resources = ExecutionResources { - n_steps: 268, + n_steps: expected_n_steps, n_memory_holes: 4, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 4)]), }; @@ -1265,8 +1292,8 @@ fn test_get_execution_info() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), retdata: expected_ret_data, - execution_resources: expected_execution_resources, - gas_consumed: 28580, + execution_resources: Some(expected_execution_resources), + gas_consumed: expected_gas_consumed, ..Default::default() }; @@ -3044,3 +3071,539 @@ fn keccak_syscall() { assert_eq!(retdata[0], Felt252::one()); } + +#[test] +fn library_call_recursive_50_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/square_root_recursive.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/square_root_recursive.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let entrypoints = contract_class.clone().entry_points_by_type; + let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add lib contract to the state + + #[cfg(not(feature = "cairo_1_tests"))] + let lib_program_data = include_bytes!("../starknet_programs/cairo2/math_lib.casm"); + #[cfg(feature = "cairo_1_tests")] + let lib_program_data = include_bytes!("../starknet_programs/cairo1/math_lib.casm"); + + let lib_contract_class: CasmContractClass = serde_json::from_slice(lib_program_data).unwrap(); + + let lib_address = Address(1112.into()); + let lib_class_hash: ClassHash = [2; 32]; + let lib_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + lib_class_hash, + CompiledClass::Casm(Arc::new(lib_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(lib_address.clone(), lib_class_hash); + state_reader + .address_to_nonce_mut() + .insert(lib_address, lib_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + // Create an execution entry point + let calldata = [ + felt_str!("1125899906842624"), + Felt252::from_bytes_be(&lib_class_hash), + Felt252::from(50), + ] + .to_vec(); + let caller_address = Address(0000.into()); + let entry_point_type = EntryPointType::External; + + let exec_entry_point = ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(entrypoint_selector.clone()), + caller_address, + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u128::MAX, + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + let expected_execution_resources_internal_call = ExecutionResources { + #[cfg(not(feature = "cairo_1_tests"))] + n_steps: 80, + #[cfg(feature = "cairo_1_tests")] + n_steps: 85, + n_memory_holes: 5, + builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 7)]), + }; + + let call_info = exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + + assert_eq!(call_info.internal_calls.len(), 50); + assert_eq!( + call_info.internal_calls[0], + CallInfo { + caller_address: Address(0.into()), + call_type: Some(CallType::Delegate), + contract_address: Address(1111.into()), + entry_point_selector: Some( + Felt252::from_str_radix( + "544923964202674311881044083303061611121949089655923191939299897061511784662", + 10, + ) + .unwrap(), + ), + entry_point_type: Some(EntryPointType::External), + calldata: vec![felt_str!("1125899906842624")], + retdata: [felt_str!("33554432")].to_vec(), + execution_resources: Some(expected_execution_resources_internal_call), + class_hash: Some(lib_class_hash), + gas_consumed: 0, + ..Default::default() + } + ); + assert_eq!(call_info.retdata, [1.into()].to_vec()); + assert!(!call_info.failure_flag); +} + +#[test] +fn call_contract_storage_write_read_recursive_50_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( + "increase_balance_recursive".as_bytes(), + )); + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add simple_wallet contract to the state + #[cfg(not(feature = "cairo_1_tests"))] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); + #[cfg(feature = "cairo_1_tests")] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); + + let simple_wallet_contract_class: CasmContractClass = + serde_json::from_slice(simple_wallet_program_data).unwrap(); + let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class + .entry_points_by_type + .constructor + .get(0) + .unwrap() + .selector + .clone(); + + let simple_wallet_address = Address(1112.into()); + let simple_wallet_class_hash: ClassHash = [2; 32]; + let simple_wallet_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(simple_wallet_address.clone(), simple_wallet_class_hash); + state_reader + .address_to_nonce_mut() + .insert(simple_wallet_address.clone(), simple_wallet_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + + let mut resources_manager = ExecutionResourcesManager::default(); + + let create_execute_extrypoint = |selector: &BigUint, + calldata: Vec, + entry_point_type: EntryPointType, + class_hash: [u8; 32], + address: Address| + -> ExecutionEntryPoint { + ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(selector.clone()), + Address(0000.into()), + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u64::MAX.into(), + ) + }; + + // RUN SIMPLE_WALLET CONSTRUCTOR + // Create an execution entry point + let calldata = [25.into()].to_vec(); + let constructor_exec_entry_point = create_execute_extrypoint( + &simple_wallet_constructor_entrypoint_selector, + calldata, + EntryPointType::Constructor, + simple_wallet_class_hash, + simple_wallet_address.clone(), + ); + + // Run constructor entrypoint + constructor_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0.clone()].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); + + // RUN INCREASE_BALANCE + // Create an execution entry point + let calldata = [50.into(), simple_wallet_address.0.clone()].to_vec(); + let increase_balance_entry_point = create_execute_extrypoint( + increase_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run increase_balance entrypoint + let call_info = increase_balance_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + // Check that the recursive function did in fact call the simple_wallet contract 50 times + assert_eq!(call_info.internal_calls.len(), 50); + assert!(!call_info.failure_flag); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address, + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [75.into()]) +} + +#[test] +fn call_contract_storage_write_read_recursive_100_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( + "increase_balance_recursive".as_bytes(), + )); + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache + .set_contract_class(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add simple_wallet contract to the state + #[cfg(not(feature = "cairo_1_tests"))] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); + #[cfg(feature = "cairo_1_tests")] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); + + let simple_wallet_contract_class: CasmContractClass = + serde_json::from_slice(simple_wallet_program_data).unwrap(); + let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class + .entry_points_by_type + .constructor + .get(0) + .unwrap() + .selector + .clone(); + + let simple_wallet_address = Address(1112.into()); + let simple_wallet_class_hash: ClassHash = [2; 32]; + let simple_wallet_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(simple_wallet_address.clone(), simple_wallet_class_hash); + state_reader + .address_to_nonce_mut() + .insert(simple_wallet_address.clone(), simple_wallet_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + + let mut resources_manager = ExecutionResourcesManager::default(); + + let create_execute_extrypoint = |selector: &BigUint, + calldata: Vec, + entry_point_type: EntryPointType, + class_hash: [u8; 32], + address: Address| + -> ExecutionEntryPoint { + ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(selector.clone()), + Address(0000.into()), + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u64::MAX.into(), + ) + }; + + // RUN SIMPLE_WALLET CONSTRUCTOR + // Create an execution entry point + let calldata = [25.into()].to_vec(); + let constructor_exec_entry_point = create_execute_extrypoint( + &simple_wallet_constructor_entrypoint_selector, + calldata, + EntryPointType::Constructor, + simple_wallet_class_hash, + simple_wallet_address.clone(), + ); + + // Run constructor entrypoint + constructor_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0.clone()].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); + + // RUN INCREASE_BALANCE + // Create an execution entry point + let calldata = [100.into(), simple_wallet_address.0.clone()].to_vec(); + let increase_balance_entry_point = create_execute_extrypoint( + increase_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run increase_balance entrypoint + let call_info = increase_balance_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + // Check that the recursive function did in fact call the simple_wallet contract 50 times + assert_eq!(call_info.internal_calls.len(), 100); + assert!(!call_info.failure_flag); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address, + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) +} diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs new file mode 100644 index 000000000..dfa10b1de --- /dev/null +++ b/tests/cairo_native.rs @@ -0,0 +1,1001 @@ +#![cfg(all(feature = "cairo-native", not(feature = "cairo_1_tests")))] + +use crate::CallType::Call; +use cairo_lang_starknet::casm_contract_class::CasmContractEntryPoints; +use cairo_lang_starknet::contract_class::ContractEntryPoints; +use cairo_vm::felt::Felt252; +use num_bigint::BigUint; +use num_traits::One; +use num_traits::Zero; +use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +use starknet_in_rust::definitions::block_context::BlockContext; +use starknet_in_rust::execution::{Event, OrderedEvent}; +use starknet_in_rust::hash_utils::calculate_contract_address; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; +use starknet_in_rust::state::contract_class_cache::ContractClassCache; +use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; +use starknet_in_rust::CasmContractClass; +use starknet_in_rust::EntryPointType::{self, External}; +use starknet_in_rust::{ + definitions::constants::TRANSACTION_VERSION, + execution::{ + execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, + }, + state::cached_state::CachedState, + state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + utils::{Address, ClassHash}, +}; + +use std::collections::HashSet; +use std::sync::Arc; + +#[test] +fn integration_test_erc20() { + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/erc20.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + let casm_data = include_bytes!("../starknet_programs/cairo2/erc20.casm"); + let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + let native_entrypoints = sierra_contract_class.clone().entry_points_by_type; + let native_constructor_selector = &native_entrypoints.constructor.get(0).unwrap().selector; + + let casm_entrypoints = casm_contract_class.clone().entry_points_by_type; + let casm_constructor_selector = &casm_entrypoints.constructor.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + static NATIVE_CLASS_HASH: ClassHash = [1; 32]; + static CASM_CLASS_HASH: ClassHash = [2; 32]; + + let caller_address = Address(123456789.into()); + + contract_class_cache.set_contract_class( + NATIVE_CLASS_HASH, + CompiledClass::Sierra(Arc::new(sierra_contract_class)), + ); + contract_class_cache.set_contract_class( + CASM_CLASS_HASH, + CompiledClass::Casm(Arc::new(casm_contract_class)), + ); + let mut state_reader = InMemoryStateReader::default(); + let nonce = Felt252::zero(); + + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), CASM_CLASS_HASH); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let state_reader = Arc::new(state_reader); + let mut state_vm = + CachedState::new(state_reader.clone(), Arc::new(contract_class_cache.clone())); + let mut state_native = CachedState::new(state_reader, Arc::new(contract_class_cache)); + + /* + 1 recipient + 2 name + 3 decimals + 4 initial_supply + 5 symbol + */ + let calldata = [ + caller_address.0.clone(), + 2.into(), + 3.into(), + 4.into(), + 5.into(), + ] + .to_vec(); + + let vm_result = execute( + &mut state_vm, + &caller_address, + &caller_address, + casm_constructor_selector, + &calldata, + EntryPointType::Constructor, + &CASM_CLASS_HASH, + ); + + let native_result = execute( + &mut state_native, + &caller_address, + &caller_address, + native_constructor_selector, + &calldata, + EntryPointType::Constructor, + &NATIVE_CLASS_HASH, + ); + + assert_eq!(vm_result.caller_address, caller_address); + assert_eq!(vm_result.call_type, Some(CallType::Delegate)); + assert_eq!(vm_result.contract_address, caller_address); + assert_eq!( + vm_result.entry_point_selector, + Some(Felt252::new(casm_constructor_selector)) + ); + assert_eq!( + vm_result.entry_point_type, + Some(EntryPointType::Constructor) + ); + assert_eq!(vm_result.calldata, calldata); + assert!(!vm_result.failure_flag); + assert_eq!(vm_result.retdata, [].to_vec()); + assert_eq!(vm_result.class_hash, Some(CASM_CLASS_HASH)); + + assert_eq!(native_result.caller_address, caller_address); + assert_eq!(native_result.call_type, Some(CallType::Delegate)); + assert_eq!(native_result.contract_address, caller_address); + assert_eq!( + native_result.entry_point_selector, + Some(Felt252::new(native_constructor_selector)) + ); + assert_eq!( + native_result.entry_point_type, + Some(EntryPointType::Constructor) + ); + assert_eq!(native_result.calldata, calldata); + assert!(!native_result.failure_flag); + assert_eq!(native_result.retdata, [].to_vec()); + assert_eq!(native_result.execution_resources, None); + assert_eq!(native_result.class_hash, Some(NATIVE_CLASS_HASH)); + + assert_eq!(vm_result.events, native_result.events); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); + assert_eq!(vm_result.gas_consumed, native_result.gas_consumed); + + #[allow(clippy::too_many_arguments)] + fn compare_results( + state_vm: &mut CachedState, + state_native: &mut CachedState, + selector_idx: usize, + native_entrypoints: &ContractEntryPoints, + casm_entrypoints: &CasmContractEntryPoints, + calldata: &[Felt252], + caller_address: &Address, + debug_name: &str, + ) { + let native_selector = &native_entrypoints + .external + .get(selector_idx) + .unwrap() + .selector; + let casm_selector = &casm_entrypoints + .external + .get(selector_idx) + .unwrap() + .selector; + + let vm_result = execute( + state_vm, + caller_address, + caller_address, + casm_selector, + calldata, + EntryPointType::External, + &CASM_CLASS_HASH, + ); + + let native_result = execute( + state_native, + caller_address, + caller_address, + native_selector, + calldata, + EntryPointType::External, + &NATIVE_CLASS_HASH, + ); + + assert_eq!(vm_result.failure_flag, native_result.failure_flag); + assert_eq!(vm_result.retdata, native_result.retdata); + assert_eq!(vm_result.events, native_result.events); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); + + assert_eq!( + vm_result.gas_consumed, native_result.gas_consumed, + "gas consumed mismatch for {debug_name}", + ); + } + + // --------------- GET TOTAL SUPPLY ----------------- + + compare_results( + &mut state_vm, + &mut state_native, + 5, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get total supply 1", + ); + + // ---------------- GET DECIMALS ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 1, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get decimals 1", + ); + + // ---------------- GET NAME ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 6, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get name", + ); + + // // ---------------- GET SYMBOL ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 7, + &native_entrypoints, + &casm_entrypoints, + &[], + &caller_address, + "get symbol", + ); + + // ---------------- GET BALANCE OF CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone()], + &caller_address, + "get balance of caller", + ); + + // // ---------------- ALLOWANCE OF ADDRESS 1 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 3, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone(), 1.into()], + &caller_address, + "get allowance of address 1", + ); + + // // ---------------- INCREASE ALLOWANCE OF ADDRESS 1 by 10_000 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 2, + &native_entrypoints, + &casm_entrypoints, + &[1.into(), 10_000.into()], + &caller_address, + "increase allowance of address 1 by 10000", + ); + + // ---------------- ALLOWANCE OF ADDRESS 1 ---------------------- + + // Checking again because allowance changed with previous call. + compare_results( + &mut state_vm, + &mut state_native, + 3, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone(), 1.into()], + &caller_address, + "allowance of address 1 part 2", + ); + + // ---------------- APPROVE ADDRESS 1 TO MAKE TRANSFERS ON BEHALF OF THE CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 4, + &native_entrypoints, + &casm_entrypoints, + &[1.into(), 5000.into()], + &caller_address, + "approve address 1 to make transfers", + ); + + // ---------------- TRANSFER 3 TOKENS FROM CALLER TO ADDRESS 2 --------- + + compare_results( + &mut state_vm, + &mut state_native, + 0, + &native_entrypoints, + &casm_entrypoints, + &[2.into(), 3.into()], + &caller_address, + "transfer 3 tokens", + ); + + // // ---------------- GET BALANCE OF CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone()], + &caller_address, + "GET BALANCE OF CALLER", + ); + + // // ---------------- GET BALANCE OF ADDRESS 2 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[2.into()], + &caller_address, + "GET BALANCE OF ADDRESS 2", + ); + + // // ---------------- TRANSFER 1 TOKEN FROM CALLER TO ADDRESS 2, CALLED FROM ADDRESS 1 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 9, + &native_entrypoints, + &casm_entrypoints, + &[1.into(), 2.into(), 1.into()], + &caller_address, + "TRANSFER 1 TOKEN FROM CALLER TO ADDRESS 2, CALLED FROM ADDRESS 1", + ); + + // // ---------------- GET BALANCE OF ADDRESS 2 ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[2.into()], + &caller_address, + "GET BALANCE OF ADDRESS 2 part 2", + ); + + // // ---------------- GET BALANCE OF CALLER ---------------------- + + compare_results( + &mut state_vm, + &mut state_native, + 8, + &native_entrypoints, + &casm_entrypoints, + &[caller_address.0.clone()], + &caller_address, + "GET BALANCE OF CALLER last", + ); +} + +#[test] +fn call_contract_test() { + // Caller contract + let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/caller.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Callee contract + let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/callee.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Caller contract entrypoints + let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; + let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; + + // Callee contract entrypoints + let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; + let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Caller contract data + let caller_address = Address(1111.into()); + let caller_class_hash: ClassHash = [1; 32]; + let caller_nonce = Felt252::zero(); + + // Callee contract data + let callee_address = Address(1112.into()); + let callee_class_hash: ClassHash = [2; 32]; + let callee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + caller_class_hash, + CompiledClass::Sierra(Arc::new(caller_contract_class)), + ); + contract_class_cache.set_contract_class( + callee_class_hash, + CompiledClass::Sierra(Arc::new(callee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), caller_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), caller_nonce); + + // Insert callee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(callee_address.clone(), callee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(callee_address.clone(), callee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [fn_selector.into()].to_vec(); + let result = execute( + &mut state, + &caller_address, + &callee_address, + call_contract_selector, + &calldata, + EntryPointType::External, + &caller_class_hash, + ); + + assert_eq!(result.retdata, [Felt252::new(44)]); +} + +#[test] +fn call_echo_contract_test() { + // Caller contract + let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo_caller.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Callee contract + let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Caller contract entrypoints + let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; + let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; + + // Callee contract entrypoints + let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; + let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Caller contract data + let caller_address = Address(1111.into()); + let caller_class_hash: ClassHash = [1; 32]; + let caller_nonce = Felt252::zero(); + + // Callee contract data + let callee_address = Address(1112.into()); + let callee_class_hash: ClassHash = [2; 32]; + let callee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + caller_class_hash, + CompiledClass::Sierra(Arc::new(caller_contract_class)), + ); + + contract_class_cache.set_contract_class( + callee_class_hash, + CompiledClass::Sierra(Arc::new(callee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), caller_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), caller_nonce); + + // Insert callee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(callee_address.clone(), callee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(callee_address.clone(), callee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [fn_selector.into(), 99999999.into()].to_vec(); + let result = execute( + &mut state, + &caller_address, + &callee_address, + call_contract_selector, + &calldata, + EntryPointType::External, + &caller_class_hash, + ); + + assert_eq!(result.retdata, [Felt252::new(99999999)]); + assert_eq!(result.gas_consumed, 89110); +} + +#[test] +#[cfg(feature = "cairo-native")] +fn call_events_contract_test() { + // Caller contract + let caller_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/caller.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Callee contract + let callee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/event_emitter.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Caller contract entrypoints + let caller_entrypoints = caller_contract_class.clone().entry_points_by_type; + let call_contract_selector = &caller_entrypoints.external.get(0).unwrap().selector; + + // Event emmitter contract entrypoints + let callee_entrypoints = callee_contract_class.clone().entry_points_by_type; + let fn_selector = &callee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Caller contract data + let caller_address = Address(1111.into()); + let caller_class_hash: ClassHash = [1; 32]; + let caller_nonce = Felt252::zero(); + + // Callee contract data + let callee_address = Address(1112.into()); + let callee_class_hash: ClassHash = [2; 32]; + let callee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + caller_class_hash, + CompiledClass::Sierra(Arc::new(caller_contract_class)), + ); + + contract_class_cache.set_contract_class( + callee_class_hash, + CompiledClass::Sierra(Arc::new(callee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), caller_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), caller_nonce); + + // Insert callee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(callee_address.clone(), callee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(callee_address.clone(), callee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [fn_selector.into()].to_vec(); + let result = execute( + &mut state, + &caller_address, + &callee_address, + call_contract_selector, + &calldata, + EntryPointType::External, + &caller_class_hash, + ); + + let internal_call = CallInfo { + caller_address: Address(1111.into()), + call_type: Some(Call), + contract_address: Address(1112.into()), + code_address: None, + class_hash: Some([ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, + ]), + entry_point_selector: Some(fn_selector.into()), + entry_point_type: Some(External), + calldata: Vec::new(), + retdata: vec![1234.into()], + execution_resources: None, + events: vec![OrderedEvent { + order: 0, + keys: vec![110.into()], + data: vec![1.into()], + }], + l2_to_l1_messages: Vec::new(), + storage_read_values: Vec::new(), + accessed_storage_keys: HashSet::new(), + internal_calls: Vec::new(), + gas_consumed: 9640, + failure_flag: false, + }; + + let event = Event { + from_address: Address(1112.into()), + keys: vec![110.into()], + data: vec![1.into()], + }; + + assert_eq!(result.retdata, [1234.into()]); + assert_eq!(result.events, []); + assert_eq_sorted!(result.internal_calls, [internal_call]); + + let sorted_events = result.get_sorted_events().unwrap(); + assert_eq!(sorted_events, vec![event]); +} + +fn execute( + state: &mut CachedState, + caller_address: &Address, + callee_address: &Address, + selector: &BigUint, + calldata: &[Felt252], + entrypoint_type: EntryPointType, + class_hash: &ClassHash, +) -> CallInfo { + let exec_entry_point = ExecutionEntryPoint::new( + (*callee_address).clone(), + calldata.to_vec(), + Felt252::new(selector), + (*caller_address).clone(), + entrypoint_type, + Some(CallType::Delegate), + Some(*class_hash), + u64::MAX.into(), + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + exec_entry_point + .execute( + state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap() +} + +fn execute_deploy( + state: &mut CachedState, + caller_address: &Address, + selector: &BigUint, + calldata: &[Felt252], + entrypoint_type: EntryPointType, + class_hash: &ClassHash, +) -> CallInfo { + let exec_entry_point = ExecutionEntryPoint::new( + (*caller_address).clone(), + calldata.to_vec(), + Felt252::new(selector), + (*caller_address).clone(), + entrypoint_type, + Some(CallType::Delegate), + Some(*class_hash), + u64::MAX.into(), + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + exec_entry_point + .execute( + state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap() +} + +#[test] +#[cfg(feature = "cairo-native")] +fn deploy_syscall_test() { + // Deployer contract + + let deployer_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/deploy.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Deployee contract + let deployee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // deployer contract entrypoints + let deployer_entrypoints = deployer_contract_class.clone().entry_points_by_type; + let deploy_contract_selector = &deployer_entrypoints.external.get(0).unwrap().selector; + + // Echo contract entrypoints + let deployee_entrypoints = deployee_contract_class.clone().entry_points_by_type; + let _fn_selector = &deployee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Deployer contract data + let deployer_address = Address(1111.into()); + let deployer_class_hash: ClassHash = [1; 32]; + let deployer_nonce = Felt252::zero(); + + // Deployee contract data + let deployee_class_hash: ClassHash = Felt252::one().to_be_bytes(); + let _deployee_nonce = Felt252::zero(); + + contract_class_cache.set_contract_class( + deployer_class_hash, + CompiledClass::Sierra(Arc::new(deployer_contract_class)), + ); + + contract_class_cache.set_contract_class( + deployee_class_hash, + CompiledClass::Sierra(Arc::new(deployee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert deployer contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(deployer_address.clone(), deployer_class_hash); + state_reader + .address_to_nonce_mut() + .insert(deployer_address.clone(), deployer_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [Felt252::from_bytes_be(&deployee_class_hash), Felt252::one()].to_vec(); + let result = execute_deploy( + &mut state, + &deployer_address, + deploy_contract_selector, + &calldata, + EntryPointType::External, + &deployer_class_hash, + ); + let expected_deployed_contract_address = Address( + calculate_contract_address( + &Felt252::one(), + &Felt252::from_bytes_be(&deployee_class_hash), + &[100.into()], + deployer_address, + ) + .unwrap(), + ); + + assert_eq!(result.retdata, [expected_deployed_contract_address.0]); + assert_eq!(result.events, []); + assert_eq!(result.internal_calls.len(), 1); + + let sorted_events = result.get_sorted_events().unwrap(); + assert_eq!(sorted_events, vec![]); + assert_eq!(result.failure_flag, false) +} + +#[test] +#[cfg(feature = "cairo-native")] +fn deploy_syscall_address_unavailable_test() { + // Deployer contract + + use starknet_in_rust::utils::felt_to_hash; + let deployer_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/deploy.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Deployee contract + let deployee_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/echo.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // deployer contract entrypoints + let deployer_entrypoints = deployer_contract_class.clone().entry_points_by_type; + let deploy_contract_selector = &deployer_entrypoints.external.get(0).unwrap().selector; + + // Echo contract entrypoints + let deployee_entrypoints = deployee_contract_class.clone().entry_points_by_type; + let _fn_selector = &deployee_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let contract_class_cache = PermanentContractClassCache::default(); + + // Deployer contract data + let deployer_address = Address(1111.into()); + let deployer_class_hash: ClassHash = [2; 32]; + let deployer_nonce = Felt252::zero(); + + // Deployee contract data + let deployee_class_hash: ClassHash = felt_to_hash(&Felt252::one()); + let deployee_nonce = Felt252::zero(); + let expected_deployed_contract_address = Address( + calculate_contract_address( + &Felt252::one(), + &Felt252::from_bytes_be(&deployee_class_hash), + &[100.into()], + deployer_address.clone(), + ) + .unwrap(), + ); + // Insert contract to be deployed so that its address is taken + let deployee_address = expected_deployed_contract_address; + + contract_class_cache.set_contract_class( + deployer_class_hash, + CompiledClass::Sierra(Arc::new(deployer_contract_class)), + ); + + contract_class_cache.set_contract_class( + deployee_class_hash, + CompiledClass::Sierra(Arc::new(deployee_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert deployer contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(deployer_address.clone(), deployer_class_hash); + state_reader + .address_to_nonce_mut() + .insert(deployer_address.clone(), deployer_nonce); + + // Insert deployee contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(deployee_address.clone(), deployee_class_hash); + state_reader + .address_to_nonce_mut() + .insert(deployee_address.clone(), deployee_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); + + let calldata = [Felt252::from_bytes_be(&deployee_class_hash), Felt252::one()].to_vec(); + let result = execute_deploy( + &mut state, + &deployer_address, + deploy_contract_selector, + &calldata, + EntryPointType::External, + &deployer_class_hash, + ); + + assert_eq!( + std::str::from_utf8(&result.retdata[0].to_be_bytes()) + .unwrap() + .trim_start_matches('\0'), + "Result::unwrap failed." + ); + assert_eq!(result.events, []); + assert_eq!(result.failure_flag, true); + assert!(result.internal_calls.is_empty()); +} diff --git a/tests/complex_contracts/amm_contracts/amm.rs b/tests/complex_contracts/amm_contracts/amm.rs index 747ddca2c..98653cd58 100644 --- a/tests/complex_contracts/amm_contracts/amm.rs +++ b/tests/complex_contracts/amm_contracts/amm.rs @@ -95,14 +95,14 @@ fn amm_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 232, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 14), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: vec![Felt252::zero(), Felt252::zero()], @@ -184,14 +184,14 @@ fn amm_add_demo_tokens_test() { entry_point_selector: Some(add_demo_token_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata_add_demo_token.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 393, n_memory_holes: 44, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 20), (HASH_BUILTIN_NAME.to_string(), 8), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys: accessed_storage_keys_add_demo_token, storage_read_values: vec![ @@ -263,14 +263,14 @@ fn amm_get_pool_token_balance() { entry_point_selector: Some(get_pool_balance_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata_get_pool_token_balance.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 84, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 1), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys: accessed_storage_keys_get_pool_token_balance, storage_read_values: vec![10000.into()], @@ -358,14 +358,14 @@ fn amm_swap_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata_swap.clone(), retdata: expected_return, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 820, n_memory_holes: 95, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 41), (HASH_BUILTIN_NAME.to_string(), 14), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: [ @@ -608,14 +608,14 @@ fn amm_get_account_token_balance_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata_get_balance, retdata: expected_return, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 92, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: [10.into()].to_vec(), diff --git a/tests/complex_contracts/amm_contracts/amm_proxy.rs b/tests/complex_contracts/amm_contracts/amm_proxy.rs index df8978826..88da2bb2e 100644 --- a/tests/complex_contracts/amm_contracts/amm_proxy.rs +++ b/tests/complex_contracts/amm_contracts/amm_proxy.rs @@ -82,14 +82,14 @@ fn amm_proxy_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone()[1..].to_vec(), retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 232, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 14), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, storage_read_values: vec![Felt252::zero(), Felt252::zero()], @@ -104,14 +104,14 @@ fn amm_proxy_init_pool_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 280, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 14), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -190,14 +190,14 @@ fn amm_proxy_get_pool_token_balance_test() { calldata: calldata.clone()[1..].to_vec(), retdata: [555.into()].to_vec(), storage_read_values: [555.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 84, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 1), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -211,14 +211,14 @@ fn amm_proxy_get_pool_token_balance_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [555.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 140, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 1), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -304,14 +304,14 @@ fn amm_proxy_add_demo_token_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone()[1..].to_vec(), storage_read_values: vec![0.into(), 0.into(), 0.into(), 0.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 397, n_memory_holes: 42, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 8), ("range_check_builtin".to_string(), 20), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -324,14 +324,14 @@ fn amm_proxy_add_demo_token_test() { entry_point_selector: Some(amm_proxy_entrypoint_selector), entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 445, n_memory_holes: 42, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 8), ("range_check_builtin".to_string(), 20), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -429,14 +429,14 @@ fn amm_proxy_get_account_token_balance() { calldata: calldata.clone()[1..].to_vec(), retdata: [200.into()].to_vec(), storage_read_values: [200.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 92, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -450,14 +450,14 @@ fn amm_proxy_get_account_token_balance() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: [200.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 151, n_memory_holes: 11, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 2), ("range_check_builtin".to_string(), 3), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() @@ -572,14 +572,14 @@ fn amm_proxy_swap() { 1000.into(), ] .to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 826, n_memory_holes: 92, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 14), ("range_check_builtin".to_string(), 41), ]), - }, + }), class_hash: Some(contract_class_hash), accessed_storage_keys, ..Default::default() @@ -593,14 +593,14 @@ fn amm_proxy_swap() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 885, n_memory_holes: 92, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 14), ("range_check_builtin".to_string(), 41), ]), - }, + }), class_hash: Some(proxy_class_hash), internal_calls, ..Default::default() diff --git a/tests/complex_contracts/nft/erc721.rs b/tests/complex_contracts/nft/erc721.rs index 6ae4b4894..de1a8afed 100644 --- a/tests/complex_contracts/nft/erc721.rs +++ b/tests/complex_contracts/nft/erc721.rs @@ -143,14 +143,14 @@ fn erc721_balance_of_test() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 105, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 1), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, @@ -225,14 +225,14 @@ fn erc721_test_owner_of() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result.clone(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 116, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 5), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, @@ -324,14 +324,14 @@ fn erc721_test_get_approved() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 192, n_memory_holes: 20, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 8), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -426,14 +426,14 @@ fn erc721_test_is_approved_for_all() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 101, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -529,14 +529,14 @@ fn erc721_test_approve() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 332, n_memory_holes: 30, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 13), (HASH_BUILTIN_NAME.to_string(), 6), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -627,14 +627,14 @@ fn erc721_set_approval_for_all() { entry_point_type: Some(EntryPointType::External), calldata: calldata.clone(), retdata: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 154, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 3), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), class_hash: Some(class_hash), accessed_storage_keys, storage_read_values, @@ -777,14 +777,14 @@ fn erc721_transfer_from_test() { accessed_storage_keys, storage_read_values: expected_read_values, events: expected_events, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 1131, n_memory_holes: 117, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 53), (HASH_BUILTIN_NAME.to_string(), 16), ]), - }, + }), ..Default::default() }; @@ -868,14 +868,14 @@ fn erc721_transfer_from_and_get_owner_test() { class_hash: Some(class_hash), accessed_storage_keys, storage_read_values: expected_read_result, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 116, n_memory_holes: 10, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 5), (HASH_BUILTIN_NAME.to_string(), 2), ]), - }, + }), ..Default::default() }; diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index 842267831..f6330312c 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -103,7 +103,7 @@ fn internal_deploy_account() { ("n_steps", 3612), ("pedersen_builtin", 23), ("range_check_builtin", 83), - ("l1_gas_usage", 3672) + ("l1_gas_usage", 3060) ] .into_iter() .map(|(k, v)| (k.to_string(), v)) @@ -177,11 +177,11 @@ fn internal_deploy_account_cairo1() { let n_steps; #[cfg(not(feature = "cairo_1_tests"))] { - n_steps = 3948; + n_steps = 3921; } #[cfg(feature = "cairo_1_tests")] { - n_steps = 3952; + n_steps = 3937; } assert_eq!( @@ -195,7 +195,7 @@ fn internal_deploy_account_cairo1() { )), code_address: None, #[cfg(not(feature="cairo_1_tests"))] - gas_consumed: 16440, + gas_consumed: 15540, #[cfg(feature="cairo_1_tests")] gas_consumed: 16770, class_hash: Some([ @@ -212,12 +212,12 @@ fn internal_deploy_account_cairo1() { 2.into() ], retdata: vec![felt_str!("370462705988")], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature="cairo_1_tests"))] - n_steps: 152, + n_steps: 144, #[cfg(feature="cairo_1_tests")] n_steps: 155, - n_memory_holes: 17, + n_memory_holes: 2, builtin_instance_counter: [ ("range_check_builtin", 2), @@ -225,7 +225,7 @@ fn internal_deploy_account_cairo1() { .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), - }, + }), ..Default::default() }), @@ -242,14 +242,14 @@ fn internal_deploy_account_cairo1() { entry_point_selector: Some(felt_str!("1159040026212278395030414237414753050475174923702621880048416706425641521556")), entry_point_type: Some(EntryPointType::Constructor), #[cfg(not(feature="cairo_1_tests"))] - gas_consumed: 14240, + gas_consumed: 13840, #[cfg(feature="cairo_1_tests")] gas_consumed: 14350, calldata: vec![2.into()], accessed_storage_keys: keys, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature="cairo_1_tests"))] - n_steps: 92, + n_steps: 88, #[cfg(feature="cairo_1_tests")] n_steps: 93, n_memory_holes: 0, @@ -260,7 +260,7 @@ fn internal_deploy_account_cairo1() { .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), - }, + }), ..Default::default() }), None, @@ -270,7 +270,7 @@ fn internal_deploy_account_cairo1() { ("n_steps", n_steps), ("pedersen_builtin", 23), ("range_check_builtin", 87), - ("l1_gas_usage", 4896) + ("l1_gas_usage", 5508) ] .into_iter() .map(|(k, v)| (k.to_string(), v)) diff --git a/tests/fibonacci.rs b/tests/fibonacci.rs index abad548d8..90ef33054 100644 --- a/tests/fibonacci.rs +++ b/tests/fibonacci.rs @@ -117,10 +117,10 @@ fn integration_test() { calldata, retdata: [144.into()].to_vec(), class_hash: Some(class_hash), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 94, ..Default::default() - }, + }), ..Default::default() }; @@ -211,13 +211,13 @@ fn integration_test_cairo1() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [144.into()].to_vec(), - execution_resources: ExecutionResources { - n_steps: 418, + execution_resources: Some(ExecutionResources { + n_steps: 414, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 15)]), - }, + }), class_hash: Some(class_hash), - gas_consumed: 35220, + gas_consumed: 34820, ..Default::default() }; diff --git a/tests/increase_balance.rs b/tests/increase_balance.rs index c5910b321..6808f16de 100644 --- a/tests/increase_balance.rs +++ b/tests/increase_balance.rs @@ -123,10 +123,10 @@ fn hello_starknet_increase_balance() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 65, ..Default::default() - }, + }), class_hash: Some(class_hash), accessed_storage_keys: expected_accessed_storage_keys, storage_read_values: expected_storage_read_values, diff --git a/tests/internals.rs b/tests/internals.rs index 5a7443a92..e54d26240 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -406,10 +406,10 @@ fn expected_validate_call_info( // Entries **not** in blockifier. class_hash: Some(felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH)), call_type: Some(CallType::Call), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 13, ..Default::default() - }, + }), ..Default::default() } @@ -476,14 +476,14 @@ fn expected_fee_transfer_call_info( Felt252::zero(), Felt252::zero(), ], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 529, n_memory_holes: 57, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), ..Default::default() } } @@ -610,6 +610,20 @@ fn invoke_tx(calldata: Vec, max_fee: u128) -> InvokeFunction { .unwrap() } +fn invoke_tx_with_nonce(calldata: Vec, max_fee: u128, nonce: Felt252) -> InvokeFunction { + InvokeFunction::new( + TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), + EXECUTE_ENTRY_POINT_SELECTOR.clone(), + max_fee, + TRANSACTION_VERSION.clone(), + calldata, + vec![], + StarknetChainId::TestNet.to_felt(), + Some(nonce), + ) + .unwrap() +} + fn expected_fee_transfer_info(fee: u128) -> CallInfo { CallInfo { failure_flag: false, @@ -623,14 +637,14 @@ fn expected_fee_transfer_info(fee: u128) -> CallInfo { entry_point_type: Some(EntryPointType::External), calldata: vec![Felt252::from(4096), Felt252::from(fee), Felt252::zero()], retdata: vec![Felt252::from(1)], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), l2_to_l1_messages: vec![], internal_calls: vec![], events: vec![OrderedEvent { @@ -687,14 +701,14 @@ fn expected_fib_fee_transfer_info(fee: u128) -> CallInfo { entry_point_type: Some(EntryPointType::External), calldata: vec![Felt252::from(4096), Felt252::from(fee), Felt252::zero()], retdata: vec![Felt252::from(1)], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 21), ("pedersen_builtin".to_string(), 4), ]), - }, + }), l2_to_l1_messages: vec![], internal_calls: vec![], events: vec![OrderedEvent { @@ -708,13 +722,13 @@ fn expected_fib_fee_transfer_info(fee: u128) -> CallInfo { ], }], storage_read_values: vec![ - INITIAL_BALANCE.clone() - Felt252::from(1252), + INITIAL_BALANCE.clone() - Felt252::from(3700), Felt252::zero(), - INITIAL_BALANCE.clone() - Felt252::from(1252), + INITIAL_BALANCE.clone() - Felt252::from(3700), Felt252::zero(), - Felt252::from(1252), + Felt252::from(3700), Felt252::zero(), - Felt252::from(1252), + Felt252::from(3700), Felt252::zero(), ], accessed_storage_keys: HashSet::from([ @@ -757,7 +771,7 @@ fn declare_tx() -> Declare { fn declarev2_tx() -> DeclareV2 { #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/fibonacci.sierra"); + let program_data = include_bytes!("../starknet_programs/raw_contract_classes/fibonacci.sierra"); #[cfg(feature = "cairo_1_tests")] let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.sierra"); let sierra_contract_class: SierraContractClass = serde_json::from_slice(program_data).unwrap(); @@ -775,7 +789,7 @@ fn declarev2_tx() -> DeclareV2 { nonce: 0.into(), hash_value: 0.into(), compiled_class_hash: casm_class_hash, - sierra_contract_class, + sierra_contract_class: Some(sierra_contract_class), sierra_class_hash, casm_class: casm_class.into(), skip_execute: false, @@ -871,14 +885,14 @@ fn expected_declare_fee_transfer_info(fee: u128) -> CallInfo { ], ]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 525, n_memory_holes: 59, builtin_instance_counter: HashMap::from([ (RANGE_CHECK_BUILTIN_NAME.to_string(), 21), (HASH_BUILTIN_NAME.to_string(), 4), ]), - }, + }), ..Default::default() } } @@ -954,10 +968,10 @@ fn test_declare_tx() { entry_point_selector: Some(VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone()), entry_point_type: Some(EntryPointType::External), calldata: vec![TEST_EMPTY_CONTRACT_CLASS_HASH.clone()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 12, ..Default::default() - }, + }), ..Default::default() }), None, @@ -1034,7 +1048,7 @@ fn test_declarev2_tx() { ("n_steps".to_string(), 2715), ("range_check_builtin".to_string(), 63), ("pedersen_builtin".to_string(), 15), - ("l1_gas_usage".to_string(), 1224), + ("l1_gas_usage".to_string(), 3672), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); @@ -1055,10 +1069,10 @@ fn test_declarev2_tx() { entry_point_selector: Some(VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone()), entry_point_type: Some(EntryPointType::External), calldata: vec![contract_hash], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 12, ..Default::default() - }, + }), ..Default::default() }), None, @@ -1112,18 +1126,18 @@ fn expected_execute_call_info() -> CallInfo { internal_calls: vec![], contract_address: TEST_CONTRACT_ADDRESS.clone(), code_address: None, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 22, ..Default::default() - }, + }), ..Default::default() }], events: vec![], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 61, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 1)]), - }, + }), ..Default::default() } } @@ -1155,14 +1169,14 @@ fn expected_fib_execute_call_info() -> CallInfo { Felt252::from(0), ], retdata: vec![Felt252::from(42)], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 157, + n_steps: 153, #[cfg(feature = "cairo_1_tests")] n_steps: 160, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 4)]), - }, + }), l2_to_l1_messages: vec![], internal_calls: vec![CallInfo { caller_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), @@ -1178,17 +1192,17 @@ fn expected_fib_execute_call_info() -> CallInfo { contract_address: TEST_FIB_CONTRACT_ADDRESS.clone(), code_address: None, #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 4380, + gas_consumed: 3980, #[cfg(feature = "cairo_1_tests")] gas_consumed: 4710, - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 118, + n_steps: 114, #[cfg(feature = "cairo_1_tests")] n_steps: 121, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 3)]), - }, + }), ..Default::default() }], events: vec![], @@ -1214,11 +1228,11 @@ fn expected_validate_call_info_2() -> CallInfo { Felt252::from(1), Felt252::from(2), ], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 21, n_memory_holes: 0, builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 1)]), - }, + }), ..Default::default() } } @@ -1239,11 +1253,11 @@ fn expected_fib_validate_call_info_2() -> CallInfo { Felt252::from(0), Felt252::from(0), ], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 21, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 1)]), - }, + }), ..Default::default() } } @@ -1273,7 +1287,7 @@ fn expected_fib_transaction_execution_info( let n_steps; #[cfg(not(feature = "cairo_1_tests"))] { - n_steps = 4231; + n_steps = 4227; } #[cfg(feature = "cairo_1_tests")] { @@ -1281,7 +1295,7 @@ fn expected_fib_transaction_execution_info( } let resources = HashMap::from([ ("n_steps".to_string(), n_steps), - ("l1_gas_usage".to_string(), 4896), + ("l1_gas_usage".to_string(), 6732), ("pedersen_builtin".to_string(), 16), ("range_check_builtin".to_string(), 104), ]); @@ -1504,9 +1518,9 @@ fn test_invoke_with_declarev2_tx() { Felt252::from(0), // b Felt252::from(0), // n ]; - let invoke_tx = invoke_tx(calldata, u128::MAX); + let invoke_tx = invoke_tx_with_nonce(calldata, u128::MAX, Felt252::one()); - let expected_gas_consumed = 4908; + let expected_gas_consumed = 5551; let result = invoke_tx .execute(state, block_context, expected_gas_consumed) .unwrap(); @@ -1519,7 +1533,7 @@ fn test_invoke_with_declarev2_tx() { fn test_deploy_account() { let (block_context, mut state) = create_account_tx_test_state().unwrap(); - let expected_fee = 3709; + let expected_fee = 3097; let deploy_account_tx = DeployAccount::new( felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH), @@ -1597,7 +1611,7 @@ fn test_deploy_account() { ("n_steps".to_string(), 3625), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), - ("l1_gas_usage".to_string(), 3672), + ("l1_gas_usage".to_string(), 3060), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); @@ -1744,12 +1758,12 @@ fn test_deploy_account_revert() { ("n_steps".to_string(), 3625), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), - ("l1_gas_usage".to_string(), 3672), + ("l1_gas_usage".to_string(), 3060), ]); let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); - assert_eq!(fee, 3709); + assert_eq!(fee, 3097); let mut expected_execution_info = TransactionExecutionInfo::new( None, @@ -1787,7 +1801,7 @@ fn expected_deploy_account_states() -> ( CachedState, CachedState, ) { - let fee = Felt252::from(3709); + let fee = Felt252::from(3097); let mut state_before = CachedState::new( Arc::new(InMemoryStateReader::new( HashMap::from([ @@ -1838,7 +1852,7 @@ fn expected_deploy_account_states() -> ( INITIAL_BALANCE.clone(), ); - let mut state_after = state_before.clone(); + let mut state_after = state_before.clone_for_testing(); // Make the contract cache independent (otherwise tests will fail because the initial state's // cache will not be empty anymore). @@ -2335,19 +2349,19 @@ fn test_library_call_with_declare_v2() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 30080, + gas_consumed: 29680, #[cfg(feature = "cairo_1_tests")] gas_consumed: 30410, calldata: vec![1.into(), 1.into(), 10.into()], retdata: vec![89.into()], // fib(10) - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 368, + n_steps: 364, #[cfg(feature = "cairo_1_tests")] n_steps: 371, n_memory_holes: 0, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 13)]), - }, + }), ..Default::default() }; @@ -2359,19 +2373,19 @@ fn test_library_call_with_declare_v2() { entry_point_selector: Some(external_entrypoint_selector.into()), entry_point_type: Some(EntryPointType::External), #[cfg(not(feature = "cairo_1_tests"))] - gas_consumed: 112490, + gas_consumed: 111690, #[cfg(feature = "cairo_1_tests")] gas_consumed: 113480, calldata, retdata: vec![89.into()], // fib(10) - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 578, + n_steps: 570, #[cfg(feature = "cairo_1_tests")] n_steps: 587, n_memory_holes: 1, builtin_instance_counter: HashMap::from([("range_check_builtin".to_string(), 16)]), - }, + }), internal_calls: vec![expected_internal_call_info], ..Default::default() }; diff --git a/tests/storage.rs b/tests/storage.rs index 22b87180d..73a092b17 100644 --- a/tests/storage.rs +++ b/tests/storage.rs @@ -120,10 +120,10 @@ fn integration_storage_test() { entry_point_type: Some(EntryPointType::External), calldata, retdata: [42.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 68, ..Default::default() - }, + }), class_hash: Some(class_hash), storage_read_values: vec![0.into(), 42.into()], accessed_storage_keys: expected_accessed_storage_keys, diff --git a/tests/syscalls.rs b/tests/syscalls.rs index 4e96b104f..e60ecca52 100644 --- a/tests/syscalls.rs +++ b/tests/syscalls.rs @@ -175,7 +175,7 @@ fn test_contract<'a>( assert_eq!(result.calldata, calldata); assert_eq_sorted!(result.retdata, return_data.into()); assert_eq_sorted!(result.internal_calls, internal_calls.into()); - assert_eq!(result.execution_resources, execution_resources); + assert_eq!(result.execution_resources, Some(execution_resources)); assert_eq!(result.gas_consumed, 0); assert!(!result.failure_flag); @@ -217,10 +217,10 @@ fn call_contract_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![21.into(), 2.into()], retdata: vec![42.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 24, ..Default::default() - }, + }), ..Default::default() }, CallInfo { @@ -239,10 +239,10 @@ fn call_contract_syscall() { ]] .into_iter() .collect(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 63, ..Default::default() - }, + }), ..Default::default() }, CallInfo { @@ -256,10 +256,10 @@ fn call_contract_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![], retdata: vec![2222.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 26, ..Default::default() - }, + }), ..Default::default() }, ], @@ -709,11 +709,11 @@ fn library_call_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![21.into(), 2.into()], retdata: vec![42.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 24, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }, + }), ..Default::default() }, CallInfo { @@ -732,11 +732,11 @@ fn library_call_syscall() { ]] .into_iter() .collect(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 63, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }, + }), ..Default::default() }, CallInfo { @@ -750,11 +750,11 @@ fn library_call_syscall() { entry_point_type: Some(EntryPointType::External), calldata: vec![], retdata: vec![1111.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 26, n_memory_holes: 0, builtin_instance_counter: HashMap::default(), - }, + }), ..Default::default() }, ], @@ -804,10 +804,10 @@ fn library_call_l1_handler_syscall() { .into_iter() .collect(), storage_read_values: vec![0.into()], - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, ..Default::default() - }, + }), ..Default::default() }], [], @@ -949,11 +949,11 @@ fn deploy_with_constructor_syscall() { entry_point_selector: Some(entry_point_selector), entry_point_type: Some(EntryPointType::Constructor), calldata: [550.into()].to_vec(), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, n_memory_holes: 0, ..Default::default() - }, + }), accessed_storage_keys: HashSet::<[u8; 32]>::from([[ 2, 63, 76, 85, 114, 157, 43, 172, 36, 175, 107, 126, 158, 121, 114, 77, 194, 27, 162, 147, 169, 199, 107, 53, 94, 246, 206, 221, 169, 114, 215, 255, @@ -1030,10 +1030,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![], storage_read_values: vec![0.into()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, ..Default::default() - }, + }), ..Default::default() }, // Invoke storage_var_and_constructor.cairo mult_constant function @@ -1055,10 +1055,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![(constructor_constant.clone() * Felt252::new(4))], storage_read_values: vec![constructor_constant.clone()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 52, ..Default::default() - }, + }), ..Default::default() }, // Invoke storage_var_and_constructor.cairo set_constant function @@ -1080,10 +1080,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![], storage_read_values: vec![constructor_constant], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 40, ..Default::default() - }, + }), ..Default::default() }, // Invoke storage_var_and_constructor.cairo get_constant function @@ -1105,10 +1105,10 @@ fn test_deploy_and_call_contract_syscall() { retdata: vec![new_constant.clone()], storage_read_values: vec![new_constant.clone()], accessed_storage_keys: HashSet::from([constant_storage_key]), - execution_resources: ExecutionResources { + execution_resources: Some(ExecutionResources { n_steps: 46, ..Default::default() - }, + }), ..Default::default() } ], @@ -1219,6 +1219,7 @@ fn deploy_cairo1_from_cairo0_with_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1323,6 +1324,7 @@ fn deploy_cairo1_from_cairo0_without_constructor() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); @@ -1425,6 +1427,7 @@ fn deploy_cairo1_and_invoke() { let ret_casm_class = match state.get_contract_class(&ret_class_hash).unwrap() { CompiledClass::Casm(class) => class.as_ref().clone(), CompiledClass::Deprecated(_) => unreachable!(), + CompiledClass::Sierra(_) => unreachable!(), }; assert_eq!(ret_casm_class, test_contract_class); From 967ae8f1caee8be115ab9d4f9cff8b2ff8f27a53 Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 14 Nov 2023 11:57:53 -0300 Subject: [PATCH 49/56] Merge --- Cargo.lock | 36 +- Cargo.toml | 12 +- Makefile | 4 +- README.md | 35 +- bench/internals.rs | 2 +- bench/native_bench.rs | 565 +++++ cairo_programs/constants.cairo | 2 + cli/src/main.rs | 2 +- examples/contract_execution/Cargo.toml | 14 + examples/contract_execution/README.md | 9 +- .../contract_execution/example_contract.cairo | 32 - .../contract_execution/execute_contract.rs | 136 -- examples/contract_execution/src/main.rs | 265 +++ rpc_state_reader/Cargo.toml | 2 +- rpc_state_reader/src/lib.rs | 125 +- rpc_state_reader/src/rpc_state.rs | 292 ++- rpc_state_reader/src/rpc_state_errors.rs | 21 + rpc_state_reader/tests/blockifier_tests.rs | 17 +- rpc_state_reader/tests/sir_tests.rs | 86 +- src/definitions/constants.rs | 30 +- src/execution/execution_entry_point.rs | 225 +- src/execution/mod.rs | 6 +- src/execution/os_usage.rs | 16 +- src/lib.rs | 7 +- .../api/contract_classes/compiled_class.rs | 3 +- src/state/mod.rs | 25 +- src/state/state_api.rs | 27 +- .../business_logic_syscall_handler.rs | 7 +- ...precated_business_logic_syscall_handler.rs | 2 +- src/syscalls/deprecated_syscall_handler.rs | 2 +- src/syscalls/native_syscall_handler.rs | 258 ++- src/syscalls/syscall_info.rs | 1 + src/transaction/declare.rs | 345 +-- src/transaction/declare_v2.rs | 171 +- src/transaction/deploy_account.rs | 170 +- src/transaction/error.rs | 9 + src/transaction/fee.rs | 7 +- src/transaction/invoke_function.rs | 157 +- src/transaction/l1_handler.rs | 19 +- src/transaction/mod.rs | 20 +- ...validation_and_expensive_constructor.cairo | 86 + .../cairo2/example_contract.cairo | 32 + starknet_programs/cairo2/factorial_tr.cairo | 26 + .../cairo2/get_block_hash_basic.cairo | 19 + .../test_cairo_keccak.cairo | 0 starknet_programs/deployer.cairo | 49 + .../keccak/test_cairo_keccak.casm | 2033 ----------------- .../keccak/test_cairo_keccak.sierra | 943 -------- tests/account_panic.rs | 2 +- tests/cairo_1_syscalls.rs | 545 ++++- tests/cairo_native.rs | 902 +++++++- tests/deploy_account.rs | 22 +- tests/internals.rs | 146 +- 53 files changed, 4098 insertions(+), 3871 deletions(-) create mode 100644 bench/native_bench.rs create mode 100644 examples/contract_execution/Cargo.toml delete mode 100644 examples/contract_execution/example_contract.cairo delete mode 100644 examples/contract_execution/execute_contract.rs create mode 100644 examples/contract_execution/src/main.rs create mode 100644 rpc_state_reader/src/rpc_state_errors.rs create mode 100644 starknet_programs/account_without_validation_and_expensive_constructor.cairo create mode 100644 starknet_programs/cairo2/example_contract.cairo create mode 100644 starknet_programs/cairo2/factorial_tr.cairo create mode 100644 starknet_programs/cairo2/get_block_hash_basic.cairo rename starknet_programs/{keccak => cairo2}/test_cairo_keccak.cairo (100%) create mode 100644 starknet_programs/deployer.cairo delete mode 100644 starknet_programs/keccak/test_cairo_keccak.casm delete mode 100644 starknet_programs/keccak/test_cairo_keccak.sierra diff --git a/Cargo.lock b/Cargo.lock index 6d46e8782..720b376f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1320,7 +1320,7 @@ dependencies = [ [[package]] name = "cairo-native" version = "0.1.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" +source = "git+https://github.com/lambdaclass/cairo_native?rev=4012a10b97530e208b76d42169aa9608a6a9d8fd#4012a10b97530e208b76d42169aa9608a6a9d8fd" dependencies = [ "bumpalo", "cairo-felt", @@ -1355,7 +1355,7 @@ dependencies = [ [[package]] name = "cairo-native-runtime" version = "0.1.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=03cd09ba3e51852da2234fb32a74056787abba8e#03cd09ba3e51852da2234fb32a74056787abba8e" +source = "git+https://github.com/lambdaclass/cairo_native?rev=4012a10b97530e208b76d42169aa9608a6a9d8fd#4012a10b97530e208b76d42169aa9608a6a9d8fd" dependencies = [ "cairo-felt", "cairo-lang-runner", @@ -1573,6 +1573,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" +[[package]] +name = "contract_execution" +version = "0.4.0" +dependencies = [ + "cairo-vm", + "serde_json", + "starknet_in_rust", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -1884,9 +1893,18 @@ dependencies = [ [[package]] name = "deunicode" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" +checksum = "71dbf1bf89c23e9cd1baf5e654f622872655f195b36588dc9dc38f7eda30758c" +dependencies = [ + "deunicode 1.4.1", +] + +[[package]] +name = "deunicode" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1abaf4d861455be59f64fd2b55606cb151fce304ede7165f410243ce96bde6" [[package]] name = "diff" @@ -3318,9 +3336,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "plist" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" +checksum = "9a4a0cfc5fb21a09dc6af4bf834cf10d4a32fccd9e2ea468c4b1751a097487aa" dependencies = [ "base64 0.21.4", "indexmap 1.9.3", @@ -3458,9 +3476,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" dependencies = [ "memchr", ] @@ -4127,7 +4145,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" dependencies = [ - "deunicode", + "deunicode 0.4.5", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c4b08bf43..4ed36458f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ cairo_1_tests = [] metrics = [] [workspace] -members = ["cli", "fuzzer", "rpc_state_reader"] +members = ["cli", "fuzzer", "rpc_state_reader", "examples/contract_execution"] [workspace.dependencies] cairo-lang-casm = "2.2.0" @@ -34,8 +34,8 @@ cairo-lang-runner = { workspace = true } cairo-lang-sierra = { workspace = true } cairo-lang-starknet = { workspace = true } cairo-lang-utils = { workspace = true } -cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "03cd09ba3e51852da2234fb32a74056787abba8e", optional = true } -cairo-vm = { workspace = true, features = ["cairo-1-hints"] } +cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "4012a10b97530e208b76d42169aa9608a6a9d8fd", optional = true } +cairo-vm = { workspace = true } flate2 = "1.0.25" getset = "0.1.2" hex = "0.4.3" @@ -71,3 +71,9 @@ tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } path = "bench/internals.rs" name = "internals" harness = false + +[[bin]] +path = "bench/native_bench.rs" +name = "cairo_native" +required-features = ["cairo-native"] +harness = false diff --git a/Makefile b/Makefile index 61183ab26..0c5875ac8 100644 --- a/Makefile +++ b/Makefile @@ -202,10 +202,10 @@ test: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra $(MAKE) test-cairo-2 test-cairo-1: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra - cargo nextest run --workspace --all-targets --features=cairo_1_tests,metrics + cargo nextest run --workspace --all-targets --features=cairo_1_tests,metrics,cairo-native test-cairo-2: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra - cargo nextest run --workspace --all-targets --features=metrics + cargo nextest run --workspace --all-targets --features=metrics,cairo-native test-cairo-native: compile-cairo compile-starknet compile-cairo-1-casm compile-cairo-1-sierra compile-cairo-2-casm compile-cairo-2-sierra cargo nextest run --workspace --test cairo_native --features=cairo-native diff --git a/README.md b/README.md index 43ce64184..f1d176bd7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Starknet transaction execution library in Rust, featuring [âš¡cairo-vmâš¡](https - [How to manually install the script dependencies](#how-to-manually-install-the-script-dependencies) - [🚀 Usage](#-usage) - [Running simple contracts](#running-simple-contracts) - - [Using the Cli](#using-the-cli) + - [Using the CLI](#using-the-cli) - [Testing](#testing) - [Profiling](#profiling) - [Benchmarking](#benchmarking) @@ -74,14 +74,6 @@ $ make build Check the [Makefile](/Makefile) for additional targets. -#### RPC State Reader - -In order to use the RPC state reader add an Infura API key in a `.env` file at root: - -``` -INFURA_API_KEY={some_key} -``` - #### How to manually install the script dependencies `cairo-lang` requires the `gmp` library to build. @@ -173,12 +165,35 @@ its documentation for more information. ### Testing -[Add an Infura API key.](#rpc-state-reader) +#### Logging configuration + +This project uses the [`tracing`](https://crates.io/crates/tracing) crate as a library. Check out +its documentation for more information. + +### Testing Run the following command: ```bash $ make test ``` +Take into account that some tests use the [RPC State Reader](#rpc-state-reader) so you need a full-node instance or an Infura API key. + + +### RPC State Reader + +[The RPC State Reader](/rpc_state_reader/) provides a way of reading the real Starknet State when using Starknet in Rust. +So you can re-execute an existing transaction in any of the Starknet networks in an easy way, just providing the transaction hash, the block number and the network in which the transaction was executed. +Every time it needs to read a storage value, a contract class or contract, it goes to an RPC to fetch them. + +Right now we are using it for internal testing but we plan to release it as a library soon. + +#### How to configure it +In order to use the RPC state reader add an Infura API key in a `.env` file at root: + +``` +INFURA_API_KEY={some_key} +``` + ### Profiling diff --git a/bench/internals.rs b/bench/internals.rs index bc64f8075..7b0df24b7 100644 --- a/bench/internals.rs +++ b/bench/internals.rs @@ -89,7 +89,7 @@ fn deploy_account() { let internal_deploy_account = DeployAccount::new( class_hash, 0, - 0.into(), + 1.into(), Felt252::zero(), vec![], signature, diff --git a/bench/native_bench.rs b/bench/native_bench.rs new file mode 100644 index 000000000..d01e4a936 --- /dev/null +++ b/bench/native_bench.rs @@ -0,0 +1,565 @@ +// Usage: +// For executing the binary with cairo native you can run it like: +// $ native_bench native +// otherwise it will run it using the Cairo VM +// native_bench +// You can also choose which benchmark to run by passing the name of the benchmark as the third argument: +// $ native_bench native +// where fibo executes a fibonacci function and fact a factorial n times. + +#![cfg(feature = "cairo-native")] + +#[cfg(not(feature = "cairo-native"))] +fn main() { + unimplemented!("This program should be compiled with the cairo-native feature"); +} + +use cairo_native::cache::ProgramCache; +use cairo_native::context::NativeContext; +use cairo_vm::felt::felt_str; +use cairo_vm::felt::Felt252; +use lazy_static::lazy_static; +use num_traits::Zero; +use starknet_in_rust::definitions::block_context::BlockContext; +use starknet_in_rust::definitions::block_context::StarknetChainId; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; +use starknet_in_rust::state::state_api::State; +use starknet_in_rust::transaction::DeployAccount; +use starknet_in_rust::utils::calculate_sn_keccak; +use starknet_in_rust::CasmContractClass; +use starknet_in_rust::EntryPointType; +use starknet_in_rust::{ + definitions::constants::TRANSACTION_VERSION, + execution::{ + execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, TransactionExecutionContext, + }, + state::cached_state::CachedState, + state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, + utils::{Address, ClassHash}, +}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; +use std::sync::Arc; + +pub fn main() { + let args: Vec = std::env::args().collect(); + match args.get(3).map(|s| s.as_str()) { + Some("fibo") => bench_fibo( + args.get(1) + .and_then(|x| x.parse::().ok()) + .unwrap_or(1), + args.get(2) == Some(&"native".to_string()), + ), + Some("fact") => bench_fact( + args.get(1) + .and_then(|x| x.parse::().ok()) + .unwrap_or(1), + args.get(2) == Some(&"native".to_string()), + ), + _ => bench_erc20( + args.get(1) + .and_then(|x| x.parse::().ok()) + .unwrap_or(1), + args.get(2) == Some(&"native".to_string()), + ), + } +} + +fn bench_fibo(executions: usize, native: bool) { + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + static CASM_CLASS_HASH: ClassHash = [2; 32]; + + let (contract_class, constructor_selector) = match native { + true => { + let sierra_data = include_bytes!("../starknet_programs/cairo2/fibonacci.sierra"); + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_slice(sierra_data).unwrap(); + + let entrypoints = sierra_contract_class.clone().entry_points_by_type; + let constructor_selector = entrypoints.external.get(0).unwrap().selector.clone(); + let sierra_program = sierra_contract_class.extract_sierra_program().unwrap(); + let entrypoints = sierra_contract_class.entry_points_by_type; + ( + CompiledClass::Sierra(Arc::new((sierra_program, entrypoints))), + constructor_selector, + ) + } + false => { + let casm_data = include_bytes!("../starknet_programs/cairo2/fibonacci.casm"); + let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + let entrypoints = casm_contract_class.clone().entry_points_by_type; + let constructor_selector = entrypoints.external.get(0).unwrap().selector.clone(); + + ( + CompiledClass::Casm(Arc::new(casm_contract_class)), + constructor_selector, + ) + } + }; + + let caller_address = Address(123456789.into()); + + contract_class_cache.insert(CASM_CLASS_HASH, contract_class); + let mut state_reader = InMemoryStateReader::default(); + let nonce = Felt252::zero(); + + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), CASM_CLASS_HASH); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let state_reader = Arc::new(state_reader); + let state = CachedState::new(state_reader, contract_class_cache); + + /* f0, f1, N */ + let mut calldata = [1.into(), 1.into(), 2000000.into()]; + + let native_ctx = NativeContext::new(); + let program_cache = Rc::new(RefCell::new(ProgramCache::new(&native_ctx))); + + for _ in 0..executions { + calldata[2] = &calldata[2] + 1usize; + let result = execute( + &mut state.clone(), + &caller_address, + &caller_address, + &Felt252::new(constructor_selector.clone()), + &calldata, + EntryPointType::External, + &CASM_CLASS_HASH, + program_cache.clone(), + ); + + _ = std::hint::black_box(result); + } +} + +fn bench_fact(executions: usize, native: bool) { + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + static CASM_CLASS_HASH: ClassHash = [2; 32]; + + let (contract_class, constructor_selector) = match native { + true => { + let sierra_data = include_bytes!("../starknet_programs/cairo2/factorial_tr.sierra"); + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_slice(sierra_data).unwrap(); + + let entrypoints = sierra_contract_class.clone().entry_points_by_type; + let constructor_selector = entrypoints.external.get(0).unwrap().selector.clone(); + let sierra_program = sierra_contract_class.extract_sierra_program().unwrap(); + let entrypoints = sierra_contract_class.entry_points_by_type; + ( + CompiledClass::Sierra(Arc::new((sierra_program, entrypoints))), + constructor_selector, + ) + } + false => { + let casm_data = include_bytes!("../starknet_programs/cairo2/factorial_tr.casm"); + let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + let entrypoints = casm_contract_class.clone().entry_points_by_type; + let constructor_selector = entrypoints.external.get(0).unwrap().selector.clone(); + + ( + CompiledClass::Casm(Arc::new(casm_contract_class)), + constructor_selector, + ) + } + }; + + let caller_address = Address(123456789.into()); + // FACT 1M + // FIBO 2M + + contract_class_cache.insert(CASM_CLASS_HASH, contract_class); + let mut state_reader = InMemoryStateReader::default(); + let nonce = Felt252::zero(); + + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), CASM_CLASS_HASH); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let state_reader = Arc::new(state_reader); + let state = CachedState::new(state_reader, contract_class_cache); + + /* N */ + let mut calldata = [2000000.into()]; + + let native_ctx = NativeContext::new(); + let program_cache = Rc::new(RefCell::new(ProgramCache::new(&native_ctx))); + + for _ in 0..executions { + calldata[0] = &calldata[0] + 1usize; + let result = execute( + &mut state.clone(), + &caller_address, + &caller_address, + &Felt252::new(constructor_selector.clone()), + &calldata, + EntryPointType::External, + &CASM_CLASS_HASH, + program_cache.clone(), + ); + + _ = std::hint::black_box(result); + } +} + +fn bench_erc20(executions: usize, native: bool) { + // 1. setup ERC20 contract and state. + // Create state reader and preload the contract classes. + let mut contract_class_cache = HashMap::new(); + + lazy_static! { + static ref ERC20_CLASS_HASH: ClassHash = felt_str!("2").to_be_bytes(); + static ref DEPLOYER_CLASS_HASH: ClassHash = felt_str!("10").to_be_bytes(); + static ref ACCOUNT1_CLASS_HASH: ClassHash = felt_str!("1").to_be_bytes(); + static ref DEPLOYER_ADDRESS: Address = Address(1111.into()); + static ref ERC20_NAME: Felt252 = Felt252::from_bytes_be(b"be"); + static ref ERC20_SYMBOL: Felt252 = Felt252::from_bytes_be(b"be"); + static ref ERC20_DECIMALS: Felt252 = Felt252::from(24); + static ref ERC20_INITIAL_SUPPLY: Felt252 = Felt252::from(1_000_000); + static ref ERC20_RECIPIENT: Felt252 = felt_str!("111"); + static ref ERC20_SALT: Felt252 = felt_str!("1234"); + static ref ERC20_DEPLOYER_CALLDATA: [Felt252; 7] = [ + Felt252::from_bytes_be(&ERC20_CLASS_HASH.clone()), + ERC20_SALT.clone(), + ERC20_RECIPIENT.clone(), + ERC20_NAME.clone(), + ERC20_DECIMALS.clone(), + ERC20_INITIAL_SUPPLY.clone(), + ERC20_SYMBOL.clone(), + ]; + static ref ERC20_DEPLOYMENT_CALLER_ADDRESS: Address = Address(0000.into()); + } + + let (erc20_address, mut state): (Address, CachedState) = match native { + true => { + let erc20_sierra_class = include_bytes!("../starknet_programs/cairo2/erc20.sierra"); + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_slice(erc20_sierra_class).unwrap(); + let sierra_program = sierra_contract_class.extract_sierra_program().unwrap(); + let entrypoints = sierra_contract_class.entry_points_by_type; + let erc20_contract_class = + CompiledClass::Sierra(Arc::new((sierra_program, entrypoints))); + + // we also need to read the contract class of the deployERC20 contract. + // this contract is used as a deployer of the erc20. + let erc20_deployer_code = + include_bytes!("../starknet_programs/cairo2/deploy_erc20.casm"); + let erc20_deployer_class: CasmContractClass = + serde_json::from_slice(erc20_deployer_code).unwrap(); + let entrypoints = erc20_deployer_class.clone().entry_points_by_type; + let deploy_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + + // insert deployer and erc20 classes into the cache. + contract_class_cache.insert( + *DEPLOYER_CLASS_HASH, + CompiledClass::Casm(Arc::new(erc20_deployer_class)), + ); + contract_class_cache.insert(*ERC20_CLASS_HASH, erc20_contract_class); + + let mut state_reader = InMemoryStateReader::default(); + // setup deployer nonce and address into the state reader + state_reader + .address_to_class_hash_mut() + .insert(DEPLOYER_ADDRESS.clone(), *DEPLOYER_CLASS_HASH); + state_reader + .address_to_nonce_mut() + .insert(DEPLOYER_ADDRESS.clone(), Felt252::zero()); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + // deploy the erc20 contract by calling the deployer contract. + + let exec_entry_point = ExecutionEntryPoint::new( + DEPLOYER_ADDRESS.clone(), + ERC20_DEPLOYER_CALLDATA.to_vec(), + Felt252::new(deploy_entrypoint_selector.clone()), + ERC20_DEPLOYMENT_CALLER_ADDRESS.clone(), + EntryPointType::External, + Some(CallType::Delegate), + Some(*DEPLOYER_CLASS_HASH), + 100_000_000_000, + ); + + // create required structures for execution + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + 1.into(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + // execute the deployment + let call_info = exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // obtain the address of the deployed erc20 contract + let erc20_address = call_info.call_info.unwrap().retdata.get(0).unwrap().clone(); + + (Address(erc20_address), state) + } + false => { + // read the ERC20 contract class + let erc20_casm_class = include_bytes!("../starknet_programs/cairo2/erc20.casm"); + let casm_contract_class: CasmContractClass = + serde_json::from_slice(erc20_casm_class).unwrap(); + let erc20_contract_class = CompiledClass::Casm(Arc::new(casm_contract_class)); + + // we also need to read the contract class of the deployERC20 contract. + // this contract is used as a deployer of the erc20. + let erc20_deployer_code = + include_bytes!("../starknet_programs/cairo2/deploy_erc20.casm"); + let erc20_deployer_class: CasmContractClass = + serde_json::from_slice(erc20_deployer_code).unwrap(); + let entrypoints = erc20_deployer_class.clone().entry_points_by_type; + let deploy_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + + // insert deployer and erc20 classes into the cache. + contract_class_cache.insert( + *DEPLOYER_CLASS_HASH, + CompiledClass::Casm(Arc::new(erc20_deployer_class)), + ); + contract_class_cache.insert(*ERC20_CLASS_HASH, erc20_contract_class); + + let mut state_reader = InMemoryStateReader::default(); + // setup deployer nonce and address into the state reader + state_reader + .address_to_class_hash_mut() + .insert(DEPLOYER_ADDRESS.clone(), *DEPLOYER_CLASS_HASH); + state_reader + .address_to_nonce_mut() + .insert(DEPLOYER_ADDRESS.clone(), Felt252::zero()); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + // deploy the erc20 contract by calling the deployer contract. + + let exec_entry_point = ExecutionEntryPoint::new( + DEPLOYER_ADDRESS.clone(), + ERC20_DEPLOYER_CALLDATA.to_vec(), + Felt252::new(deploy_entrypoint_selector.clone()), + ERC20_DEPLOYMENT_CALLER_ADDRESS.clone(), + EntryPointType::External, + Some(CallType::Delegate), + Some(*DEPLOYER_CLASS_HASH), + 100_000_000_000, + ); + + // create required structures for execution + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + 1.into(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + // execute the deployment + let call_info = exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // obtain the address of the deployed erc20 contract + let erc20_address = call_info.call_info.unwrap().retdata.get(0).unwrap().clone(); + + (Address(erc20_address), state) + } + }; + + // 2. setup accounts (here we need to execute a deploy_account, + // so we execute it in the vm only). + // Further executions (transfers) will be executed with Native. + // (or the VM, depending on configuration) + // 2a. setup for first account: + let account_casm_file = include_bytes!("../starknet_programs/cairo2/hello_world_account.casm"); + let account_contract_class: CasmContractClass = + serde_json::from_slice(account_casm_file).unwrap(); + + state + .set_contract_class( + &ACCOUNT1_CLASS_HASH, + &CompiledClass::Casm(Arc::new(account_contract_class)), + ) + .unwrap(); + state + .set_compiled_class_hash( + &Felt252::from_bytes_be(&ACCOUNT1_CLASS_HASH.clone()), + &Felt252::from_bytes_be(&ACCOUNT1_CLASS_HASH.clone()), + ) + .unwrap(); + + let contract_address_salt = + felt_str!("2669425616857739096022668060305620640217901643963991674344872184515580705509"); + + // create a transaction for deploying the first account + let account1_deploy_tx = DeployAccount::new( + *ACCOUNT1_CLASS_HASH, // class hash + 0, // max fee + 1.into(), // tx version + Felt252::zero(), // nonce + vec![2.into()], // constructor calldata + vec![ + felt_str!( + "3233776396904427614006684968846859029149676045084089832563834729503047027074" + ), + felt_str!( + "707039245213420890976709143988743108543645298941971188668773816813012281203" + ), + ], // signature + contract_address_salt.clone(), // salt + StarknetChainId::TestNet.to_felt(), // network + ) + .unwrap(); + + // execute the deploy_account transaction. + // this will create the account and after that, + // we can extract its address. + let account1_address = account1_deploy_tx + .execute(&mut state, &Default::default()) + .expect("failed to execute the deployment of account 1") + .validate_info + .expect("validate_info missing") + .contract_address; + + // now we need to deploy account2 + let account2_deploy_tx = DeployAccount::new( + *ACCOUNT1_CLASS_HASH, // class hash + 0, // max fee + 1.into(), // tx version + Felt252::zero(), // nonce + vec![3.into()], // constructor calldata + vec![ + felt_str!( + "3233776396904427614006684968846859029149676045084089832563834729503047027074" + ), + felt_str!( + "707039245213420890976709143988743108543645298941971188668773816813012281203" + ), + ], // signature + contract_address_salt, // salt + StarknetChainId::TestNet.to_felt(), // network + ) + .unwrap(); + + // execute the deploy_account transaction and retrieve the deployed account address. + let _account2_address = account2_deploy_tx + .execute(&mut state, &Default::default()) + .expect("failed to execute the deployment of account 2") + .validate_info + .expect("validate_info missing") + .contract_address; + + // 4. do transfers between the accounts + + let transfer_entrypoint_selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"transfer")); + // calldata for transfering 123 tokens from account1 to account2 + let calldata = vec![Felt252::from(12), Felt252::from(123)]; + + let native_ctx = NativeContext::new(); + let program_cache = Rc::new(RefCell::new(ProgramCache::new(&native_ctx))); + + for _ in 0..executions { + let result = execute( + &mut state.clone(), + &account1_address, + &erc20_address, + &transfer_entrypoint_selector.clone(), + &calldata.clone(), + EntryPointType::External, + &ERC20_CLASS_HASH, + program_cache.clone(), + ); + + _ = std::hint::black_box(result); + } +} + +#[inline(never)] +#[allow(clippy::too_many_arguments)] +fn execute( + state: &mut CachedState, + caller_address: &Address, + callee_address: &Address, + selector: &Felt252, + calldata: &[Felt252], + entrypoint_type: EntryPointType, + class_hash: &ClassHash, + program_cache: Rc>>, +) -> CallInfo { + let exec_entry_point = ExecutionEntryPoint::new( + (*callee_address).clone(), + calldata.to_vec(), + selector.clone(), + (*caller_address).clone(), + entrypoint_type, + Some(CallType::Delegate), + Some(*class_hash), + u64::MAX.into(), // gas is u64 in cairo-native and sierra + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + exec_entry_point + .execute_with_native_cache( + state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + program_cache, + ) + .unwrap() + .call_info + .unwrap() +} diff --git a/cairo_programs/constants.cairo b/cairo_programs/constants.cairo index d7d3add45..a99470f13 100644 --- a/cairo_programs/constants.cairo +++ b/cairo_programs/constants.cairo @@ -80,6 +80,8 @@ const STORAGE_READ_GAS_COST = SYSCALL_BASE_GAS_COST + 50 * STEP_GAS_COST; const STORAGE_WRITE_GAS_COST = SYSCALL_BASE_GAS_COST + 50 * STEP_GAS_COST; const EMIT_EVENT_GAS_COST = SYSCALL_BASE_GAS_COST + 10 * STEP_GAS_COST; const SEND_MESSAGE_TO_L1_GAS_COST = SYSCALL_BASE_GAS_COST + 50 * STEP_GAS_COST; +const GET_BLOCK_HASH_GAS_COST = SYSCALL_BASE_GAS_COST + 50 * STEP_GAS_COST; + // Cairo 1.0 error codes. const ERROR_OUT_OF_GAS = 'Out of gas'; diff --git a/cli/src/main.rs b/cli/src/main.rs index 177f70f55..eba455151 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -204,7 +204,7 @@ fn invoke_parser( )?; let mut transactional_state = cached_state.create_transactional()?; let _tx_info = internal_invoke.apply(&mut transactional_state, &BlockContext::default(), 0)?; - cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state)?)?; + cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state.cache())?)?; let tx_hash = calculate_transaction_hash_common( TransactionHashPrefix::Invoke, diff --git a/examples/contract_execution/Cargo.toml b/examples/contract_execution/Cargo.toml new file mode 100644 index 000000000..b2b76bbe0 --- /dev/null +++ b/examples/contract_execution/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "contract_execution" +version = "0.4.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cairo-vm = { workspace = true } +starknet_in_rust = { path = "../../", version = "0.4.0" } +serde_json = { version = "1.0", features = [ + "arbitrary_precision", + "raw_value", +] } diff --git a/examples/contract_execution/README.md b/examples/contract_execution/README.md index 88c8faf54..20aa5dbd9 100644 --- a/examples/contract_execution/README.md +++ b/examples/contract_execution/README.md @@ -10,17 +10,12 @@ As declare and deploy transactions are currently WIP, we encapsulate all the fun - Add your contract to this directory. - - Remember that in order to call functions you must use the *external* decorator. - - - You also must add ```%lang starknet``` at the beggining of the contract. - - - Compile the contract: - ```source starknet-venv/bin/activate``` - - ```starknet-compile your_contract.cairo --output your_contract.json``` + - ```cairo2/bin/starknet-compile your_contract.cairo --single-file your_contract.json``` - Add a test for your contract calling ```test_contract``` passing: - Your compiled contract path - The entrypoint you are wanting to execute - The parameters needed in order to call that entrypoint - - The expected returned value + - The expected returned value diff --git a/examples/contract_execution/example_contract.cairo b/examples/contract_execution/example_contract.cairo deleted file mode 100644 index 1fe12c14a..000000000 --- a/examples/contract_execution/example_contract.cairo +++ /dev/null @@ -1,32 +0,0 @@ -// Declare this file as a StarkNet contract. -%lang starknet - -from starkware.cairo.common.cairo_builtins import HashBuiltin - -// Define a storage variable. -@storage_var -func balance() -> (res: felt) { -} - -// Increases the balance by the given amount. -@external -func increase_balance{ - syscall_ptr: felt*, - pedersen_ptr: HashBuiltin*, - range_check_ptr, -}(amount: felt) { - let (res) = balance.read(); - balance.write(res + amount); - return (); -} - -// Returns the current balance. -@view -func get_balance{ - syscall_ptr: felt*, - pedersen_ptr: HashBuiltin*, - range_check_ptr, -}() -> (res: felt) { - let (res) = balance.read(); - return (res=res); -} diff --git a/examples/contract_execution/execute_contract.rs b/examples/contract_execution/execute_contract.rs deleted file mode 100644 index 2fa36970a..000000000 --- a/examples/contract_execution/execute_contract.rs +++ /dev/null @@ -1,136 +0,0 @@ -#![deny(warnings)] - -use cairo_vm::felt::Felt252; -use starknet_in_rust::{ - execution::{ - execution_entry_point::ExecutionEntryPoint, - objects::{CallInfo, CallType, TransactionExecutionContext}, - }, - state::{ - contract_state::ContractState, in_memory_state_reader::InMemoryStateReader, - structs::ExecutionResourcesManager, - }, - state::cached_state::CachedState, - definitions::{ - constants::TRANSACTION_VERSION, - block_context::BlockContext, - }, - services::api::contract_class::{ContractClass, EntryPointType}, - utils::{calculate_sn_keccak, Address}, -}; -use std::path::Path; - -fn test_contract( - contract_path: impl AsRef, - entry_point: &str, - call_data: Vec, - return_data: impl Into>, -) { - let contract_class = ContractClass::try_from(contract_path.as_ref().to_path_buf()) - .expect("Could not load contract from JSON"); - - - - //* -------------------------------------------- - //* Create a default contract data - //* -------------------------------------------- - - let contract_address = Address(1111.into()); - let class_hash = [1; 32]; - - //* -------------------------------------------- - //* Create default context - //* -------------------------------------------- - - let block_context = BlockContext::default(); - - let tx_execution_context = - TransactionExecutionContext::create_for_testing( - Address(0.into()), - 10, - 0.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION, - ); - - //* -------------------------------------------- - //* Create starknet state with the contract - //* (This would be the equivalent of - //* declaring and deploying the contract) - //* ------------------------------------------- - - let contract_state = ContractState::new( - class_hash, - tx_execution_context.nonce(), - Default::default(), - ); - let mut state_reader = InMemoryStateReader::new(HashMap::new(), HashMap::new()); - state_reader - .contract_states_mut() - .insert(contract_address, contract_state); - - let mut state = CachedState::new( - state_reader, - Some([(class_hash, contract_class)].iter().collect()), - ); - - //* ------------------------------------ - //* Create execution entry point - //* ------------------------------------ - - let caller_address = Address(0.into()); - - let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(entry_point.as_bytes())); - let entry_point = ExecutionEntryPoint::new( - contract_address, - call_data, - entry_point_selector, - caller_address, - EntryPointType::External, - CallType::Delegate.into(), - class_hash.into(), - ); - - let mut resources_manager = ExecutionResourcesManager::default(); - - assert_eq!( - entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &tx_execution_context, - ) - .expect("Could not execute contract"), - CallInfo { - contract_address, - caller_address, - entry_point_type: EntryPointType::External.into(), - call_type: CallType::Delegate.into(), - class_hash: class_hash.into(), - entry_point_selector: Some(entry_point_selector), - calldata: call_data.into(), - retdata: return_data.into(), - ..Default::default() - }, - ); -} - -#[test] -fn test_fibonacci(){ - test_contract( - "starknet_programs/fibonacci.json", - "fib", - [1.into(), 1.into(), 10.into()].to_vec(), - [144.into()].to_vec(), - ); -} - -#[test] -fn test_factorial(){ - test_contract("starknet_programs/factorial.json", - "factorial", - [10.into()].to_vec(), - [3628800.into()].to_vec() - ); -} diff --git a/examples/contract_execution/src/main.rs b/examples/contract_execution/src/main.rs new file mode 100644 index 000000000..d41a1b097 --- /dev/null +++ b/examples/contract_execution/src/main.rs @@ -0,0 +1,265 @@ +#![deny(warnings)] + +//! A simple example of starknet-rs use. +//! +//! In [`test_contract`] we have all the interaction with the crate's API. +//! In [`main`] we use it to run a compiled contract's entrypoint and print +//! the returned data. +//! +//! It also includes some small tests that assert the data returned by +//! running some pre-compiled contracts is as expected. + +use cairo_vm::felt::{felt_str, Felt252}; +use starknet_in_rust::{ + core::contract_address::{compute_casm_class_hash, compute_deprecated_class_hash}, + definitions::block_context::BlockContext, + services::api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, + }, + state::{ + cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, state_api::State, + }, + transaction::{DeclareV2, DeployAccount, InvokeFunction}, + utils::{calculate_sn_keccak, felt_to_hash, Address}, + CasmContractClass, SierraContractClass, +}; +use std::{collections::HashMap, fs::File, io::BufReader, path::Path, str::FromStr, sync::Arc}; + +fn main() { + // replace this with the path to your compiled contract + let contract_path = "../../starknet_programs/cairo2/fibonacci.sierra"; + + // replace this with the name of your entrypoint + let entry_point: &str = "fib"; + + // replace this with the arguments for the entrypoint + let calldata: Vec = [1.into(), 1.into(), 10.into()].to_vec(); + + let retdata = test_contract(contract_path, entry_point, calldata); + + let result_strs: Vec = retdata.iter().map(Felt252::to_string).collect(); + let joined_str = result_strs.join(", "); + + println!("The returned values were: {joined_str}"); +} + +/// This function: +/// - deploys an account +/// - declares a new contract class +/// - deploys a new contract +/// - executes the given entry point in the deployed contract +fn test_contract( + contract_path: impl AsRef, + entry_point: &str, + call_data: Vec, +) -> Vec { + //* -------------------------------------------- + //* Initialize needed variables + //* -------------------------------------------- + let block_context = BlockContext::default(); + // Values hardcoded to pass signature validation + let signature = vec![ + felt_str!("3086480810278599376317923499561306189851900463386393948998357832163236918254"), + felt_str!("598673427589502599949712887611119751108407514580626464031881322743364689811"), + ]; + + //* -------------------------------------------- + //* Initialize state + //* -------------------------------------------- + let state_reader = Arc::new(InMemoryStateReader::default()); + let mut state = CachedState::new(state_reader, HashMap::new()); + + //* -------------------------------------------- + //* Deploy deployer contract + //* -------------------------------------------- + let deployer_contract = + ContractClass::from_str(include_str!("../../../starknet_programs/deployer.json")).unwrap(); + let deployer_contract_address = Address(Felt252::from(17)); + let deployer_contract_class_hash = + felt_to_hash(&compute_deprecated_class_hash(&deployer_contract).unwrap()); + state + .set_contract_class( + &deployer_contract_class_hash, + &CompiledClass::Deprecated(Arc::new(deployer_contract)), + ) + .unwrap(); + state + .deploy_contract( + deployer_contract_address.clone(), + deployer_contract_class_hash, + ) + .expect("Failed to deploy deployer contract"); + + //* -------------------------------------------- + //* Deploy Account contract + //* -------------------------------------------- + let account_contract = + ContractClass::from_str(include_str!("../../../starknet_programs/Account.json")).unwrap(); + let account_contract_class_hash = felt_to_hash(&Felt252::from(1)); + state + .set_contract_class( + &account_contract_class_hash, + &CompiledClass::Deprecated(Arc::new(account_contract)), + ) + .unwrap(); + + let internal_deploy = DeployAccount::new_with_tx_hash( + account_contract_class_hash, + 0, + 1.into(), + 0.into(), + // Values hardcoded to pass signature validation + vec![felt_str!( + "1735102664668487605176656616876767369909409133946409161569774794110049207117" + )], + signature.clone(), + felt_str!("2669425616857739096022668060305620640217901643963991674344872184515580705509"), + 2718.into(), + ) + .unwrap(); + + let account_contract_address = internal_deploy + .execute(&mut state, &block_context) + .expect("Account Deploy Failed") + .call_info + .unwrap() + .contract_address + .clone(); + + //* -------------------------------------------- + //* Read contract from file + //* -------------------------------------------- + let file = File::open(contract_path).unwrap(); + let reader = BufReader::new(file); + let sierra_contract_class: SierraContractClass = + serde_json::from_reader(reader).expect("Could not load contract from JSON"); + let casm_class = + CasmContractClass::from_contract_class(sierra_contract_class.clone(), false).unwrap(); + let compiled_class_hash = + compute_casm_class_hash(&casm_class).expect("Error computing sierra class hash"); + //* -------------------------------------------- + //* Declare new contract class + //* -------------------------------------------- + let declare_tx = DeclareV2::new_with_tx_hash( + &sierra_contract_class, + Some(casm_class), + compiled_class_hash.clone(), + account_contract_address.clone(), + 0, // max fee + 2.into(), + signature.clone(), + 1.into(), // nonce + // Value hardcoded to pass signature validation + 2718.into(), + ) + .expect("couldn't create declare transaction"); + + declare_tx + .execute(&mut state, &block_context) + .expect("could not declare the contract class"); + + //* ---------------------------------------------------------- + //* Deploy new contract class instance through the deployer + //* ----------------------------------------------------------- + + let deploy = InvokeFunction::new( + deployer_contract_address, + Felt252::from_bytes_be(&calculate_sn_keccak("deploy_contract".as_bytes())), + 0, + 0.into(), + vec![compiled_class_hash, 3.into(), 0.into()], // call data + signature.clone(), + block_context.starknet_os_config().chain_id().clone(), + None, + ) + .unwrap(); + + let contract_address = deploy + .execute(&mut state, &block_context, 0) + .expect("could not deploy contract") + .call_info + .unwrap() + .retdata[0] + .clone(); + + //* --------------------------------------------------------- + //* Execute contract entrypoint through the account + //* --------------------------------------------------------- + let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(entry_point.as_bytes())); + let mut account_execute_calldata = vec![ + // call_array_len: felt + 1.into(), + // call_array: CallArray* + // struct CallArray { + // to: felt, + contract_address, + // selector: felt, + entry_point_selector, + // data_offset: felt, + 0.into(), + // data_len: felt, + call_data.len().into(), + // } + // calldata_len: felt + call_data.len().into(), + ]; + // calldata: felt* + account_execute_calldata.extend(call_data); + let invoke_tx = InvokeFunction::new_with_tx_hash( + account_contract_address, + Felt252::from_bytes_be(&calculate_sn_keccak("__execute__".as_bytes())), + 0, + 1.into(), + account_execute_calldata, + signature, + Some(2.into()), + // Value hardcoded to pass signature validation + 2718.into(), + ) + .unwrap(); + + let tx_exec_info = invoke_tx.execute(&mut state, &block_context, 0).unwrap(); + + //* -------------------------------------------- + //* Extract return values + //* -------------------------------------------- + tx_exec_info + .call_info + .expect("call info should exist") + .retdata +} + +#[cfg(test)] +mod tests { + use crate::test_contract; + + #[test] + fn test_example_contract() { + let retdata = test_contract( + "../../starknet_programs/cairo2/example_contract.sierra", + "get_balance", + [].to_vec(), + ); + assert_eq!(retdata, vec![0.into()]); + } + + #[test] + fn test_fibonacci() { + let retdata = test_contract( + "../../starknet_programs/cairo2/fibonacci.sierra", + "fib", + [1.into(), 1.into(), 10.into()].to_vec(), + ); + assert_eq!(retdata, vec![89.into()]); + } + + #[test] + fn test_factorial() { + let retdata = test_contract( + "../../starknet_programs/cairo2/factorial.sierra", + "factorial", + [10.into()].to_vec(), + ); + assert_eq!(retdata, vec![3628800.into()]); + } +} diff --git a/rpc_state_reader/Cargo.toml b/rpc_state_reader/Cargo.toml index 0cdbbf8ef..de58a9736 100644 --- a/rpc_state_reader/Cargo.toml +++ b/rpc_state_reader/Cargo.toml @@ -20,7 +20,7 @@ thiserror = { workspace = true } flate2 = "1.0.25" serde_with = "3.0.0" dotenv = "0.15.0" -cairo-vm = "0.8.5" +cairo-vm = { workspace = true } blockifier = "=0.2.0-rc0" starknet_in_rust = { path = "../", version = "0.4.0" } diff --git a/rpc_state_reader/src/lib.rs b/rpc_state_reader/src/lib.rs index 094029c55..7965a3859 100644 --- a/rpc_state_reader/src/lib.rs +++ b/rpc_state_reader/src/lib.rs @@ -1,4 +1,5 @@ pub mod rpc_state; +pub mod rpc_state_errors; pub mod utils; #[cfg(test)] @@ -31,7 +32,7 @@ mod tests { #[test] fn test_get_contract_class_cairo1() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let class_hash = class_hash!("0298e56befa6d1446b86ed5b900a9ba51fd2faa683cd6f50e8f833c0fb847216"); @@ -44,7 +45,7 @@ mod tests { #[test] fn test_get_contract_class_cairo0() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let class_hash = class_hash!("025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"); @@ -53,7 +54,7 @@ mod tests { #[test] fn test_get_class_hash_at() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let address = contract_address!("00b081f7ba1efc6fe98770b09a827ae373ef2baa6116b3d2a0bf5154136573a9"); @@ -65,7 +66,7 @@ mod tests { #[test] fn test_get_nonce_at() { - let rpc_state = RpcState::new_infura(RpcChain::TestNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::TestNet, BlockTag::Latest.into()).unwrap(); // Contract deployed by xqft which will not be used again, so nonce changes will not break // this test. let address = @@ -75,7 +76,7 @@ mod tests { #[test] fn test_get_storage_at() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let address = contract_address!("00b081f7ba1efc6fe98770b09a827ae373ef2baa6116b3d2a0bf5154136573a9"); let key = StorageKey(patricia_key!(0u128)); @@ -85,22 +86,22 @@ mod tests { #[test] fn test_get_transaction() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let tx_hash = TransactionHash(stark_felt!( "06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955" )); - rpc_state.get_transaction(&tx_hash); + assert!(rpc_state.get_transaction(&tx_hash).is_ok()); } #[test] fn test_try_from_invoke() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let tx_hash = TransactionHash(stark_felt!( "06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955" )); - let tx = rpc_state.get_transaction(&tx_hash); + let tx = rpc_state.get_transaction(&tx_hash).unwrap(); match tx { SNTransaction::Invoke(tx) => { InvokeFunction::from_invoke_transaction(tx, StarknetChainId::MainNet) @@ -112,28 +113,28 @@ mod tests { #[test] fn test_get_block_info() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); - rpc_state.get_block_info(); + assert!(rpc_state.get_block_info().is_ok()); } // Tested with the following query to the Feeder Gateway API: - // https://alpha4-2.starknet.io/feeder_gateway/get_transaction_trace?transactionHash=0x019feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc + // https://alpha-mainnet.starknet.io/feeder_gateway/get_transaction_trace?transactionHash=0x035673e42bd485ae699c538d8502f730d1137545b22a64c094ecdaf86c59e592 #[test] fn test_get_transaction_trace() { - let rpc_state = RpcState::new_infura(RpcChain::TestNet2, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let tx_hash = TransactionHash(stark_felt!( - "19feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc" + "0x035673e42bd485ae699c538d8502f730d1137545b22a64c094ecdaf86c59e592" )); - let tx_trace = rpc_state.get_transaction_trace(&tx_hash); + let tx_trace = rpc_state.get_transaction_trace(&tx_hash).unwrap(); assert_eq!( tx_trace.signature, vec![ - stark_felt!("ffab1c47d8d5e5b76bdcc4af79e98205716c36b440f20244c69599a91ace58"), - stark_felt!("6aa48a0906c9c1f7381c1a040c043b649eeac1eea08f24a9d07813f6b1d05fe"), + stark_felt!("0x1bb2bc03d7f5faccc0e159ea2bbf54cdd1e983fc6362545391bf8fda5d8e669"), + stark_felt!("0x4517da2856095584a30640bf14ad59cca3ff91dded42be7e3e40e5ea2f51045"), ] ); @@ -141,20 +142,21 @@ mod tests { tx_trace.validate_invocation.as_ref().unwrap().calldata, Some(vec![ stark_felt!("1"), - stark_felt!("690c876e61beda61e994543af68038edac4e1cb1990ab06e52a2d27e56a1232"), - stark_felt!("1f24f689ced5802b706d7a2e28743fe45c7bfa37431c97b1c766e9622b65573"), + stark_felt!("0x45dc42889b6292c540de9def0341364bd60c2d8ccced459fac8b1bfc24fa1f5"), + stark_felt!("0xb758361d5e84380ef1e632f89d8e76a8677dbc3f4b93a4f9d75d2a6048f312"), stark_felt!("0"), - stark_felt!("9"), - stark_felt!("9"), - stark_felt!("4"), - stark_felt!("4254432d55534443"), - stark_felt!("f02e7324ecbd65ce267"), - stark_felt!("5754492d55534443"), - stark_felt!("8e13050d06d8f514c"), - stark_felt!("4554482d55534443"), - stark_felt!("f0e4a142c3551c149d"), - stark_felt!("4a50592d55534443"), - stark_felt!("38bd34c31a0a5c"), + stark_felt!("0xa"), + stark_felt!("0xa"), + stark_felt!("0x3fed4"), + stark_felt!("0"), + stark_felt!("0xdf6aedb"), + stark_felt!("0"), + stark_felt!("0"), + stark_felt!("0"), + stark_felt!("0x47c5f10d564f1623566b940a61fe54754bfff996f7536901ec969b12874f87f"), + stark_felt!("2"), + stark_felt!("0x72034953cd93dc8618123b4802003bae1f469b526bc18355250080c0f93dc17"), + stark_felt!("0x5f2ac628fa43d58fb8a6b7a2739de5c1edb550cb13cdcec5bc99f00135066a7"), ]) ); assert_eq!( @@ -168,12 +170,12 @@ mod tests { .unwrap() .execution_resources, ExecutionResources { - n_steps: 790, - n_memory_holes: 51, + n_steps: 672, + n_memory_holes: 74, builtin_instance_counter: HashMap::from([ - ("range_check_builtin".to_string(), 20), + ("range_check_builtin".to_string(), 11), ("ecdsa_builtin".to_string(), 1), - ("pedersen_builtin".to_string(), 2), + ("pedersen_builtin".to_string(), 1), ]), } ); @@ -190,21 +192,22 @@ mod tests { assert_eq!( tx_trace.function_invocation.as_ref().unwrap().calldata, Some(vec![ - stark_felt!("1"), - stark_felt!("690c876e61beda61e994543af68038edac4e1cb1990ab06e52a2d27e56a1232"), - stark_felt!("1f24f689ced5802b706d7a2e28743fe45c7bfa37431c97b1c766e9622b65573"), - stark_felt!("0"), - stark_felt!("9"), - stark_felt!("9"), - stark_felt!("4"), - stark_felt!("4254432d55534443"), - stark_felt!("f02e7324ecbd65ce267"), - stark_felt!("5754492d55534443"), - stark_felt!("8e13050d06d8f514c"), - stark_felt!("4554482d55534443"), - stark_felt!("f0e4a142c3551c149d"), - stark_felt!("4a50592d55534443"), - stark_felt!("38bd34c31a0a5c"), + stark_felt!("0x1"), + stark_felt!("0x45dc42889b6292c540de9def0341364bd60c2d8ccced459fac8b1bfc24fa1f5"), + stark_felt!("0xb758361d5e84380ef1e632f89d8e76a8677dbc3f4b93a4f9d75d2a6048f312"), + stark_felt!("0x0"), + stark_felt!("0xa"), + stark_felt!("0xa"), + stark_felt!("0x3fed4"), + stark_felt!("0x0"), + stark_felt!("0xdf6aedb"), + stark_felt!("0x0"), + stark_felt!("0x0"), + stark_felt!("0x0"), + stark_felt!("0x47c5f10d564f1623566b940a61fe54754bfff996f7536901ec969b12874f87f"), + stark_felt!("0x2"), + stark_felt!("0x72034953cd93dc8618123b4802003bae1f469b526bc18355250080c0f93dc17"), + stark_felt!("0x5f2ac628fa43d58fb8a6b7a2739de5c1edb550cb13cdcec5bc99f00135066a7") ]) ); assert_eq!( @@ -218,11 +221,13 @@ mod tests { .unwrap() .execution_resources, ExecutionResources { - n_steps: 2808, - n_memory_holes: 136, + n_steps: 3525, + n_memory_holes: 421, builtin_instance_counter: HashMap::from([ - ("range_check_builtin".to_string(), 49), - ("pedersen_builtin".to_string(), 14), + ("range_check_builtin".to_string(), 83), + ("pedersen_builtin".to_string(), 16), + ("poseidon_builtin".to_string(), 4), + ("ec_op_builtin".to_string(), 3), ]), } ); @@ -254,14 +259,14 @@ mod tests { .internal_calls[0] .internal_calls .len(), - 7 + 0 ); assert_eq!( tx_trace.fee_transfer_invocation.as_ref().unwrap().calldata, Some(vec![ - stark_felt!("1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"), - stark_felt!("2b0322a23ba4"), + stark_felt!("0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"), + stark_felt!("0x2439e47667460"), stark_felt!("0"), ]) ); @@ -276,8 +281,8 @@ mod tests { .unwrap() .execution_resources, ExecutionResources { - n_steps: 586, - n_memory_holes: 42, + n_steps: 590, + n_memory_holes: 40, builtin_instance_counter: HashMap::from([ ("range_check_builtin".to_string(), 21), ("pedersen_builtin".to_string(), 4), @@ -297,11 +302,11 @@ mod tests { #[test] fn test_get_transaction_receipt() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let tx_hash = TransactionHash(stark_felt!( "06da92cfbdceac5e5e94a1f40772d6c79d34f011815606742658559ec77b6955" )); - rpc_state.get_transaction_receipt(&tx_hash); + assert!(rpc_state.get_transaction_receipt(&tx_hash).is_ok()); } } diff --git a/rpc_state_reader/src/rpc_state.rs b/rpc_state_reader/src/rpc_state.rs index 60bfd21b2..587e15d8d 100644 --- a/rpc_state_reader/src/rpc_state.rs +++ b/rpc_state_reader/src/rpc_state.rs @@ -13,9 +13,8 @@ use starknet_api::{ }; use starknet_in_rust::definitions::block_context::StarknetChainId; use std::{collections::HashMap, env, fmt::Display}; -use thiserror::Error; -use crate::utils; +use crate::{rpc_state_errors::RpcStateError, utils}; /// Starknet chains supported in Infura. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord)] @@ -72,14 +71,6 @@ pub struct RpcState { pub block: BlockValue, } -#[derive(Error, Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)] -enum RpcError { - #[error("RPC call failed with error: {0}")] - RpcCall(String), - #[error("Request failed with error: {0}")] - Request(String), -} - /// Represents the tag of a block value. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, PartialOrd, Ord)] pub enum BlockTag { @@ -197,7 +188,7 @@ where D: Deserializer<'de>, { let hex: String = Deserialize::deserialize(deserializer)?; - Ok(u128::from_str_radix(&hex[2..], 16).unwrap()) + u128::from_str_radix(&hex[2..], 16).map_err(serde::de::Error::custom) } impl<'de> Deserialize<'de> for RpcCallInfo { @@ -208,34 +199,72 @@ impl<'de> Deserialize<'de> for RpcCallInfo { let value: serde_json::Value = Deserialize::deserialize(deserializer)?; // Parse execution_resources - let execution_resources_value = value["execution_resources"].clone(); + let execution_resources_value = value + .get("execution_resources") + .ok_or(serde::de::Error::custom( + "Missing field execution_resources", + ))? + .clone(); let execution_resources = VmExecutionResources { - n_steps: serde_json::from_value(execution_resources_value["n_steps"].clone()) - .map_err(serde::de::Error::custom)?, + n_steps: serde_json::from_value( + execution_resources_value + .get("n_steps") + .ok_or(serde::de::Error::custom( + "Missing field execution_resources.n_steps", + ))? + .clone(), + ) + .map_err(serde::de::Error::custom)?, n_memory_holes: serde_json::from_value( - execution_resources_value["n_memory_holes"].clone(), + execution_resources_value + .get("n_memory_holes") + .ok_or(serde::de::Error::custom( + "Missing field execution_resources.n_memory_holes", + ))? + .clone(), ) .map_err(serde::de::Error::custom)?, builtin_instance_counter: serde_json::from_value( - execution_resources_value["builtin_instance_counter"].clone(), + execution_resources_value + .get("builtin_instance_counter") + .ok_or(serde::de::Error::custom( + "Missing field execution_resources.builtin_instance_counter", + ))? + .clone(), ) .map_err(serde::de::Error::custom)?, }; // Parse retdata - let retdata_value = value["result"].clone(); - let retdata = serde_json::from_value(retdata_value).unwrap(); + let retdata_value = value + .get("result") + .ok_or(serde::de::Error::custom("Missing field result"))? + .clone(); + let retdata = serde_json::from_value(retdata_value) + .map_err(|e| serde::de::Error::custom(e.to_string()))?; // Parse calldata - let calldata_value = value["calldata"].clone(); - let calldata = serde_json::from_value(calldata_value).unwrap(); + let calldata_value = value + .get("calldata") + .ok_or(serde::de::Error::custom("Missing field calldata"))? + .clone(); + let calldata = serde_json::from_value(calldata_value) + .map_err(|e| serde::de::Error::custom(e.to_string()))?; // Parse internal calls - let internal_calls_value = value["internal_calls"].clone(); + let internal_calls_value = value + .get("internal_calls") + .ok_or(serde::de::Error::custom("Missing field internal_calls"))? + .clone(); let mut internal_calls = vec![]; - for call in internal_calls_value.as_array().unwrap() { + for call in internal_calls_value + .as_array() + .ok_or(serde::de::Error::custom( + "Wrong type for field internal_calls", + ))? + { internal_calls .push(serde_json::from_value(call.clone()).map_err(serde::de::Error::custom)?); } @@ -259,28 +288,28 @@ impl RpcState { } } - pub fn new_infura(chain: RpcChain, block: BlockValue) -> Self { + pub fn new_infura(chain: RpcChain, block: BlockValue) -> Result { if env::var("INFURA_API_KEY").is_err() { - dotenv().expect("Missing .env file"); + dotenv().map_err(|_| RpcStateError::MissingEnvFile)?; } let rpc_endpoint = format!( "https://{}.infura.io/v3/{}", chain, - env::var("INFURA_API_KEY").expect("missing infura api key") + env::var("INFURA_API_KEY").map_err(|_| RpcStateError::MissingInfuraApiKey)? ); let chain_id: ChainId = chain.into(); let feeder_url = format!("https://{}.starknet.io/feeder_gateway", chain_id); - Self::new(chain, block, &rpc_endpoint, &feeder_url) + Ok(Self::new(chain, block, &rpc_endpoint, &feeder_url)) } fn rpc_call_result Deserialize<'a>>( &self, method: &str, params: &serde_json::Value, - ) -> Result { + ) -> Result { Ok(self.rpc_call::>(method, params)?.result) } @@ -288,32 +317,32 @@ impl RpcState { &self, method: &str, params: &serde_json::Value, - ) -> Result { + ) -> Result { let payload = serde_json::json!({ "jsonrpc": "2.0", "method": method, "params": params, "id": 1 }); - let response = self.rpc_call_no_deserialize(&payload)?.into_json().unwrap(); + let response = self.rpc_call_no_deserialize(&payload)?.into_json()?; Self::deserialize_call(response) } fn rpc_call_no_deserialize( &self, params: &serde_json::Value, - ) -> Result { + ) -> Result { ureq::post(&self.rpc_endpoint) .set("Content-Type", "application/json") .set("accept", "application/json") .send_json(params) - .map_err(|err| RpcError::Request(err.to_string())) + .map_err(|err| RpcStateError::Request(err.to_string())) } fn deserialize_call Deserialize<'a>>( response: serde_json::Value, - ) -> Result { - serde_json::from_value(response).map_err(|err| RpcError::RpcCall(err.to_string())) + ) -> Result { + serde_json::from_value(response).map_err(|err| RpcStateError::RpcCall(err.to_string())) } /// Gets the url of the feeder endpoint @@ -327,38 +356,53 @@ impl RpcState { /// - actual fee /// - events /// - return data - pub fn get_transaction_trace(&self, hash: &TransactionHash) -> TransactionTrace { + pub fn get_transaction_trace( + &self, + hash: &TransactionHash, + ) -> Result { let response = ureq::get(&self.get_feeder_endpoint("get_transaction_trace")) .query("transactionHash", &hash.0.to_string()) .call() - .unwrap(); + .map_err(|e| RpcStateError::Request(e.to_string()))?; - serde_json::from_value(response.into_json().unwrap()).unwrap() + serde_json::from_value(response.into_json().map_err(RpcStateError::Io)?) + .map_err(|e| RpcStateError::Request(e.to_string())) } /// Requests the given transaction to the Feeder Gateway API. - pub fn get_transaction(&self, hash: &TransactionHash) -> SNTransaction { + pub fn get_transaction(&self, hash: &TransactionHash) -> Result { let result = self .rpc_call::( "starknet_getTransactionByHash", &json!([hash.to_string()]), - ) - .unwrap()["result"] + )? + .get("result") + .ok_or(RpcStateError::RpcCall( + "Response has no field result".into(), + ))? .clone(); - utils::deserialize_transaction_json(result).unwrap() + utils::deserialize_transaction_json(result).map_err(RpcStateError::SerdeJson) } /// Gets the gas price of a given block. - pub fn get_gas_price(&self, block_number: u64) -> serde_json::Result { + pub fn get_gas_price(&self, block_number: u64) -> Result { let response = ureq::get(&self.get_feeder_endpoint("get_block")) .query("blockNumber", &block_number.to_string()) .call() - .unwrap(); - - let res: serde_json::Value = response.into_json().expect("should be json"); - - let gas_price_hex = res["gas_price"].as_str().unwrap(); - let gas_price = u128::from_str_radix(gas_price_hex.trim_start_matches("0x"), 16).unwrap(); + .map_err(|e| RpcStateError::Request(e.to_string()))?; + + let res: serde_json::Value = response.into_json().map_err(RpcStateError::Io)?; + + let gas_price_hex = + res.get("gas_price") + .and_then(|gp| gp.as_str()) + .ok_or(RpcStateError::Request( + "Response has no field gas_price".to_string(), + ))?; + let gas_price = + u128::from_str_radix(gas_price_hex.trim_start_matches("0x"), 16).map_err(|_| { + RpcStateError::Request("Response field gas_price has wrong type".to_string()) + })?; Ok(gas_price) } @@ -366,73 +410,103 @@ impl RpcState { self.chain.into() } - pub fn get_block_info(&self) -> RpcBlockInfo { + pub fn get_block_info(&self) -> Result { let block_info: serde_json::Value = self - .rpc_call( - "starknet_getBlockWithTxs", - &json!([self.block.to_value().unwrap()]), - ) - .unwrap(); - let sequencer_address: StarkFelt = - serde_json::from_value(block_info["result"]["sequencer_address"].clone()).unwrap(); - - let transactions: Vec<_> = block_info["result"]["transactions"] - .as_array() - .unwrap() - .iter() - .filter_map(|result| utils::deserialize_transaction_json(result.clone()).ok()) - .collect(); - - RpcBlockInfo { + .rpc_call("starknet_getBlockWithTxs", &json!([self.block.to_value()?])) + .map_err(|e| RpcStateError::RpcCall(e.to_string()))?; + + let sequencer_address: StarkFelt = block_info + .get("result") + .and_then(|result| result.get("sequencer_address")) + .and_then(|sa| serde_json::from_value(sa.clone()).ok()) + .ok_or_else(|| { + RpcStateError::RpcObjectHasNoField("block_info".into(), "sequencer_address".into()) + })?; + + let transactions: Vec<_> = block_info + .get("result") + .and_then(|result| result.get("transactions")) + .and_then(|txs| txs.as_array()) + .map(|arr| { + arr.iter() + .filter_map(|result| utils::deserialize_transaction_json(result.clone()).ok()) + .collect() + }) + .ok_or_else(|| { + RpcStateError::RpcObjectHasNoField("block_info".into(), "transactions".into()) + })?; + + Ok(RpcBlockInfo { block_number: BlockNumber( - block_info["result"]["block_number"] - .to_string() - .parse::() - .unwrap(), + block_info + .get("result") + .and_then(|result| result.get("block_number")) + .and_then(|v| v.to_string().parse::().ok()) + .ok_or_else(|| { + RpcStateError::RpcObjectHasNoField( + "block_info".into(), + "block_number".into(), + ) + })?, ), block_timestamp: BlockTimestamp( - block_info["result"]["timestamp"] - .to_string() - .parse::() - .unwrap(), + block_info + .get("result") + .and_then(|result| result.get("timestamp")) + .and_then(|v| v.to_string().parse::().ok()) + .ok_or_else(|| { + RpcStateError::RpcObjectHasNoField("block_info".into(), "timestamp".into()) + })?, + ), + sequencer_address: ContractAddress( + sequencer_address + .try_into() + .map_err(|_| RpcStateError::StarkFeltToParticiaKeyConversion)?, ), - sequencer_address: ContractAddress(sequencer_address.try_into().unwrap()), transactions, - } + }) } pub fn get_contract_class(&self, class_hash: &ClassHash) -> Option { - self.rpc_call_result( - "starknet_getClass", - &json!([self.block.to_value().unwrap(), class_hash.0.to_string()]), - ) - .ok() + self.block.to_value().ok().and_then(|block| { + self.rpc_call_result( + "starknet_getClass", + &json!([block, class_hash.0.to_string()]), + ) + .ok() + }) } pub fn get_class_hash_at(&self, contract_address: &ContractAddress) -> ClassHash { let hash = self - .rpc_call_result( - "starknet_getClassHashAt", - &json!([ - self.block.to_value().unwrap(), - contract_address.0.key().clone().to_string() - ]), - ) + .block + .to_value() + .ok() + .and_then(|block| { + self.rpc_call_result( + "starknet_getClassHashAt", + &json!([block, contract_address.0.key().clone().to_string()]), + ) + .ok() + }) .unwrap_or_default(); ClassHash(hash) } pub fn get_nonce_at(&self, contract_address: &ContractAddress) -> StarkFelt { - self.rpc_call_result( - "starknet_getNonce", - &json!([ - self.block.to_value().unwrap(), - contract_address.0.key().clone().to_string() - ]), - ) - // When running deploy_account transactions, the nonce doesn't exist on the previous block so we return 0 - .unwrap_or_default() + self.block + .to_value() + .ok() + .and_then(|block| { + self.rpc_call_result( + "starknet_getNonce", + &json!([block, contract_address.0.key().clone().to_string()]), + ) + .ok() + }) + // When running deploy_account transactions, the nonce doesn't exist on the previous block so we return 0 + .unwrap_or_default() } pub fn get_storage_at( @@ -442,21 +516,25 @@ impl RpcState { ) -> StarkFelt { let contract_address = contract_address.0.key(); let key = key.0.key(); - - self.rpc_call_result( - "starknet_getStorageAt", - &json!([ - contract_address.to_string(), - key.to_string(), - self.block.to_value().unwrap() - ]), - ) - .unwrap_or_default() + self.block + .to_value() + .ok() + .and_then(|block| { + self.rpc_call_result( + "starknet_getStorageAt", + &json!([contract_address.to_string(), key.to_string(), block]), + ) + .ok() + }) + .unwrap_or_default() } /// Requests the given transaction to the Feeder Gateway API. - pub fn get_transaction_receipt(&self, hash: &TransactionHash) -> RpcTransactionReceipt { + pub fn get_transaction_receipt( + &self, + hash: &TransactionHash, + ) -> Result { self.rpc_call_result("starknet_getTransactionReceipt", &json!([hash.to_string()])) - .unwrap() + .map_err(|e| RpcStateError::RpcCall(e.to_string())) } } diff --git a/rpc_state_reader/src/rpc_state_errors.rs b/rpc_state_reader/src/rpc_state_errors.rs new file mode 100644 index 000000000..ac671c2fc --- /dev/null +++ b/rpc_state_reader/src/rpc_state_errors.rs @@ -0,0 +1,21 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum RpcStateError { + #[error("Missing .env file")] + MissingEnvFile, + #[error("Missing infura api key")] + MissingInfuraApiKey, + #[error("RPC call failed with error: {0}")] + RpcCall(String), + #[error("Request failed with error: {0}")] + Request(String), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error("Object {0} obtained from rpc call has no field {1}")] + RpcObjectHasNoField(String, String), + #[error("Failed to convert StarkFelt to PatriciaKey")] + StarkFeltToParticiaKeyConversion, +} diff --git a/rpc_state_reader/tests/blockifier_tests.rs b/rpc_state_reader/tests/blockifier_tests.rs index 584464929..ae47f58a0 100644 --- a/rpc_state_reader/tests/blockifier_tests.rs +++ b/rpc_state_reader/tests/blockifier_tests.rs @@ -123,7 +123,7 @@ pub fn execute_tx( let tx_hash = tx_hash.strip_prefix("0x").unwrap(); // Instantiate the RPC StateReader and the CachedState - let rpc_reader = RpcStateReader(RpcState::new_infura(network, block_number.into())); + let rpc_reader = RpcStateReader(RpcState::new_infura(network, block_number.into()).unwrap()); let gas_price = rpc_reader.0.get_gas_price(block_number.0).unwrap(); // Get values for block context before giving ownership of the reader @@ -133,14 +133,14 @@ pub fn execute_tx( block_timestamp, sequencer_address, .. - } = rpc_reader.0.get_block_info(); + } = rpc_reader.0.get_block_info().unwrap(); // Get transaction before giving ownership of the reader let tx_hash = TransactionHash(stark_felt!(tx_hash)); let sn_api_tx = rpc_reader.0.get_transaction(&tx_hash); - let trace = rpc_reader.0.get_transaction_trace(&tx_hash); - let receipt = rpc_reader.0.get_transaction_receipt(&tx_hash); + let trace = rpc_reader.0.get_transaction_trace(&tx_hash).unwrap(); + let receipt = rpc_reader.0.get_transaction_receipt(&tx_hash).unwrap(); // Create state from RPC reader let global_cache = GlobalContractCache::default(); @@ -180,7 +180,7 @@ pub fn execute_tx( }; // Map starknet_api transaction to blockifier's - let blockifier_tx = match sn_api_tx { + let blockifier_tx = match sn_api_tx.unwrap() { SNTransaction::Invoke(tx) => { let invoke = InvokeTransaction { tx, tx_hash }; AccountTransaction::Invoke(invoke) @@ -201,8 +201,9 @@ pub fn execute_tx( } SNTransaction::Declare(tx) => { // Fetch the contract_class from the next block (as we don't have it in the previous one) - let mut next_block_state_reader = - RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); + let mut next_block_state_reader = RpcStateReader( + RpcState::new_infura(network, (block_number.next()).into()).unwrap(), + ); let contract_class = next_block_state_reader .get_compiled_contract_class(&tx.class_hash()) .unwrap(); @@ -240,7 +241,7 @@ pub fn execute_tx( #[test] fn test_get_gas_price() { let block = BlockValue::Number(BlockNumber(169928)); - let rpc_state = RpcState::new_infura(RpcChain::MainNet, block); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, block).unwrap(); let price = rpc_state.get_gas_price(169928).unwrap(); assert_eq!(price, 22804578690); diff --git a/rpc_state_reader/tests/sir_tests.rs b/rpc_state_reader/tests/sir_tests.rs index 44d480490..59b82b322 100644 --- a/rpc_state_reader/tests/sir_tests.rs +++ b/rpc_state_reader/tests/sir_tests.rs @@ -106,7 +106,7 @@ pub fn execute_tx_configurable( let tx_hash = tx_hash.strip_prefix("0x").unwrap(); // Instantiate the RPC StateReader and the CachedState - let rpc_reader = RpcStateReader(RpcState::new_infura(network, block_number.into())); + let rpc_reader = RpcStateReader(RpcState::new_infura(network, block_number.into()).unwrap()); let gas_price = rpc_reader.0.get_gas_price(block_number.0).unwrap(); // Get values for block context before giving ownership of the reader @@ -123,7 +123,7 @@ pub fn execute_tx_configurable( block_timestamp, sequencer_address, .. - } = rpc_reader.0.get_block_info(); + } = rpc_reader.0.get_block_info().unwrap(); let block_number = block_number.0; let block_timestamp = block_timestamp.0; @@ -139,19 +139,20 @@ pub fn execute_tx_configurable( // Get transaction before giving ownership of the reader let tx_hash = TransactionHash(stark_felt!(tx_hash)); - let tx = match rpc_reader.0.get_transaction(&tx_hash) { + let tx = match rpc_reader.0.get_transaction(&tx_hash).unwrap() { SNTransaction::Invoke(tx) => InvokeFunction::from_invoke_transaction(tx, chain_id) .unwrap() .create_for_simulation(skip_validate, false, false, false, skip_nonce_check), SNTransaction::DeployAccount(tx) => { DeployAccount::from_sn_api_transaction(tx, chain_id.to_felt()) .unwrap() - .create_for_simulation(skip_validate, false, false, false) + .create_for_simulation(skip_validate, false, false, false, skip_nonce_check) } SNTransaction::Declare(tx) => { // Fetch the contract_class from the next block (as we don't have it in the previous one) - let next_block_state_reader = - RpcStateReader(RpcState::new_infura(network, (block_number.next()).into())); + let next_block_state_reader = RpcStateReader( + RpcState::new_infura(network, (block_number.next()).into()).unwrap(), + ); let contract_class = next_block_state_reader .get_contract_class(tx.class_hash().0.bytes().try_into().unwrap()) .unwrap(); @@ -177,7 +178,7 @@ pub fn execute_tx_configurable( tx.class_hash().0.bytes().try_into().unwrap(), ) .unwrap(); - declare.create_for_simulation(skip_validate, false, false, false) + declare.create_for_simulation(skip_validate, false, false, false, skip_nonce_check) } else { let contract_class = match contract_class { CompiledClass::Casm(cc) => cc.as_ref().clone(), @@ -203,7 +204,7 @@ pub fn execute_tx_configurable( Felt252::from_bytes_be(tx_hash.0.bytes()), ) .unwrap(); - declare.create_for_simulation(skip_validate, false, false, false) + declare.create_for_simulation(skip_validate, false, false, false, skip_nonce_check) } } SNTransaction::L1Handler(tx) => L1Handler::from_sn_api_tx( @@ -216,8 +217,8 @@ pub fn execute_tx_configurable( _ => unimplemented!(), }; - let trace = rpc_reader.0.get_transaction_trace(&tx_hash); - let receipt = rpc_reader.0.get_transaction_receipt(&tx_hash); + let trace = rpc_reader.0.get_transaction_trace(&tx_hash).unwrap(); + let receipt = rpc_reader.0.get_transaction_receipt(&tx_hash).unwrap(); let class_cache = Arc::new(PermanentContractClassCache::default()); let mut state = CachedState::new(Arc::new(rpc_reader), class_cache); @@ -267,11 +268,11 @@ pub fn execute_tx_without_validate( #[test] fn test_get_transaction_try_from() { - let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, BlockTag::Latest.into()).unwrap(); let str_hash = stark_felt!("0x5d200ef175ba15d676a68b36f7a7b72c17c17604eda4c1efc2ed5e4973e2c91"); let tx_hash = TransactionHash(str_hash); - let sn_tx = rpc_state.get_transaction(&tx_hash); + let sn_tx = rpc_state.get_transaction(&tx_hash).unwrap(); match &sn_tx { SNTransaction::Invoke(sn_tx) => { let tx = @@ -286,7 +287,7 @@ fn test_get_transaction_try_from() { #[test] fn test_get_gas_price() { let block = BlockValue::Number(BlockNumber(169928)); - let rpc_state = RpcState::new_infura(RpcChain::MainNet, block); + let rpc_state = RpcState::new_infura(RpcChain::MainNet, block).unwrap(); let price = rpc_state.get_gas_price(169928).unwrap(); assert_eq!(price, 22804578690); @@ -395,7 +396,6 @@ fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain) actual_fee, .. } = tx_info; - let CallInfo { execution_resources, internal_calls, @@ -551,3 +551,61 @@ fn starknet_in_rust_test_case_declare_tx(hash: &str, block_number: u64, chain: R } } } + +#[test_case( + "0x05dc2a26a65b0fc9e8cb17d8b3e9142abdb2b2d2dd2f3eb275256f23bddfc9f2", + 899787, // real block 899788 + RpcChain::TestNet +)] +fn starknet_in_rust_test_case_tx_skip_nonce_check(hash: &str, block_number: u64, chain: RpcChain) { + let (tx_info, trace, receipt) = + execute_tx_configurable(hash, chain, BlockNumber(block_number), false, true); + + let TransactionExecutionInfo { + call_info, + actual_fee, + .. + } = tx_info; + let CallInfo { + execution_resources, + internal_calls, + .. + } = call_info.unwrap(); + + // check Cairo VM execution resources + assert_eq_sorted!( + execution_resources.as_ref(), + Some( + &trace + .function_invocation + .as_ref() + .unwrap() + .execution_resources + ), + "execution resources mismatch" + ); + + // check amount of internal calls + assert_eq!( + internal_calls.len(), + trace + .function_invocation + .as_ref() + .unwrap() + .internal_calls + .len(), + "internal calls length mismatch" + ); + + // check actual fee calculation + if receipt.actual_fee != actual_fee { + let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee; + + if diff >= 5 { + assert_eq!( + actual_fee, receipt.actual_fee, + "actual_fee mismatch differs from the baseline by more than 5% ({diff}%)", + ); + } + } +} diff --git a/src/definitions/constants.rs b/src/definitions/constants.rs index 4087af325..dcc52cbd2 100644 --- a/src/definitions/constants.rs +++ b/src/definitions/constants.rs @@ -14,11 +14,6 @@ pub(crate) const N_DEFAULT_TOPICS: usize = 1; // Events have one default topic. pub(crate) const CONSUMED_MSG_TO_L2_ENCODED_DATA_SIZE: usize = (L1_TO_L2_MSG_HEADER_SIZE + 1) - CONSUMED_MSG_TO_L2_N_TOPICS; -lazy_static! { - pub(crate) static ref QUERY_VERSION_BASE: Felt252 = - felt_str!("340282366920938463463374607431768211456"); -} - pub(crate) const LOG_MSG_TO_L1_ENCODED_DATA_SIZE: usize = (L2_TO_L1_MSG_HEADER_SIZE + 1) - LOG_MSG_TO_L1_N_TOPICS; @@ -32,17 +27,6 @@ pub(crate) const N_STEPS_FEE_WEIGHT: f64 = 0.01; /// The version is considered 0 for L1-Handler transaction hash calculation purposes. pub(crate) const L1_HANDLER_VERSION: u64 = 0; -lazy_static! { - pub static ref SUPPORTED_VERSIONS: [Felt252; 6] = [ - 0.into(), - 1.into(), - 2.into(), - &Into::::into(0) | &QUERY_VERSION_BASE.clone(), - &Into::::into(1) | &QUERY_VERSION_BASE.clone(), - &Into::::into(2) | &QUERY_VERSION_BASE.clone(), - ]; -} - lazy_static! { // Ratios are taken from the `starknet_instance` CairoLayout object in cairo-lang. pub static ref DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS: HashMap = @@ -113,5 +97,19 @@ lazy_static! { pub static ref VALIDATE_ENTRY_POINT_SELECTOR: Felt252 = felt_str!("626969833899987279399947180575486623810258720106406659648356883742278317941"); + pub static ref VALIDATE_RETDATA: Felt252 = + felt_str!("370462705988"); + pub static ref BLOCK_HASH_CONTRACT_ADDRESS: Address = Address(1.into()); } + +// Indentation for transactions meant to query and not addressed to the OS. +lazy_static! { + static ref QUERY_VERSION_BASE: Felt252 = felt_str!("340282366920938463463374607431768211456"); + pub(crate) static ref QUERY_VERSION_0: Felt252 = + &Into::::into(0) | &*QUERY_VERSION_BASE; + pub(crate) static ref QUERY_VERSION_1: Felt252 = + &Into::::into(1) | &*QUERY_VERSION_BASE; + pub(crate) static ref QUERY_VERSION_2: Felt252 = + &Into::::into(2) | &*QUERY_VERSION_BASE; +} diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index c13994ca9..07641ee85 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -13,7 +13,7 @@ use crate::{ contract_class_cache::ContractClassCache, contract_storage_state::ContractStorageState, state_api::{State, StateReader}, - ExecutionResourcesManager, StateDiff, + ExecutionResourcesManager, }, syscalls::{ business_logic_syscall_handler::BusinessLogicSyscallHandler, @@ -27,7 +27,13 @@ use crate::{ validate_contract_deployed, Address, }, }; +#[cfg(feature = "cairo-native")] +use crate::{state::StateDiff, utils::ClassHash}; +use cairo_lang_sierra::program::Program as SierraProgram; use cairo_lang_starknet::casm_contract_class::{CasmContractClass, CasmContractEntryPoint}; +use cairo_lang_starknet::contract_class::ContractEntryPoints; +#[cfg(feature = "cairo-native")] +use cairo_native::cache::ProgramCache; use cairo_vm::{ felt::Felt252, types::{ @@ -35,6 +41,7 @@ use cairo_vm::{ relocatable::{MaybeRelocatable, Relocatable}, }, vm::{ + errors::runner_errors::RunnerError, runners::cairo_runner::{CairoArg, CairoRunner, ExecutionResources, RunResources}, vm_core::VirtualMachine, }, @@ -166,18 +173,137 @@ impl ExecutionEntryPoint { } } } + #[cfg(not(feature = "cairo-native"))] + CompiledClass::Sierra(_) => { + unimplemented!("Use the feature 'cairo-native' to enable native execution") + } + #[cfg(feature = "cairo-native")] + CompiledClass::Sierra(sierra_program_and_entrypoints) => { + let mut transactional_state = state.create_transactional(); + + let native_context = NativeContext::new(); + let program_cache = Rc::new(RefCell::new(ProgramCache::new(&native_context))); + + match self.native_execute( + &mut transactional_state, + sierra_program_and_entrypoints, + tx_execution_context, + block_context, + &class_hash, + program_cache, + ) { + Ok(call_info) => { + state.apply_state_update(&StateDiff::from_cached_state( + transactional_state.cache(), + )?)?; + + Ok(ExecutionResult { + call_info: Some(call_info), + revert_error: None, + n_reverted_steps: 0, + }) + } + Err(e) => { + if !support_reverted { + state.apply_state_update(&StateDiff::from_cached_state( + transactional_state.cache(), + )?)?; + + return Err(e); + } + + let n_reverted_steps = + (max_steps as usize) - resources_manager.cairo_usage.n_steps; + Ok(ExecutionResult { + call_info: None, + revert_error: Some(e.to_string()), + n_reverted_steps, + }) + } + } + } + } + } + + #[cfg(feature = "cairo-native")] + pub fn execute_with_native_cache( + &self, + state: &mut CachedState, + block_context: &BlockContext, + resources_manager: &mut ExecutionResourcesManager, + tx_execution_context: &mut TransactionExecutionContext, + support_reverted: bool, + max_steps: u64, + program_cache: Rc>>, + ) -> Result + where + T: StateReader, + { + // lookup the compiled class from the state. + let class_hash = self.get_code_class_hash(state)?; + let contract_class = state + .get_contract_class(&class_hash) + .map_err(|_| TransactionError::MissingCompiledClass)?; + match contract_class { + CompiledClass::Deprecated(contract_class) => { + let call_info = self._execute_version0_class( + state, + resources_manager, + block_context, + tx_execution_context, + contract_class, + class_hash, + )?; + Ok(ExecutionResult { + call_info: Some(call_info), + revert_error: None, + n_reverted_steps: 0, + }) + } + CompiledClass::Casm(contract_class) => { + match self._execute( + state, + resources_manager, + block_context, + tx_execution_context, + contract_class, + class_hash, + support_reverted, + ) { + Ok(call_info) => Ok(ExecutionResult { + call_info: Some(call_info), + revert_error: None, + n_reverted_steps: 0, + }), + Err(e) => { + if !support_reverted { + return Err(e); + } + + let n_reverted_steps = + (max_steps as usize) - resources_manager.cairo_usage.n_steps; + Ok(ExecutionResult { + call_info: None, + revert_error: Some(e.to_string()), + n_reverted_steps, + }) + } + } + } CompiledClass::Sierra(sierra_contract_class) => { - let mut transactional_state = state.create_transactional()?; + let mut transactional_state = state.create_transactional(); match self.native_execute( &mut transactional_state, sierra_contract_class, tx_execution_context, block_context, + &class_hash, + program_cache, ) { Ok(call_info) => { state.apply_state_update(&StateDiff::from_cached_state( - transactional_state, + transactional_state.cache(), )?)?; Ok(ExecutionResult { @@ -189,7 +315,7 @@ impl ExecutionEntryPoint { Err(e) => { if !support_reverted { state.apply_state_update(&StateDiff::from_cached_state( - transactional_state, + transactional_state.cache(), )?)?; return Err(e); @@ -344,24 +470,24 @@ impl ExecutionEntryPoint { /// Returns the hash of the executed contract class. fn get_code_class_hash(&self, state: &mut S) -> Result<[u8; 32], TransactionError> { - if self.class_hash.is_some() { - return match self.call_type { - CallType::Delegate => Ok(self.class_hash.unwrap()), - _ => Err(TransactionError::CallTypeIsNotDelegate), - }; + if let Some(class_hash) = self.class_hash { + match self.call_type { + CallType::Delegate => return Ok(class_hash), + _ => return Err(TransactionError::CallTypeIsNotDelegate), + } } let code_address = match self.call_type { - CallType::Call => Some(self.contract_address.clone()), + CallType::Call => &self.contract_address, CallType::Delegate => { - if self.code_address.is_some() { - self.code_address.clone() + if let Some(ref code_address) = self.code_address { + code_address } else { return Err(TransactionError::AttempToUseNoneCodeAddress); } } }; - get_deployed_address_class_hash_at_address(state, &code_address.unwrap()) + get_deployed_address_class_hash_at_address(state, code_address) } fn _execute_version0_class( @@ -528,7 +654,6 @@ impl ExecutionEntryPoint { ); let mut runner = StarknetRunner::new(cairo_runner, vm, hint_processor); - // TODO: handle error cases // Load builtin costs let builtin_costs: Vec = vec![0.into(), 0.into(), 0.into(), 0.into(), 0.into()]; @@ -539,14 +664,16 @@ impl ExecutionEntryPoint { .into(); // Load extra data - let core_program_end_ptr = - (runner.cairo_runner.program_base.unwrap() + program.data_len()).unwrap(); + let core_program_end_ptr = (runner + .cairo_runner + .program_base + .ok_or(RunnerError::NoProgBase)? + + program.data_len())?; let program_extra_data: Vec = vec![0x208B7FFF7FFF7FFE.into(), builtin_costs_ptr]; runner .vm - .load_data(core_program_end_ptr, &program_extra_data) - .unwrap(); + .load_data(core_program_end_ptr, &program_extra_data)?; // Positional arguments are passed to *args in the 'run_from_entrypoint' function. let data = self.calldata.iter().map(|d| d.into()).collect(); @@ -562,7 +689,7 @@ impl ExecutionEntryPoint { .collect(); entrypoint_args.push(CairoArg::Single(alloc_pointer.clone())); entrypoint_args.push(CairoArg::Single( - alloc_pointer.add_usize(self.calldata.len()).unwrap(), + alloc_pointer.add_usize(self.calldata.len())?, )); let ref_vec: Vec<&CairoArg> = entrypoint_args.iter().collect(); @@ -586,11 +713,11 @@ impl ExecutionEntryPoint { .get_initial_fp() .ok_or(TransactionError::MissingInitialFp)?; - let args_ptr = initial_fp - (entrypoint_args.len() + 2); + let args_ptr = (initial_fp - (entrypoint_args.len() + 2))?; runner .vm - .mark_address_range_as_accessed(args_ptr.unwrap(), entrypoint_args.len())?; + .mark_address_range_as_accessed(args_ptr, entrypoint_args.len())?; *resources_manager = runner .hint_processor @@ -621,10 +748,11 @@ impl ExecutionEntryPoint { #[cfg(not(feature = "cairo-native"))] #[inline(always)] + #[allow(dead_code)] fn native_execute( &self, _state: &mut CachedState, - _contract_class: Arc, + _sierra_program_and_entrypoints: Arc<(SierraProgram, ContractEntryPoints)>, _tx_execution_context: &mut TransactionExecutionContext, _block_context: &BlockContext, ) -> Result { @@ -638,9 +766,11 @@ impl ExecutionEntryPoint { fn native_execute( &self, state: &mut CachedState, - contract_class: Arc, + sierra_program_and_entrypoints: Arc<(SierraProgram, ContractEntryPoints)>, tx_execution_context: &TransactionExecutionContext, block_context: &BlockContext, + class_hash: &[u8; 32], + program_cache: Rc>>, ) -> Result { use cairo_lang_sierra::{ extensions::core::{CoreLibfunc, CoreType, CoreTypeConcrete}, @@ -649,34 +779,39 @@ impl ExecutionEntryPoint { use serde_json::json; use crate::syscalls::business_logic_syscall_handler::SYSCALL_BASE; + let sierra_program = &sierra_program_and_entrypoints.0; + let contract_entrypoints = &sierra_program_and_entrypoints.1; let entry_point = match self.entry_point_type { - EntryPointType::External => contract_class - .entry_points_by_type + EntryPointType::External => contract_entrypoints .external .iter() .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) .unwrap(), - EntryPointType::Constructor => contract_class - .entry_points_by_type + EntryPointType::Constructor => contract_entrypoints .constructor .iter() .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) .unwrap(), - EntryPointType::L1Handler => contract_class - .entry_points_by_type + EntryPointType::L1Handler => contract_entrypoints .l1_handler .iter() .find(|entry_point| entry_point.selector == self.entry_point_selector.to_biguint()) .unwrap(), }; - let sierra_program = contract_class.extract_sierra_program().unwrap(); let program_registry: ProgramRegistry = - ProgramRegistry::new(&sierra_program).unwrap(); + ProgramRegistry::new(sierra_program).unwrap(); + + let native_executor = { + let mut cache = program_cache.borrow_mut(); + if let Some(executor) = cache.get(*class_hash) { + executor + } else { + cache.compile_and_insert(*class_hash, sierra_program) + } + }; - let native_context = NativeContext::new(); - let mut native_program = native_context.compile(&sierra_program).unwrap(); let contract_storage_state = ContractStorageState::new(state, self.contract_address.clone()); @@ -690,14 +825,22 @@ impl ExecutionEntryPoint { entry_point_selector: self.entry_point_selector.clone(), tx_execution_context: tx_execution_context.clone(), block_context: block_context.clone(), + program_cache: program_cache.clone(), resources_manager: Default::default(), }; - native_program - .insert_metadata(SyscallHandlerMeta::new(&syscall_handler)) - .unwrap(); + native_executor + .borrow_mut() + .get_module_mut() + .remove_metadata::(); + native_executor + .borrow_mut() + .get_module_mut() + .insert_metadata(SyscallHandlerMeta::new(&syscall_handler)); - let syscall_addr = native_program + let syscall_addr = native_executor + .borrow() + .get_module() .get_metadata::() .unwrap() .as_ptr() @@ -716,7 +859,10 @@ impl ExecutionEntryPoint { .collect(); let entry_point_id = &entry_point_fn.id; - let required_init_gas = native_program.get_required_init_gas(entry_point_id); + let required_init_gas = native_executor + .borrow() + .get_module() + .get_required_init_gas(entry_point_id); let calldata: Vec<_> = self .calldata @@ -760,9 +906,8 @@ impl ExecutionEntryPoint { let mut writer: Vec = Vec::new(); let returns = &mut serde_json::Serializer::new(&mut writer); - let native_executor = NativeExecutor::new(native_program); - native_executor + .borrow() .execute(entry_point_id, json!(params), returns, required_init_gas) .map_err(|e| TransactionError::CustomError(format!("cairo-native error: {:?}", e)))?; diff --git a/src/execution/mod.rs b/src/execution/mod.rs index 5c9774517..2ee902982 100644 --- a/src/execution/mod.rs +++ b/src/execution/mod.rs @@ -1,8 +1,6 @@ pub mod execution_entry_point; pub mod gas_usage; pub mod os_usage; - -use crate::definitions::constants::QUERY_VERSION_BASE; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use crate::utils::parse_felt_array; use crate::{ @@ -383,8 +381,8 @@ impl TransactionExecutionContext { n_steps: u64, version: Felt252, ) -> Self { - let nonce = if version == 0.into() || version == *QUERY_VERSION_BASE { - 0.into() + let nonce = if version == 0.into() { + Felt252::zero() } else { nonce }; diff --git a/src/execution/os_usage.rs b/src/execution/os_usage.rs index 5e6b1aad7..7a49bdcdd 100644 --- a/src/execution/os_usage.rs +++ b/src/execution/os_usage.rs @@ -4,6 +4,12 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use crate::{definitions::transaction_type::TransactionType, transaction::error::TransactionError}; +pub(crate) const ESTIMATED_INVOKE_FUNCTION_STEPS: usize = 3363; +pub(crate) const ESTIMATED_DECLARE_STEPS: usize = 2703; +pub(crate) const ESTIMATED_DEPLOY_STEPS: usize = 0; +pub(crate) const ESTIMATED_DEPLOY_ACCOUNT_STEPS: usize = 3612; +pub(crate) const ESTIMATED_L1_HANDLER_STEPS: usize = 1068; + #[derive(Debug, Clone)] pub struct OsResources { execute_syscalls: HashMap, @@ -16,7 +22,7 @@ impl Default for OsResources { ( TransactionType::InvokeFunction, ExecutionResources { - n_steps: 3363, + n_steps: ESTIMATED_INVOKE_FUNCTION_STEPS, n_memory_holes: 0, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 16), @@ -27,7 +33,7 @@ impl Default for OsResources { ( TransactionType::Declare, ExecutionResources { - n_steps: 2703, + n_steps: ESTIMATED_DECLARE_STEPS, n_memory_holes: 0, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 15), @@ -38,7 +44,7 @@ impl Default for OsResources { ( TransactionType::Deploy, ExecutionResources { - n_steps: 0, + n_steps: ESTIMATED_DEPLOY_STEPS, n_memory_holes: 0, builtin_instance_counter: HashMap::new(), }, @@ -46,7 +52,7 @@ impl Default for OsResources { ( TransactionType::DeployAccount, ExecutionResources { - n_steps: 3612, + n_steps: ESTIMATED_DEPLOY_ACCOUNT_STEPS, n_memory_holes: 0, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 23), @@ -57,7 +63,7 @@ impl Default for OsResources { ( TransactionType::L1Handler, ExecutionResources { - n_steps: 1068, + n_steps: ESTIMATED_L1_HANDLER_STEPS, n_memory_holes: 0, builtin_instance_counter: HashMap::from([ ("pedersen_builtin".to_string(), 11), diff --git a/src/lib.rs b/src/lib.rs index 205b218a3..208b89494 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -856,7 +856,7 @@ mod test { DeployAccount::new( *CLASS_HASH_BYTES, 0, - 0.into(), + 1.into(), Felt252::zero(), vec![], SIGNATURE.clone(), @@ -891,8 +891,8 @@ mod test { DeclareV2 { sender_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), validate_entry_point_selector: VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(), - version: 1.into(), - max_fee: INITIAL_GAS_COST, + version: 2.into(), + max_fee: 2900, signature: vec![], nonce: 0.into(), hash_value: 0.into(), @@ -903,6 +903,7 @@ mod test { skip_execute: false, skip_fee_transfer: false, skip_validate: false, + skip_nonce_check: false, } } diff --git a/src/services/api/contract_classes/compiled_class.rs b/src/services/api/contract_classes/compiled_class.rs index 26b56281f..4ac80403e 100644 --- a/src/services/api/contract_classes/compiled_class.rs +++ b/src/services/api/contract_classes/compiled_class.rs @@ -8,6 +8,7 @@ use crate::services::api::contract_classes::deprecated_contract_class::AbiType; use crate::{ContractEntryPoint, EntryPointType}; use super::deprecated_contract_class::ContractClass; +use cairo_lang_sierra::program::Program as SierraProgram; use cairo_lang_starknet::abi::Contract; use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_lang_starknet::contract_class::{ @@ -24,7 +25,7 @@ use starknet::core::types::ContractClass::{Legacy, Sierra}; pub enum CompiledClass { Deprecated(Arc), Casm(Arc), - Sierra(Arc), + Sierra(Arc<(SierraProgram, ContractEntryPoints)>), } impl TryInto for CompiledClass { diff --git a/src/state/mod.rs b/src/state/mod.rs index ef6efc242..14f786900 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -1,5 +1,6 @@ use self::{ cached_state::CachedState, contract_class_cache::ContractClassCache, state_api::StateReader, + state_cache::StateCache, }; use crate::{ core::errors::state_errors::StateError, @@ -125,19 +126,13 @@ impl StateDiff { } } - pub fn from_cached_state(cached_state: CachedState) -> Result - where - T: StateReader, - C: ContractClassCache, - { - let state_cache = cached_state.cache().to_owned(); - - let substracted_maps = state_cache.storage_writes; - let storage_updates = to_state_diff_storage_mapping(&substracted_maps); + pub fn from_cached_state(state_cache: &StateCache) -> Result { + let substracted_maps = &state_cache.storage_writes; + let storage_updates = to_state_diff_storage_mapping(substracted_maps); - let address_to_nonce = state_cache.nonce_writes; - let class_hash_to_compiled_class = state_cache.compiled_class_hash_writes; - let address_to_class_hash = state_cache.class_hash_writes; + let address_to_nonce = state_cache.nonce_writes.clone(); + let class_hash_to_compiled_class = state_cache.compiled_class_hash_writes.clone(); + let address_to_class_hash = state_cache.class_hash_writes.clone(); Ok(StateDiff { address_to_class_hash, @@ -257,7 +252,7 @@ mod test { Arc::new(PermanentContractClassCache::default()), ); - let diff = StateDiff::from_cached_state(cached_state).unwrap(); + let diff = StateDiff::from_cached_state(&cached_state.cache).unwrap(); assert_eq!(0, diff.storage_updates.len()); } @@ -330,7 +325,7 @@ mod test { Arc::new(PermanentContractClassCache::default()), ); - let diff = StateDiff::from_cached_state(cached_state_original.clone_for_testing()).unwrap(); + let diff = StateDiff::from_cached_state(cached_state_original.cache()).unwrap(); let cached_state = diff .to_cached_state::<_, PermanentContractClassCache>( @@ -390,7 +385,7 @@ mod test { Arc::new(PermanentContractClassCache::default()), ); - let mut diff = StateDiff::from_cached_state(cached_state).unwrap(); + let mut diff = StateDiff::from_cached_state(cached_state.cache()).unwrap(); let diff_squashed = diff.squash(diff.clone()); diff --git a/src/state/state_api.rs b/src/state/state_api.rs index 4abe12354..87a2ed6b6 100644 --- a/src/state/state_api.rs +++ b/src/state/state_api.rs @@ -1,9 +1,10 @@ use super::state_cache::StorageEntry; use crate::{ core::errors::state_errors::StateError, + definitions::block_context::BlockContext, services::api::contract_classes::compiled_class::CompiledClass, state::StateDiff, - utils::{Address, ClassHash, CompiledClassHash}, + utils::{get_erc20_balance_var_addresses, Address, ClassHash, CompiledClassHash}, }; use cairo_lang_utils::bigint::BigUintAsHex; use cairo_vm::felt::Felt252; @@ -24,6 +25,30 @@ pub trait StateReader { &self, class_hash: &ClassHash, ) -> Result; + /// Returns the storage value representing the balance (in fee token) at the given address as a (low, high) pair + fn get_fee_token_balance( + &mut self, + block_context: &BlockContext, + contract_address: &Address, + ) -> Result<(Felt252, Felt252), StateError> { + let (low_key, high_key) = get_erc20_balance_var_addresses(contract_address)?; + let low = self.get_storage_at(&( + block_context + .starknet_os_config() + .fee_token_address() + .clone(), + low_key, + ))?; + let high = self.get_storage_at(&( + block_context + .starknet_os_config() + .fee_token_address() + .clone(), + high_key, + ))?; + + Ok((low, high)) + } } #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/src/syscalls/business_logic_syscall_handler.rs b/src/syscalls/business_logic_syscall_handler.rs index 42925bf16..e34a968b4 100644 --- a/src/syscalls/business_logic_syscall_handler.rs +++ b/src/syscalls/business_logic_syscall_handler.rs @@ -73,6 +73,7 @@ lazy_static! { 94901967946959054011942058057773508207_u128.into(), "get_execution_info", ); + map.insert(22096086224907272360718070632_u128.into(), "get_block_hash"); map.insert(100890693370601760042082660_u128.into(), "storage_read"); map.insert(20853273475220472486191784820_u128.into(), "call_contract"); map.insert( @@ -114,6 +115,7 @@ lazy_static! { map.insert("send_message_to_l1", SYSCALL_BASE + 50 * STEP); map.insert("get_block_timestamp", 0); map.insert("keccak", 0); + map.insert("get_block_hash", SYSCALL_BASE + 50 * STEP); map }; @@ -316,7 +318,9 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(_) => todo!(), + CompiledClass::Sierra(class_and_entrypoints) => { + Ok(class_and_entrypoints.1.constructor.is_empty()) + } } } @@ -860,6 +864,7 @@ impl<'a, S: StateReader, C: ContractClassCache> BusinessLogicSyscallHandler<'a, "library_call" => LibraryCallRequest::from_ptr(vm, syscall_ptr), "deploy" => DeployRequest::from_ptr(vm, syscall_ptr), "get_block_number" => Ok(SyscallRequest::GetBlockNumber), + "get_block_hash" => GetBlockHashRequest::from_ptr(vm, syscall_ptr), "storage_write" => StorageWriteRequest::from_ptr(vm, syscall_ptr), "get_execution_info" => Ok(SyscallRequest::GetExecutionInfo), "send_message_to_l1" => SendMessageToL1Request::from_ptr(vm, syscall_ptr), diff --git a/src/syscalls/deprecated_business_logic_syscall_handler.rs b/src/syscalls/deprecated_business_logic_syscall_handler.rs index 56817de19..83b039b2e 100644 --- a/src/syscalls/deprecated_business_logic_syscall_handler.rs +++ b/src/syscalls/deprecated_business_logic_syscall_handler.rs @@ -193,7 +193,7 @@ impl<'a, S: StateReader, C: ContractClassCache> DeprecatedBLSyscallHandler<'a, S .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(_) => todo!(), + CompiledClass::Sierra(_) => Err(ContractClassError::NotADeprecatedContractClass.into()), } } diff --git a/src/syscalls/deprecated_syscall_handler.rs b/src/syscalls/deprecated_syscall_handler.rs index 997f684df..1c33b2af8 100644 --- a/src/syscalls/deprecated_syscall_handler.rs +++ b/src/syscalls/deprecated_syscall_handler.rs @@ -1221,7 +1221,7 @@ mod tests { .unwrap(); state - .apply_state_update(&StateDiff::from_cached_state(transactional).unwrap()) + .apply_state_update(&StateDiff::from_cached_state(transactional.cache()).unwrap()) .unwrap(); let result_call_info = result.call_info.unwrap(); diff --git a/src/syscalls/native_syscall_handler.rs b/src/syscalls/native_syscall_handler.rs index 00386eaea..275b9694f 100644 --- a/src/syscalls/native_syscall_handler.rs +++ b/src/syscalls/native_syscall_handler.rs @@ -1,9 +1,12 @@ -use crate::ContractClassCache; -use cairo_native::starknet::{ - BlockInfo, ExecutionInfo, StarkNetSyscallHandler, SyscallResult, TxInfo, U256, +use std::{cell::RefCell, rc::Rc}; + +use cairo_native::{ + cache::ProgramCache, + starknet::{BlockInfo, ExecutionInfo, StarkNetSyscallHandler, SyscallResult, TxInfo, U256}, }; use cairo_vm::felt::Felt252; use num_traits::Zero; +use starknet::core::utils::cairo_short_string_to_felt; use crate::definitions::constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR; use crate::execution::CallResult; @@ -11,6 +14,7 @@ use crate::hash_utils::calculate_contract_address; use crate::services::api::contract_class_errors::ContractClassError; use crate::services::api::contract_classes::compiled_class::CompiledClass; use crate::state::state_api::State; +use crate::syscalls::business_logic_syscall_handler::KECCAK_ROUND_COST; use crate::utils::felt_to_hash; use crate::utils::ClassHash; use crate::{ @@ -25,29 +29,31 @@ use crate::{ ExecutionResourcesManager, }, syscalls::business_logic_syscall_handler::{SYSCALL_BASE, SYSCALL_GAS_COST}, + syscalls::syscall_handler_errors::SyscallHandlerError, + transaction::error::TransactionError, utils::Address, EntryPointType, }; #[derive(Debug)] -pub struct NativeSyscallHandler<'a, S, C> +pub struct NativeSyscallHandler<'a, 'cache, S> where S: StateReader, - C: ContractClassCache, { - pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, + pub(crate) starknet_storage_state: ContractStorageState<'a, S>, pub(crate) contract_address: Address, pub(crate) caller_address: Address, pub(crate) entry_point_selector: Felt252, pub(crate) events: Vec, pub(crate) l2_to_l1_messages: Vec, + pub(crate) resources_manager: ExecutionResourcesManager, pub(crate) tx_execution_context: TransactionExecutionContext, pub(crate) block_context: BlockContext, pub(crate) internal_calls: Vec, - pub(crate) resources_manager: ExecutionResourcesManager, + pub(crate) program_cache: Rc>>, } -impl<'a, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, S, C> { +impl<'a, 'cache, S: StateReader> NativeSyscallHandler<'a, 'cache, S> { /// Generic code that needs to be run on all syscalls. fn handle_syscall_request(&mut self, gas: &mut u128, syscall_name: &str) -> SyscallResult<()> { let required_gas = SYSCALL_GAS_COST @@ -57,7 +63,7 @@ impl<'a, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, S, C> { if *gas < required_gas { let out_of_gas_felt = Felt252::from_bytes_be("Out of gas".as_bytes()); - println!("out of gas!: {:?} < {:?}", *gas, required_gas); // TODO: remove once all other prints are removed + tracing::debug!("out of gas!: {:?} < {:?}", *gas, required_gas); return Err(vec![out_of_gas_felt.clone()]); } @@ -70,26 +76,34 @@ impl<'a, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, S, C> { } } -impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler - for NativeSyscallHandler<'a, S, C> -{ +impl<'a, 'cache, S: StateReader> StarkNetSyscallHandler for NativeSyscallHandler<'a, 'cache, S> { fn get_block_hash( &mut self, block_number: u64, gas: &mut u128, ) -> SyscallResult { - println!("Called `get_block_hash({block_number})` from MLIR."); + tracing::debug!("Called `get_block_hash({block_number})` from Cairo Native"); self.handle_syscall_request(gas, "get_block_hash")?; - Ok(Felt252::from_bytes_be(b"get_block_hash ok")) + let key: Felt252 = block_number.into(); + let block_hash_address = Address(1.into()); + + match self + .starknet_storage_state + .state + .get_storage_at(&(block_hash_address, key.to_be_bytes())) + { + Ok(value) => Ok(value), + Err(_) => Ok(Felt252::zero()), + } } fn get_execution_info( &mut self, gas: &mut u128, ) -> SyscallResult { - println!("Called `get_execution_info()` from MLIR."); + tracing::debug!("Called `get_execution_info()` from Cairo Native"); self.handle_syscall_request(gas, "get_execution_info")?; @@ -126,6 +140,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler deploy_from_zero: bool, gas: &mut u128, ) -> SyscallResult<(cairo_vm::felt::Felt252, Vec)> { + tracing::debug!("Called `deploy({class_hash}, {calldata:?})` from Cairo Native"); self.handle_syscall_request(gas, "deploy")?; let deployer_address = if deploy_from_zero { @@ -176,15 +191,21 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler )) } - fn replace_class( - &mut self, - class_hash: cairo_vm::felt::Felt252, - gas: &mut u128, - ) -> SyscallResult<()> { - println!("Called `replace_class({class_hash})` from MLIR."); + fn replace_class(&mut self, class_hash: Felt252, gas: &mut u128) -> SyscallResult<()> { + tracing::debug!("Called `replace_class({class_hash})` from Cairo Native"); self.handle_syscall_request(gas, "replace_class")?; - Ok(()) + match self + .starknet_storage_state + .state + .set_class_hash_at(self.contract_address.clone(), class_hash.to_be_bytes()) + { + Ok(_) => Ok(()), + Err(e) => { + let replace_class_felt = Felt252::from_bytes_be(e.to_string().as_bytes()); + Err(vec![replace_class_felt.clone()]) + } + } } fn library_call( @@ -194,13 +215,60 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler calldata: &[cairo_vm::felt::Felt252], gas: &mut u128, ) -> SyscallResult> { - println!( - "Called `library_call({class_hash}, {function_selector}, {calldata:?})` from MLIR." + tracing::debug!( + "Called `library_call({class_hash}, {function_selector}, {calldata:?})` from Cairo Native" ); self.handle_syscall_request(gas, "library_call")?; - Ok(calldata.iter().map(|x| x * &Felt252::new(3)).collect()) + let execution_entry_point = ExecutionEntryPoint::new( + self.contract_address.clone(), + calldata.to_vec(), + function_selector, + self.caller_address.clone(), + EntryPointType::External, + Some(CallType::Delegate), + Some(class_hash.to_be_bytes()), + *gas, + ); + + let ExecutionResult { + call_info, + revert_error, + .. + } = execution_entry_point.execute( + self.starknet_storage_state.state, + &self.block_context, + &mut self.resources_manager, + &mut self.tx_execution_context, + false, + self.block_context.invoke_tx_max_n_steps, + )?; + + let call_info = call_info.ok_or(SyscallHandlerError::ExecutionError( + revert_error.unwrap_or_else(|| "Execution error".to_string()), + ))?; + + let remaining_gas = gas.saturating_sub(call_info.gas_consumed); + *gas = remaining_gas; + + let failure_flag = call_info.failure_flag; + let retdata = call_info.retdata.clone(); + + self.starknet_storage_state + .read_values + .extend(call_info.storage_read_values.clone()); + self.starknet_storage_state + .accessed_keys + .extend(call_info.accessed_storage_keys.clone()); + + self.internal_calls.push(call_info); + + if failure_flag { + Err(retdata) + } else { + Ok(retdata) + } } fn call_contract( @@ -210,8 +278,8 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler calldata: &[cairo_vm::felt::Felt252], gas: &mut u128, ) -> SyscallResult> { - println!( - "Called `call_contract({address}, {entrypoint_selector}, {calldata:?})` from MLIR." + tracing::debug!( + "Called `call_contract({address}, {entrypoint_selector}, {calldata:?})` from Cairo Native" ); self.handle_syscall_request(gas, "call_contract")?; @@ -229,7 +297,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler ); let ExecutionResult { call_info, .. } = exec_entry_point - .execute( + .execute_with_native_cache( self.starknet_storage_state.state, // TODO: This fields dont make much sense in the Cairo Native context, // they are only dummy values for the `execute` method. @@ -238,6 +306,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler &mut self.tx_execution_context, false, self.block_context.invoke_tx_max_n_steps, + self.program_cache.clone(), ) .unwrap(); @@ -265,7 +334,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler address: cairo_vm::felt::Felt252, gas: &mut u128, ) -> SyscallResult { - println!("Called `storage_read({address_domain}, {address})` from MLIR."); + tracing::debug!("Called `storage_read({address_domain}, {address})` from Cairo Native"); self.handle_syscall_request(gas, "storage_read")?; @@ -275,7 +344,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler Err(_) => Ok(Felt252::zero()), }; - println!(" = {value:?}` from MLIR."); + tracing::debug!(" = {value:?}` from Cairo Native"); value } @@ -287,7 +356,9 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler value: cairo_vm::felt::Felt252, gas: &mut u128, ) -> SyscallResult<()> { - println!("Called `storage_write({address_domain}, {address}, {value})` from MLIR."); + tracing::debug!( + "Called `storage_write({address_domain}, {address}, {value})` from Cairo Native" + ); self.handle_syscall_request(gas, "storage_write")?; @@ -303,7 +374,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler gas: &mut u128, ) -> SyscallResult<()> { let order = self.tx_execution_context.n_emitted_events; - println!("Called `emit_event(KEYS: {keys:?}, DATA: {data:?})` from MLIR."); + tracing::debug!("Called `emit_event(KEYS: {keys:?}, DATA: {data:?})` from Cairo Native"); self.handle_syscall_request(gas, "emit_event")?; @@ -319,7 +390,7 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler payload: &[cairo_vm::felt::Felt252], gas: &mut u128, ) -> SyscallResult<()> { - println!("Called `send_message_to_l1({to_address}, {payload:?})` from MLIR."); + tracing::debug!("Called `send_message_to_l1({to_address}, {payload:?})` from Cairo Native"); self.handle_syscall_request(gas, "send_message_to_l1")?; @@ -341,11 +412,45 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler input: &[u64], gas: &mut u128, ) -> SyscallResult { - println!("Called `keccak({input:?})` from MLIR."); + tracing::debug!("Called `keccak({input:?})` from Cairo Native"); self.handle_syscall_request(gas, "keccak")?; - Ok(U256(Felt252::from(1234567890).to_le_bytes())) + let length = input.len(); + + if length % 17 != 0 { + let error_msg = b"Invalid keccak input size"; + let felt_error = Felt252::from_bytes_be(error_msg); + return Err(vec![felt_error]); + } + + let n_chunks = length / 17; + let mut state = [0u64; 25]; + + for i in 0..n_chunks { + if *gas < KECCAK_ROUND_COST { + let error_msg = b"Syscall out of gas"; + let felt_error = Felt252::from_bytes_be(error_msg); + return Err(vec![felt_error]); + } + *gas -= KECCAK_ROUND_COST; + let chunk = &input[i * 17..(i + 1) * 17]; //(request.input_start + i * 17)?; + for (i, val) in chunk.iter().enumerate() { + state[i] ^= val; + } + keccak::f1600(&mut state) + } + // state[0] and state[1] conform the hash_low (u128) + // state[2] and state[3] conform the hash_high (u128) + let hash = [ + state[0].to_le_bytes(), + state[1].to_le_bytes(), + state[2].to_le_bytes(), + state[3].to_le_bytes(), + ] + .concat(); + + SyscallResult::Ok(U256(hash[0..32].try_into().unwrap())) } fn secp256k1_add( @@ -489,10 +594,9 @@ impl<'a, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler } } -impl<'a, S, C> NativeSyscallHandler<'a, S, C> +impl<'a, 'cache, S> NativeSyscallHandler<'a, 'cache, S> where S: StateReader, - C: ContractClassCache, { fn execute_constructor_entry_point( &mut self, @@ -517,7 +621,7 @@ where if self.constructor_entry_points_empty(compiled_class)? { if !constructor_calldata.is_empty() { - return Err(StateError::ConstructorCalldataEmpty); + return Err(StateError::ConstructorCalldataEmpty()); } let call_info = CallInfo::empty_constructor_call( @@ -550,7 +654,7 @@ where false, u64::MAX, ) - .map_err(|_| StateError::ExecutionEntryPoint)?; + .map_err(|_| StateError::ExecutionEntryPoint())?; let call_info = call_info.ok_or(StateError::CustomError("Execution error".to_string()))?; @@ -570,7 +674,81 @@ where .ok_or(ContractClassError::NoneEntryPointType)? .is_empty()), CompiledClass::Casm(class) => Ok(class.entry_points_by_type.constructor.is_empty()), - CompiledClass::Sierra(class) => Ok(class.entry_points_by_type.constructor.is_empty()), + CompiledClass::Sierra(sierra_program_and_entrypoints) => { + Ok(sierra_program_and_entrypoints.1.constructor.is_empty()) + } + } + } +} + +impl From for Vec { + fn from(value: TransactionError) -> Self { + #[inline] + fn str_to_felt(x: &str) -> Felt252 { + let felt = cairo_short_string_to_felt(x).expect("shouldnt fail"); + Felt252::from_bytes_be(&felt.to_bytes_be()) + } + + let value = value.to_string(); + + if value.len() < 32 { + vec![str_to_felt(&value)] + } else { + let mut felts = vec![]; + let mut buffer = Vec::with_capacity(31); + + for c in value.chars() { + buffer.push(c); + + if buffer.len() == 31 { + let value: String = buffer.iter().collect(); + felts.push(str_to_felt(&value)); + buffer.clear(); + } + } + + if !buffer.is_empty() { + let value: String = buffer.iter().collect(); + felts.push(str_to_felt(&value)); + } + + felts + } + } +} + +impl From for Vec { + fn from(value: SyscallHandlerError) -> Self { + #[inline] + fn str_to_felt(x: &str) -> Felt252 { + let felt = cairo_short_string_to_felt(x).expect("shouldnt fail"); + Felt252::from_bytes_be(&felt.to_bytes_be()) + } + + let value = value.to_string(); + + if value.len() < 32 { + vec![str_to_felt(&value)] + } else { + let mut felts = vec![]; + let mut buffer = Vec::with_capacity(31); + + for c in value.chars() { + buffer.push(c); + + if buffer.len() == 31 { + let value: String = buffer.iter().collect(); + felts.push(str_to_felt(&value)); + buffer.clear(); + } + } + + if !buffer.is_empty() { + let value: String = buffer.iter().collect(); + felts.push(str_to_felt(&value)); + } + + felts } } } diff --git a/src/syscalls/syscall_info.rs b/src/syscalls/syscall_info.rs index f607c4ee0..c2a2d9b95 100644 --- a/src/syscalls/syscall_info.rs +++ b/src/syscalls/syscall_info.rs @@ -10,6 +10,7 @@ pub fn get_syscall_size_from_name(syscall_name: &str) -> usize { "call_contract" => 4, "replace_class" => 1, "keccak" => 2, + "get_block_hash" => 1, _ => unimplemented!(), } } diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index bf173065c..e5dd10323 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -1,29 +1,26 @@ -use super::fee::charge_fee; -use super::{verify_version, Transaction}; +use crate::definitions::block_context::BlockContext; +use crate::definitions::constants::VALIDATE_DECLARE_ENTRY_POINT_SELECTOR; +use crate::definitions::transaction_type::TransactionType; +use crate::execution::gas_usage::get_onchain_data_segment_length; +use crate::execution::os_usage::ESTIMATED_DECLARE_STEPS; +use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; +use crate::services::eth_definitions::eth_gas_constants::SHARP_GAS_PER_MEMORY_WORD; +use crate::state::cached_state::CachedState; use crate::state::contract_class_cache::ContractClassCache; +use crate::state::state_api::{State, StateChangesCount, StateReader}; use crate::{ core::{ contract_address::compute_deprecated_class_hash, transaction_hash::calculate_declare_transaction_hash, }, - definitions::{ - block_context::BlockContext, - constants::{QUERY_VERSION_BASE, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR}, - transaction_type::TransactionType, - }, execution::{ execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, CallInfo, TransactionExecutionContext, TransactionExecutionInfo, }, services::api::contract_classes::{ - compiled_class::CompiledClass, - deprecated_contract_class::{ContractClass, EntryPointType}, - }, - state::{ - cached_state::CachedState, - state_api::{State, StateReader}, - ExecutionResourcesManager, + compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, + state::ExecutionResourcesManager, transaction::error::TransactionError, utils::{ calculate_tx_resources, felt_to_hash, verify_no_calls_to_other_contracts, Address, @@ -31,8 +28,11 @@ use crate::{ }, }; use cairo_vm::felt::Felt252; -use num_traits::Zero; +use num_traits::{One, Zero}; +use super::fee::{calculate_tx_fee, charge_fee}; +use super::{get_tx_version, Transaction}; +use std::collections::HashMap; use std::fmt::Debug; use std::sync::Arc; @@ -53,6 +53,7 @@ pub struct Declare { pub skip_validate: bool, pub skip_execute: bool, pub skip_fee_transfer: bool, + pub skip_nonce_check: bool, } // ------------------------------------------------------------ @@ -69,6 +70,7 @@ impl Declare { signature: Vec, nonce: Felt252, ) -> Result { + let version = get_tx_version(version); let hash = compute_deprecated_class_hash(&contract_class)?; let class_hash = felt_to_hash(&hash); @@ -96,15 +98,9 @@ impl Declare { skip_execute: false, skip_validate: false, skip_fee_transfer: false, + skip_nonce_check: false, }; - verify_version( - &internal_declare.version, - internal_declare.max_fee, - &internal_declare.nonce, - &internal_declare.signature, - )?; - Ok(internal_declare) } @@ -118,6 +114,8 @@ impl Declare { nonce: Felt252, hash_value: Felt252, ) -> Result { + let version = get_tx_version(version); + let hash = compute_deprecated_class_hash(&contract_class)?; let class_hash = felt_to_hash(&hash); @@ -136,15 +134,9 @@ impl Declare { skip_execute: false, skip_validate: false, skip_fee_transfer: false, + skip_nonce_check: false, }; - verify_version( - &internal_declare.version, - internal_declare.max_fee, - &internal_declare.nonce, - &internal_declare.signature, - )?; - Ok(internal_declare) } @@ -159,6 +151,7 @@ impl Declare { hash_value: Felt252, class_hash: ClassHash, ) -> Result { + let version = get_tx_version(version); let validate_entry_point_selector = VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(); let internal_declare = Declare { @@ -174,15 +167,9 @@ impl Declare { skip_execute: false, skip_validate: false, skip_fee_transfer: false, + skip_nonce_check: false, }; - verify_version( - &internal_declare.version, - internal_declare.max_fee, - &internal_declare.nonce, - &internal_declare.signature, - )?; - Ok(internal_declare) } @@ -198,8 +185,6 @@ impl Declare { state: &mut CachedState, block_context: &BlockContext, ) -> Result { - verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; - // validate transaction let mut resources_manager = ExecutionResourcesManager::default(); let validate_info = if self.skip_validate { @@ -251,7 +236,7 @@ impl Declare { resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, ) -> Result, TransactionError> { - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { + if self.version.is_zero() { return Ok(None); } @@ -286,13 +271,13 @@ impl Declare { } fn handle_nonce(&self, state: &mut S) -> Result<(), TransactionError> { - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { + if self.version.is_zero() { return Ok(()); } let contract_address = &self.sender_address; let current_nonce = state.get_nonce_at(contract_address)?; - if current_nonce != self.nonce { + if current_nonce != self.nonce && !self.skip_nonce_check { return Err(TransactionError::InvalidTransactionNonce( current_nonce.to_string(), self.nonce.to_string(), @@ -304,6 +289,55 @@ impl Declare { Ok(()) } + fn check_fee_balance( + &self, + state: &mut S, + block_context: &BlockContext, + ) -> Result<(), TransactionError> { + if self.max_fee.is_zero() { + return Ok(()); + } + let minimal_fee = self.estimate_minimal_fee(block_context)?; + // Check max fee is at least the estimated constant overhead. + if self.max_fee < minimal_fee { + return Err(TransactionError::MaxFeeTooLow(self.max_fee, minimal_fee)); + } + // Check that the current balance is high enough to cover the max_fee + let (balance_low, balance_high) = + state.get_fee_token_balance(block_context, &self.sender_address)?; + // The fee is at most 128 bits, while balance is 256 bits (split into two 128 bit words). + if balance_high.is_zero() && balance_low < Felt252::from(self.max_fee) { + return Err(TransactionError::MaxFeeExceedsBalance( + self.max_fee, + balance_low, + balance_high, + )); + } + Ok(()) + } + + fn estimate_minimal_fee(&self, block_context: &BlockContext) -> Result { + let n_estimated_steps = ESTIMATED_DECLARE_STEPS; + let onchain_data_length = get_onchain_data_segment_length(&StateChangesCount { + n_storage_updates: 1, + n_class_hash_updates: 0, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 1, + }); + let resources = HashMap::from([ + ( + "l1_gas_usage".to_string(), + onchain_data_length * SHARP_GAS_PER_MEMORY_WORD, + ), + ("n_steps".to_string(), n_estimated_steps), + ]); + calculate_tx_fee( + &resources, + block_context.starknet_os_config.gas_price, + block_context, + ) + } + /// Calculates actual fee used by the transaction using the execution /// info returned by apply(), then updates the transaction execution info with the data of the fee. #[tracing::instrument(level = "debug", ret, err, skip(self, state, block_context), fields( @@ -319,7 +353,19 @@ impl Declare { state: &mut CachedState, block_context: &BlockContext, ) -> Result { + if self.version != Felt252::one() && self.version != Felt252::zero() { + return Err(TransactionError::UnsupportedTxVersion( + "Declare".to_string(), + self.version.clone(), + vec![0, 1], + )); + } + if !self.skip_fee_transfer { + self.check_fee_balance(state, block_context)?; + } + self.handle_nonce(state)?; + let mut tx_exec_info = self.apply(state, block_context)?; let mut tx_execution_context = @@ -349,6 +395,7 @@ impl Declare { skip_execute: bool, skip_fee_transfer: bool, ignore_max_fee: bool, + skip_nonce_check: bool, ) -> Transaction { let tx = Declare { skip_validate, @@ -360,6 +407,7 @@ impl Declare { } else { self.max_fee }, + skip_nonce_check, ..self.clone() }; @@ -508,187 +556,6 @@ mod tests { ); } - #[test] - fn verify_version_zero_should_fail_max_fee() { - // accounts contract class must be stored before running declaration of fibonacci - let path = PathBuf::from("starknet_programs/account_without_validation.json"); - let contract_class = ContractClass::from_path(path).unwrap(); - - // Instantiate CachedState - let contract_class_cache = PermanentContractClassCache::default(); - - // ------------ contract data -------------------- - let hash = compute_deprecated_class_hash(&contract_class).unwrap(); - let class_hash = felt_to_hash(&hash); - - contract_class_cache.set_contract_class( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - ); - - //* --------------------------------------- - //* Test declare with previous data - //* --------------------------------------- - - let fib_contract_class = - ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - - let chain_id = StarknetChainId::TestNet.to_felt(); - let max_fee = 1000; - let version = 0.into(); - - // Declare tx should fail because max_fee > 0 and version == 0 - let internal_declare = Declare::new( - fib_contract_class, - chain_id, - Address(Felt252::one()), - max_fee, - version, - Vec::new(), - Felt252::from(max_fee), - ); - - // --------------------- - // Comparison - // --------------------- - assert!(internal_declare.is_err()); - assert_matches!( - internal_declare.unwrap_err(), - TransactionError::InvalidMaxFee - ); - } - - #[test] - fn verify_version_zero_should_fail_nonce() { - // accounts contract class must be stored before running declaration of fibonacci - let path = PathBuf::from("starknet_programs/account_without_validation.json"); - let contract_class = ContractClass::from_path(path).unwrap(); - - // Instantiate CachedState - let contract_class_cache = PermanentContractClassCache::default(); - - // ------------ contract data -------------------- - let hash = compute_deprecated_class_hash(&contract_class).unwrap(); - let class_hash = felt_to_hash(&hash); - - contract_class_cache.set_contract_class( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - ); - - // store sender_address - let sender_address = Address(1.into()); - // this is not conceptually correct as the sender address would be an - // Account contract (not the contract that we are currently declaring) - // but for testing reasons its ok - - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(sender_address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(sender_address, Felt252::new(1)); - - let _state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - //* --------------------------------------- - //* Test declare with previous data - //* --------------------------------------- - - let fib_contract_class = - ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - - let chain_id = StarknetChainId::TestNet.to_felt(); - let nonce = Felt252::from(148); - let version = 0.into(); - - // Declare tx should fail because nonce > 0 and version == 0 - let internal_declare = Declare::new( - fib_contract_class, - chain_id, - Address(Felt252::one()), - 0, - version, - Vec::new(), - nonce, - ); - - // --------------------- - // Comparison - // --------------------- - assert!(internal_declare.is_err()); - assert_matches!( - internal_declare.unwrap_err(), - TransactionError::InvalidNonce - ); - } - - #[test] - fn verify_signature_should_fail_not_empty_list() { - // accounts contract class must be stored before running declaration of fibonacci - let path = PathBuf::from("starknet_programs/account_without_validation.json"); - let contract_class = ContractClass::from_path(path).unwrap(); - - // Instantiate CachedState - let contract_class_cache = PermanentContractClassCache::default(); - - // ------------ contract data -------------------- - let hash = compute_deprecated_class_hash(&contract_class).unwrap(); - let class_hash = felt_to_hash(&hash); - - contract_class_cache.set_contract_class( - class_hash, - CompiledClass::Deprecated(Arc::new(contract_class)), - ); - - // store sender_address - let sender_address = Address(1.into()); - // this is not conceptually correct as the sender address would be an - // Account contract (not the contract that we are currently declaring) - // but for testing reasons its ok - - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(sender_address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(sender_address, Felt252::new(1)); - - let _state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); - - //* --------------------------------------- - //* Test declare with previous data - //* --------------------------------------- - - let fib_contract_class = - ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); - - let chain_id = StarknetChainId::TestNet.to_felt(); - let signature = vec![1.into(), 2.into()]; - - // Declare tx should fail because signature is not empty - let internal_declare = Declare::new( - fib_contract_class, - chain_id, - Address(Felt252::one()), - 0, - 0.into(), - signature, - Felt252::zero(), - ); - - // --------------------- - // Comparison - // --------------------- - assert!(internal_declare.is_err()); - assert_matches!( - internal_declare.unwrap_err(), - TransactionError::InvalidSignature - ); - } - #[test] fn execute_class_already_declared_should_redeclare() { // accounts contract class must be stored before running declaration of fibonacci @@ -933,7 +800,7 @@ mod tests { // We expect a fee transfer failure because the fee token contract is not set up assert_matches!( internal_declare.execute(&mut state, &BlockContext::default()), - Err(TransactionError::FeeTransferError(_)) + Err(TransactionError::MaxFeeExceedsBalance(_, _, _)) ); } @@ -1017,7 +884,7 @@ mod tests { let simulate_declare = declare .clone() - .create_for_simulation(true, false, true, false); + .create_for_simulation(true, false, true, false, false); // --------------------- // Comparison @@ -1036,4 +903,34 @@ mod tests { .actual_fee, ); } + + #[test] + fn declare_wrong_version() { + let fib_contract_class = + ContractClass::from_path("starknet_programs/fibonacci.json").unwrap(); + + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + let internal_declare = Declare::new( + fib_contract_class, + chain_id, + Address(Felt252::one()), + 0, + 2.into(), + Vec::new(), + Felt252::zero(), + ) + .unwrap(); + let result = internal_declare + .execute::>( + &mut CachedState::default(), + &BlockContext::default(), + ); + + assert_matches!( + result, + Err(TransactionError::UnsupportedTxVersion(tx, ver, supp)) + if tx == "Declare" && ver == 2.into() && supp == vec![0, 1]); + } } diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index cbcca05cb..4d9389015 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -1,13 +1,17 @@ -use super::fee::charge_fee; -use super::{verify_version, Transaction}; +use super::fee::{calculate_tx_fee, charge_fee}; +use super::{get_tx_version, Transaction}; use crate::core::contract_address::{compute_casm_class_hash, compute_sierra_class_hash}; -use crate::definitions::constants::QUERY_VERSION_BASE; +use crate::definitions::constants::VALIDATE_RETDATA; use crate::execution::execution_entry_point::ExecutionResult; +use crate::execution::gas_usage::get_onchain_data_segment_length; +use crate::execution::os_usage::ESTIMATED_DECLARE_STEPS; use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; use crate::services::api::contract_classes::compiled_class::CompiledClass; +use crate::services::eth_definitions::eth_gas_constants::SHARP_GAS_PER_MEMORY_WORD; use crate::state::cached_state::CachedState; use crate::state::contract_class_cache::ContractClassCache; +use crate::state::state_api::StateChangesCount; use crate::{ core::transaction_hash::calculate_declare_v2_transaction_hash, definitions::{ @@ -28,6 +32,7 @@ use cairo_lang_starknet::casm_contract_class::CasmContractClass; use cairo_lang_starknet::contract_class::ContractClass as SierraContractClass; use cairo_vm::felt::Felt252; use num_traits::Zero; +use std::collections::HashMap; use std::fmt::Debug; use std::sync::Arc; @@ -50,6 +55,7 @@ pub struct DeclareV2 { pub skip_validate: bool, pub skip_execute: bool, pub skip_fee_transfer: bool, + pub skip_nonce_check: bool, } impl DeclareV2 { @@ -130,6 +136,7 @@ impl DeclareV2 { nonce: Felt252, hash_value: Felt252, ) -> Result { + let version = get_tx_version(version); let validate_entry_point_selector = VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(); let internal_declare = DeclareV2 { @@ -147,15 +154,9 @@ impl DeclareV2 { skip_execute: false, skip_validate: false, skip_fee_transfer: false, + skip_nonce_check: false, }; - verify_version( - &internal_declare.version, - internal_declare.max_fee, - &internal_declare.nonce, - &internal_declare.signature, - )?; - Ok(internal_declare) } @@ -272,16 +273,10 @@ impl DeclareV2 { Vec::from([bytes]) } - // TODO: delete once used - #[allow(dead_code)] fn handle_nonce(&self, state: &mut S) -> Result<(), TransactionError> { - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { - return Ok(()); - } - let contract_address = &self.sender_address; let current_nonce = state.get_nonce_at(contract_address)?; - if current_nonce != self.nonce { + if current_nonce != self.nonce && !self.skip_nonce_check { return Err(TransactionError::InvalidTransactionNonce( current_nonce.to_string(), self.nonce.to_string(), @@ -293,6 +288,55 @@ impl DeclareV2 { Ok(()) } + fn check_fee_balance( + &self, + state: &mut S, + block_context: &BlockContext, + ) -> Result<(), TransactionError> { + if self.max_fee.is_zero() { + return Ok(()); + } + let minimal_fee = self.estimate_minimal_fee(block_context)?; + // Check max fee is at least the estimated constant overhead. + if self.max_fee < minimal_fee { + return Err(TransactionError::MaxFeeTooLow(self.max_fee, minimal_fee)); + } + // Check that the current balance is high enough to cover the max_fee + let (balance_low, balance_high) = + state.get_fee_token_balance(block_context, &self.sender_address)?; + // The fee is at most 128 bits, while balance is 256 bits (split into two 128 bit words). + if balance_high.is_zero() && balance_low < Felt252::from(self.max_fee) { + return Err(TransactionError::MaxFeeExceedsBalance( + self.max_fee, + balance_low, + balance_high, + )); + } + Ok(()) + } + + fn estimate_minimal_fee(&self, block_context: &BlockContext) -> Result { + let n_estimated_steps = ESTIMATED_DECLARE_STEPS; + let onchain_data_length = get_onchain_data_segment_length(&StateChangesCount { + n_storage_updates: 1, + n_class_hash_updates: 0, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 1, + }); + let resources = HashMap::from([ + ( + "l1_gas_usage".to_string(), + onchain_data_length * SHARP_GAS_PER_MEMORY_WORD, + ), + ("n_steps".to_string(), n_estimated_steps), + ]); + calculate_tx_fee( + &resources, + block_context.starknet_os_config.gas_price, + block_context, + ) + } + /// Execute the validation of the contract in the cairo-vm. Returns a TransactionExecutionInfo if succesful. /// ## Parameter: /// - state: An state that implements the State and StateReader traits. @@ -311,9 +355,19 @@ impl DeclareV2 { state: &mut CachedState, block_context: &BlockContext, ) -> Result { - self.handle_nonce(state)?; - verify_version(&self.version, self.max_fee, &self.nonce, &self.signature)?; + if self.version != 2.into() { + return Err(TransactionError::UnsupportedTxVersion( + "DeclareV2".to_string(), + self.version.clone(), + vec![2], + )); + } + + if !self.skip_fee_transfer { + self.check_fee_balance(state, block_context)?; + } + self.handle_nonce(state)?; let initial_gas = INITIAL_GAS_COST; let mut resources_manager = ExecutionResourcesManager::default(); @@ -440,6 +494,24 @@ impl DeclareV2 { )? }; + // Validate the return data + let class_hash = state.get_class_hash_at(&self.sender_address.clone())?; + let contract_class = state + .get_contract_class(&class_hash) + .map_err(|_| TransactionError::MissingCompiledClass)?; + if let CompiledClass::Sierra(_) = contract_class { + // The account contract class is a Cairo 1.0 contract; the `validate` entry point should + // return `VALID`. + if !execution_result + .call_info + .as_ref() + .map(|ci| ci.retdata == vec![VALIDATE_RETDATA.clone()]) + .unwrap_or_default() + { + return Err(TransactionError::WrongValidateRetdata); + } + } + if execution_result.call_info.is_some() { verify_no_calls_to_other_contracts(&execution_result.call_info)?; remaining_gas -= execution_result.call_info.clone().unwrap().gas_consumed; @@ -457,6 +529,7 @@ impl DeclareV2 { skip_execute: bool, skip_fee_transfer: bool, ignore_max_fee: bool, + skip_nonce_check: bool, ) -> Transaction { let tx = DeclareV2 { skip_validate, @@ -467,6 +540,7 @@ impl DeclareV2 { } else { self.max_fee }, + skip_nonce_check, ..self.clone() }; @@ -477,13 +551,16 @@ impl DeclareV2 { #[cfg(test)] mod tests { use super::DeclareV2; + use crate::core::contract_address::{compute_casm_class_hash, compute_sierra_class_hash}; + use crate::definitions::block_context::{BlockContext, StarknetChainId}; + use crate::definitions::constants::QUERY_VERSION_2; + use crate::services::api::contract_classes::compiled_class::CompiledClass; + use crate::state::state_api::StateReader; + use crate::transaction::error::TransactionError; use crate::{ - core::contract_address::{compute_casm_class_hash, compute_sierra_class_hash}, - definitions::constants::QUERY_VERSION_BASE, - services::api::contract_classes::compiled_class::CompiledClass, state::{ cached_state::CachedState, contract_class_cache::PermanentContractClassCache, - in_memory_state_reader::InMemoryStateReader, state_api::StateReader, + in_memory_state_reader::InMemoryStateReader, }, utils::Address, }; @@ -637,13 +714,13 @@ mod tests { let path; #[cfg(not(feature = "cairo_1_tests"))] { - version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); + version = QUERY_VERSION_2.clone(); path = PathBuf::from("starknet_programs/cairo2/fibonacci.sierra"); } #[cfg(feature = "cairo_1_tests")] { - version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); + version = QUERY_VERSION_2.clone(); path = PathBuf::from("starknet_programs/cairo1/fibonacci.sierra"); } @@ -829,4 +906,48 @@ mod tests { expected_err ); } + + #[test] + fn declarev2_wrong_version() { + let path; + #[cfg(not(feature = "cairo_1_tests"))] + { + path = PathBuf::from("starknet_programs/cairo2/fibonacci.sierra"); + } + + #[cfg(feature = "cairo_1_tests")] + { + path = PathBuf::from("starknet_programs/cairo1/fibonacci.sierra"); + } + + let file = File::open(path).unwrap(); + let reader = BufReader::new(file); + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_reader(reader).unwrap(); + + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + let internal_declare = DeclareV2::new( + &sierra_contract_class, + None, + Felt252::one(), + chain_id, + Address(Felt252::one()), + 0, + 1.into(), + Vec::new(), + Felt252::zero(), + ) + .unwrap(); + let result = internal_declare.execute::>( + &mut CachedState::default(), + &BlockContext::default(), + ); + + assert_matches!( + result, + Err(TransactionError::UnsupportedTxVersion(tx, ver, supp)) + if tx == "DeclareV2" && ver == 1.into() && supp == vec![2]); + } } diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index 978cbcca0..a074744a5 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -1,8 +1,15 @@ -use super::{ - fee::{calculate_tx_fee, charge_fee}, - invoke_function::verify_no_calls_to_other_contracts, - Transaction, -}; +use super::fee::{calculate_tx_fee, charge_fee}; +use super::get_tx_version; +use super::{invoke_function::verify_no_calls_to_other_contracts, Transaction}; +use crate::definitions::constants::VALIDATE_RETDATA; +use crate::execution::execution_entry_point::ExecutionResult; +use crate::execution::gas_usage::get_onchain_data_segment_length; +use crate::execution::os_usage::ESTIMATED_DEPLOY_ACCOUNT_STEPS; +use crate::services::api::contract_classes::deprecated_contract_class::EntryPointType; +use crate::services::eth_definitions::eth_gas_constants::SHARP_GAS_PER_MEMORY_WORD; +use crate::state::cached_state::CachedState; +use crate::state::state_api::StateChangesCount; +use crate::state::StateDiff; use crate::{ core::{ errors::state_errors::StateError, @@ -11,27 +18,23 @@ use crate::{ definitions::{ block_context::BlockContext, constants::{ - CONSTRUCTOR_ENTRY_POINT_SELECTOR, INITIAL_GAS_COST, QUERY_VERSION_BASE, + CONSTRUCTOR_ENTRY_POINT_SELECTOR, INITIAL_GAS_COST, VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR, }, transaction_type::TransactionType, }, execution::{ - execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, - CallInfo, TransactionExecutionContext, TransactionExecutionInfo, + execution_entry_point::ExecutionEntryPoint, CallInfo, TransactionExecutionContext, + TransactionExecutionInfo, }, hash_utils::calculate_contract_address, services::api::{ - contract_class_errors::ContractClassError, - contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::EntryPointType, - }, + contract_class_errors::ContractClassError, contract_classes::compiled_class::CompiledClass, }, state::{ - cached_state::CachedState, contract_class_cache::ContractClassCache, state_api::{State, StateReader}, - ExecutionResourcesManager, StateDiff, + ExecutionResourcesManager, }, syscalls::syscall_handler_errors::SyscallHandlerError, transaction::error::TransactionError, @@ -39,7 +42,8 @@ use crate::{ }; use cairo_vm::felt::Felt252; use getset::Getters; -use num_traits::Zero; +use num_traits::{One, Zero}; +use std::collections::HashMap; use std::fmt::Debug; #[derive(Clone, Debug, PartialEq, Eq)] @@ -68,6 +72,7 @@ pub struct DeployAccount { skip_validate: bool, skip_execute: bool, skip_fee_transfer: bool, + skip_nonce_check: bool, } impl DeployAccount { @@ -82,6 +87,7 @@ impl DeployAccount { contract_address_salt: Felt252, chain_id: Felt252, ) -> Result { + let version = get_tx_version(version); let contract_address = Address(calculate_contract_address( &contract_address_salt, &Felt252::from_bytes_be(&class_hash), @@ -113,6 +119,7 @@ impl DeployAccount { skip_execute: false, skip_validate: false, skip_fee_transfer: false, + skip_nonce_check: false, }) } @@ -127,6 +134,7 @@ impl DeployAccount { contract_address_salt: Felt252, hash_value: Felt252, ) -> Result { + let version = get_tx_version(version); let contract_address = Address(calculate_contract_address( &contract_address_salt, &Felt252::from_bytes_be(&class_hash), @@ -147,6 +155,7 @@ impl DeployAccount { skip_execute: false, skip_validate: false, skip_fee_transfer: false, + skip_nonce_check: false, }) } @@ -171,6 +180,18 @@ impl DeployAccount { state: &mut CachedState, block_context: &BlockContext, ) -> Result { + if self.version != Felt252::one() { + return Err(TransactionError::UnsupportedTxVersion( + "DeployAccount".to_string(), + self.version.clone(), + vec![1], + )); + } + + if !self.skip_fee_transfer { + self.check_fee_balance(state, block_context)?; + } + self.handle_nonce(state)?; let mut transactional_state = state.create_transactional()?; @@ -195,7 +216,8 @@ impl DeployAccount { .as_str(), ); } else { - state.apply_state_update(&StateDiff::from_cached_state(transactional_state)?)?; + state + .apply_state_update(&StateDiff::from_cached_state(transactional_state.cache())?)?; } let mut tx_execution_context = @@ -295,13 +317,13 @@ impl DeployAccount { } fn handle_nonce(&self, state: &mut S) -> Result<(), TransactionError> { - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { + if self.version.is_zero() { return Ok(()); } // In blockifier, get_nonce_at returns zero if no entry is found. let current_nonce = state.get_nonce_at(&self.contract_address)?; - if current_nonce != self.nonce { + if current_nonce != self.nonce && !self.skip_nonce_check { return Err(TransactionError::InvalidTransactionNonce( current_nonce.to_string(), self.nonce.to_string(), @@ -311,6 +333,55 @@ impl DeployAccount { Ok(()) } + fn check_fee_balance( + &self, + state: &mut S, + block_context: &BlockContext, + ) -> Result<(), TransactionError> { + if self.max_fee.is_zero() { + return Ok(()); + } + let minimal_fee = self.estimate_minimal_fee(block_context)?; + // Check max fee is at least the estimated constant overhead. + if self.max_fee < minimal_fee { + return Err(TransactionError::MaxFeeTooLow(self.max_fee, minimal_fee)); + } + // Check that the current balance is high enough to cover the max_fee + let (balance_low, balance_high) = + state.get_fee_token_balance(block_context, self.contract_address())?; + // The fee is at most 128 bits, while balance is 256 bits (split into two 128 bit words). + if balance_high.is_zero() && balance_low < Felt252::from(self.max_fee) { + return Err(TransactionError::MaxFeeExceedsBalance( + self.max_fee, + balance_low, + balance_high, + )); + } + Ok(()) + } + + fn estimate_minimal_fee(&self, block_context: &BlockContext) -> Result { + let n_estimated_steps = ESTIMATED_DEPLOY_ACCOUNT_STEPS; + let onchain_data_length = get_onchain_data_segment_length(&StateChangesCount { + n_storage_updates: 1, + n_class_hash_updates: 1, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 1, + }); + let resources = HashMap::from([ + ( + "l1_gas_usage".to_string(), + onchain_data_length * SHARP_GAS_PER_MEMORY_WORD, + ), + ("n_steps".to_string(), n_estimated_steps), + ]); + calculate_tx_fee( + &resources, + block_context.starknet_os_config.gas_price, + block_context, + ) + } + pub fn run_constructor_entrypoint( &self, state: &mut CachedState, @@ -364,10 +435,6 @@ impl DeployAccount { resources_manager: &mut ExecutionResourcesManager, block_context: &BlockContext, ) -> Result, TransactionError> { - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { - return Ok(None); - } - let call = ExecutionEntryPoint::new( self.contract_address.clone(), [ @@ -398,6 +465,23 @@ impl DeployAccount { )? }; + // Validate the return data + let class_hash = state.get_class_hash_at(&self.contract_address)?; + let contract_class = state + .get_contract_class(&class_hash) + .map_err(|_| TransactionError::MissingCompiledClass)?; + if let CompiledClass::Sierra(_) = contract_class { + // The account contract class is a Cairo 1.0 contract; the `validate` entry point should + // return `VALID`. + if !call_info + .as_ref() + .map(|ci| ci.retdata == vec![VALIDATE_RETDATA.clone()]) + .unwrap_or_default() + { + return Err(TransactionError::WrongValidateRetdata); + } + } + verify_no_calls_to_other_contracts(&call_info) .map_err(|_| TransactionError::InvalidContractCall)?; @@ -410,6 +494,7 @@ impl DeployAccount { skip_execute: bool, skip_fee_transfer: bool, ignore_max_fee: bool, + skip_nonce_check: bool, ) -> Transaction { let tx = DeployAccount { skip_validate, @@ -420,6 +505,7 @@ impl DeployAccount { } else { self.max_fee }, + skip_nonce_check, ..self.clone() }; @@ -558,7 +644,7 @@ mod tests { #[test] fn deploy_account_twice_should_fail() { - let path = PathBuf::from("starknet_programs/constructor.json"); + let path = PathBuf::from("starknet_programs/account_without_validation.json"); let contract = ContractClass::from_path(path).unwrap(); let hash = compute_deprecated_class_hash(&contract).unwrap(); @@ -573,9 +659,9 @@ mod tests { let internal_deploy = DeployAccount::new( class_hash, 0, + 1.into(), 0.into(), - 0.into(), - vec![10.into()], + vec![], Vec::new(), 0.into(), StarknetChainId::TestNet2.to_felt(), @@ -585,9 +671,9 @@ mod tests { let internal_deploy_error = DeployAccount::new( class_hash, 0, - 0.into(), - 0.into(), - vec![10.into()], + 1.into(), + 1.into(), + vec![], Vec::new(), 0.into(), StarknetChainId::TestNet2.to_felt(), @@ -641,4 +727,32 @@ mod tests { .unwrap(); internal_deploy.execute(&mut state, &block_context).unwrap(); } + + #[test] + fn deploy_account_wrong_version() { + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + let internal_declare = DeployAccount::new( + [2; 32], + 9000, + 2.into(), + Felt252::zero(), + vec![], + vec![], + Felt252::one(), + chain_id, + ) + .unwrap(); + let result = internal_declare + .execute::>( + &mut CachedState::default(), + &BlockContext::default(), + ); + + assert_matches!( + result, + Err(TransactionError::UnsupportedTxVersion(tx, ver, supp)) + if tx == "DeployAccount" && ver == 2.into() && supp == vec![1]); + } } diff --git a/src/transaction/error.rs b/src/transaction/error.rs index 87a1f76a5..69afa7dec 100644 --- a/src/transaction/error.rs +++ b/src/transaction/error.rs @@ -9,6 +9,7 @@ use crate::{ utils::ClassHash, }; use cairo_vm::{ + felt::Felt252, types::{ errors::{math_errors::MathError, program_errors::ProgramError}, relocatable::Relocatable, @@ -149,4 +150,12 @@ pub enum TransactionError { FromByteArrayError(#[from] FromByteArrayError), #[error("DeclareV2 transaction has neither Sierra nor Casm contract class set")] DeclareV2NoSierraOrCasm, + #[error("Unsupported {0} transaction version: {1}. Supported versions:{2:?}")] + UnsupportedTxVersion(String, Felt252, Vec), + #[error("The `validate` entry point should return `VALID`.")] + WrongValidateRetdata, + #[error("Max fee ({0}) is too low. Minimum fee: {1}.")] + MaxFeeTooLow(u128, u128), + #[error("Max fee ({0}) exceeds balance (Uint256({1}, {2})).")] + MaxFeeExceedsBalance(u128, Felt252, Felt252), } diff --git a/src/transaction/fee.rs b/src/transaction/fee.rs index aa04a6e38..957329622 100644 --- a/src/transaction/fee.rs +++ b/src/transaction/fee.rs @@ -2,9 +2,7 @@ use super::error::TransactionError; use crate::{ definitions::{ block_context::BlockContext, - constants::{ - FEE_FACTOR, INITIAL_GAS_COST, QUERY_VERSION_BASE, TRANSFER_ENTRY_POINT_SELECTOR, - }, + constants::{FEE_FACTOR, INITIAL_GAS_COST, TRANSFER_ENTRY_POINT_SELECTOR}, }, execution::{ execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, @@ -157,8 +155,7 @@ pub fn charge_fee( )?; let actual_fee = { - let version_0 = tx_execution_context.version == 0.into() - || tx_execution_context.version == *QUERY_VERSION_BASE; + let version_0 = tx_execution_context.version.is_zero(); let fee_exceeded_max = actual_fee > max_fee; if version_0 && fee_exceeded_max { diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index 1f8a0937c..f8f828921 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -1,25 +1,32 @@ use super::{ fee::{calculate_tx_fee, charge_fee}, - Transaction, + get_tx_version, Transaction, }; use crate::{ core::transaction_hash::{calculate_transaction_hash_common, TransactionHashPrefix}, definitions::{ block_context::{BlockContext, StarknetChainId}, constants::{ - EXECUTE_ENTRY_POINT_SELECTOR, QUERY_VERSION_BASE, VALIDATE_ENTRY_POINT_SELECTOR, + EXECUTE_ENTRY_POINT_SELECTOR, VALIDATE_ENTRY_POINT_SELECTOR, VALIDATE_RETDATA, }, transaction_type::TransactionType, }, execution::{ execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + gas_usage::get_onchain_data_segment_length, + os_usage::ESTIMATED_INVOKE_FUNCTION_STEPS, CallInfo, TransactionExecutionContext, TransactionExecutionInfo, }, - services::api::contract_classes::deprecated_contract_class::EntryPointType, + services::{ + api::contract_classes::{ + compiled_class::CompiledClass, deprecated_contract_class::EntryPointType, + }, + eth_definitions::eth_gas_constants::SHARP_GAS_PER_MEMORY_WORD, + }, state::{ cached_state::CachedState, contract_class_cache::ContractClassCache, - state_api::{State, StateReader}, + state_api::{State, StateChangesCount, StateReader}, ExecutionResourcesManager, StateDiff, }, transaction::error::TransactionError, @@ -27,8 +34,8 @@ use crate::{ }; use cairo_vm::felt::Felt252; use getset::Getters; -use num_traits::Zero; -use std::fmt::Debug; +use num_traits::{One, Zero}; +use std::{collections::HashMap, fmt::Debug}; /// Represents an InvokeFunction transaction in the starknet network. #[derive(Debug, Getters, Clone)] @@ -105,6 +112,8 @@ impl InvokeFunction { nonce: Option, hash_value: Felt252, ) -> Result { + let version = get_tx_version(version); + let validate_entry_point_selector = VALIDATE_ENTRY_POINT_SELECTOR.clone(); Ok(InvokeFunction { @@ -170,10 +179,7 @@ impl InvokeFunction { if self.entry_point_selector != *EXECUTE_ENTRY_POINT_SELECTOR { return Ok(None); } - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { - return Ok(None); - } - if self.skip_validation { + if self.version.is_zero() || self.skip_validation { return Ok(None); } @@ -197,6 +203,23 @@ impl InvokeFunction { block_context.validate_max_n_steps, )?; + // Validate the return data + let class_hash = state.get_class_hash_at(&self.contract_address)?; + let contract_class = state + .get_contract_class(&class_hash) + .map_err(|_| TransactionError::MissingCompiledClass)?; + if let CompiledClass::Sierra(_) = contract_class { + // The account contract class is a Cairo 1.0 contract; the `validate` entry point should + // return `VALID`. + if !call_info + .as_ref() + .map(|ci| ci.retdata == vec![VALIDATE_RETDATA.clone()]) + .unwrap_or_default() + { + return Err(TransactionError::WrongValidateRetdata); + } + } + let call_info = verify_no_calls_to_other_contracts(&call_info) .map_err(|_| TransactionError::InvalidContractCall)?; @@ -308,11 +331,21 @@ impl InvokeFunction { block_context: &BlockContext, remaining_gas: u128, ) -> Result { - if !self.skip_nonce_check { - self.handle_nonce(state)?; + if self.version != Felt252::one() && self.version != Felt252::zero() { + return Err(TransactionError::UnsupportedTxVersion( + "Invoke".to_string(), + self.version.clone(), + vec![0, 1], + )); + } + + if !self.skip_fee_transfer { + self.check_fee_balance(state, block_context)?; } - let mut transactional_state = state.create_transactional()?; + self.handle_nonce(state)?; + + let mut transactional_state = state.create_transactional(); let mut tx_exec_info = self.apply(&mut transactional_state, block_context, remaining_gas)?; @@ -335,7 +368,8 @@ impl InvokeFunction { .as_str(), ); } else { - state.apply_state_update(&StateDiff::from_cached_state(transactional_state)?)?; + state + .apply_state_update(&StateDiff::from_cached_state(transactional_state.cache())?)?; } let mut tx_execution_context = @@ -355,7 +389,7 @@ impl InvokeFunction { } fn handle_nonce(&self, state: &mut S) -> Result<(), TransactionError> { - if self.version.is_zero() || self.version == *QUERY_VERSION_BASE { + if self.version.is_zero() { return Ok(()); } @@ -368,7 +402,7 @@ impl InvokeFunction { Ok(()) } Some(nonce) => { - if nonce != ¤t_nonce { + if !self.skip_nonce_check && nonce != ¤t_nonce { return Err(TransactionError::InvalidTransactionNonce( current_nonce.to_string(), nonce.to_string(), @@ -380,6 +414,55 @@ impl InvokeFunction { } } + fn check_fee_balance( + &self, + state: &mut S, + block_context: &BlockContext, + ) -> Result<(), TransactionError> { + if self.max_fee.is_zero() { + return Ok(()); + } + let minimal_fee = self.estimate_minimal_fee(block_context)?; + // Check max fee is at least the estimated constant overhead. + if self.max_fee < minimal_fee { + return Err(TransactionError::MaxFeeTooLow(self.max_fee, minimal_fee)); + } + // Check that the current balance is high enough to cover the max_fee + let (balance_low, balance_high) = + state.get_fee_token_balance(block_context, self.contract_address())?; + // The fee is at most 128 bits, while balance is 256 bits (split into two 128 bit words). + if balance_high.is_zero() && balance_low < Felt252::from(self.max_fee) { + return Err(TransactionError::MaxFeeExceedsBalance( + self.max_fee, + balance_low, + balance_high, + )); + } + Ok(()) + } + + fn estimate_minimal_fee(&self, block_context: &BlockContext) -> Result { + let n_estimated_steps = ESTIMATED_INVOKE_FUNCTION_STEPS; + let onchain_data_length = get_onchain_data_segment_length(&StateChangesCount { + n_storage_updates: 1, + n_class_hash_updates: 0, + n_compiled_class_hash_updates: 0, + n_modified_contracts: 1, + }); + let resources = HashMap::from([ + ( + "l1_gas_usage".to_string(), + onchain_data_length * SHARP_GAS_PER_MEMORY_WORD, + ), + ("n_steps".to_string(), n_estimated_steps), + ]); + calculate_tx_fee( + &resources, + block_context.starknet_os_config.gas_price, + block_context, + ) + } + // Simulation function pub fn create_for_simulation( @@ -433,7 +516,7 @@ pub(crate) fn preprocess_invoke_function_fields( nonce: Option, version: Felt252, ) -> Result<(Felt252, Vec), TransactionError> { - if version.is_zero() || version == *QUERY_VERSION_BASE { + if version.is_zero() { match nonce { Some(_) => Err(TransactionError::InvokeFunctionZeroHasNonce), None => { @@ -534,6 +617,7 @@ fn convert_invoke_v1( mod tests { use super::*; use crate::{ + definitions::constants::QUERY_VERSION_1, services::api::contract_classes::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, @@ -678,7 +762,7 @@ mod tests { .apply(&mut transactional, &BlockContext::default(), 0) .unwrap(); state - .apply_state_update(&StateDiff::from_cached_state(transactional).unwrap()) + .apply_state_update(&StateDiff::from_cached_state(transactional.cache()).unwrap()) .unwrap(); assert_eq!(result.tx_type, Some(TransactionType::InvokeFunction)); @@ -886,7 +970,7 @@ mod tests { .apply(&mut transactional, &BlockContext::default(), 0) .unwrap(); state - .apply_state_update(&StateDiff::from_cached_state(transactional).unwrap()) + .apply_state_update(&StateDiff::from_cached_state(transactional.cache()).unwrap()) .unwrap(); assert_eq!(result.tx_type, Some(TransactionType::InvokeFunction)); @@ -1021,7 +1105,10 @@ mod tests { let result = internal_invoke_function.execute(&mut state, &block_context, 0); assert!(result.is_err()); - assert_matches!(result.unwrap_err(), TransactionError::FeeTransferError(_)); + assert_matches!( + result.unwrap_err(), + TransactionError::MaxFeeExceedsBalance(_, _, _) + ); } #[test] @@ -1304,7 +1391,7 @@ mod tests { ) .unwrap(), None, - &Into::::into(1) | &QUERY_VERSION_BASE.clone(), + QUERY_VERSION_1.clone(), ); assert!(expected_error.is_err()); } @@ -1389,4 +1476,32 @@ mod tests { .class_hash_to_compiled_class_hash ); } + + #[test] + fn invoke_wrong_version() { + let chain_id = StarknetChainId::TestNet.to_felt(); + + // declare tx + let internal_declare = InvokeFunction::new( + Address(Felt252::one()), + Felt252::one(), + 9000, + 2.into(), + vec![], + vec![], + chain_id, + Some(Felt252::zero()), + ) + .unwrap(); + let result = internal_declare.execute::>( + &mut CachedState::default(), + &BlockContext::default(), + u128::MAX, + ); + + assert_matches!( + result, + Err(TransactionError::UnsupportedTxVersion(tx, ver, supp)) + if tx == "Invoke" && ver == 2.into() && supp == vec![0, 1]); + } } diff --git a/src/transaction/l1_handler.rs b/src/transaction/l1_handler.rs index f01031436..e32f03032 100644 --- a/src/transaction/l1_handler.rs +++ b/src/transaction/l1_handler.rs @@ -1,12 +1,3 @@ -use crate::{ - execution::execution_entry_point::ExecutionResult, - services::api::contract_classes::deprecated_contract_class::EntryPointType, - state::{cached_state::CachedState, contract_class_cache::ContractClassCache}, -}; -use cairo_vm::felt::Felt252; -use getset::Getters; -use num_traits::Zero; - use super::Transaction; use crate::{ core::transaction_hash::{calculate_transaction_hash_common, TransactionHashPrefix}, @@ -15,16 +6,22 @@ use crate::{ transaction_type::TransactionType, }, execution::{ - execution_entry_point::ExecutionEntryPoint, TransactionExecutionContext, - TransactionExecutionInfo, + execution_entry_point::{ExecutionEntryPoint, ExecutionResult}, + TransactionExecutionContext, TransactionExecutionInfo, }, + services::api::contract_classes::deprecated_contract_class::EntryPointType, state::{ + cached_state::CachedState, + contract_class_cache::ContractClassCache, state_api::{State, StateReader}, ExecutionResourcesManager, }, transaction::{error::TransactionError, fee::calculate_tx_fee}, utils::{calculate_tx_resources, Address}, }; +use cairo_vm::felt::Felt252; +use getset::Getters; +use num_traits::Zero; #[allow(dead_code)] #[derive(Debug, Getters, Clone)] diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index 3d75e4266..6d96efed7 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -1,5 +1,6 @@ use crate::{ definitions::block_context::BlockContext, + definitions::constants::{QUERY_VERSION_0, QUERY_VERSION_1, QUERY_VERSION_2}, execution::TransactionExecutionInfo, state::{ cached_state::CachedState, contract_class_cache::ContractClassCache, state_api::StateReader, @@ -13,7 +14,6 @@ pub use deploy_account::DeployAccount; use error::TransactionError; pub use invoke_function::InvokeFunction; pub use l1_handler::L1Handler; -pub use verify_version::verify_version; pub mod declare; pub mod declare_v2; @@ -23,7 +23,9 @@ pub mod error; pub mod fee; pub mod invoke_function; pub mod l1_handler; -mod verify_version; + +use cairo_vm::felt::Felt252; +use num_traits::{One, Zero}; /// Represents a transaction inside the starknet network. /// The transaction are actions that may modified the state of the network. @@ -102,12 +104,14 @@ impl Transaction { skip_execute, skip_fee_transfer, ignore_max_fee, + skip_nonce_check, ), Transaction::DeclareV2(tx) => tx.create_for_simulation( skip_validate, skip_execute, skip_fee_transfer, ignore_max_fee, + skip_nonce_check, ), Transaction::Deploy(tx) => { tx.create_for_simulation(skip_validate, skip_execute, skip_fee_transfer) @@ -117,6 +121,7 @@ impl Transaction { skip_execute, skip_fee_transfer, ignore_max_fee, + skip_nonce_check, ), Transaction::InvokeFunction(tx) => tx.create_for_simulation( skip_validate, @@ -129,3 +134,14 @@ impl Transaction { } } } + +// Parses query tx versions into their normal counterpart +// This is used to execute old transactions an may be removed in the future as its not part of the current standard implementation +fn get_tx_version(version: Felt252) -> Felt252 { + match version { + version if version == *QUERY_VERSION_0 => Felt252::zero(), + version if version == *QUERY_VERSION_1 => Felt252::one(), + version if version == *QUERY_VERSION_2 => 2.into(), + version => version, + } +} diff --git a/starknet_programs/account_without_validation_and_expensive_constructor.cairo b/starknet_programs/account_without_validation_and_expensive_constructor.cairo new file mode 100644 index 000000000..a354dd62c --- /dev/null +++ b/starknet_programs/account_without_validation_and_expensive_constructor.cairo @@ -0,0 +1,86 @@ +// @compile-flags += --account_contract + +// A dummy account contract without any validations. + +%lang starknet + +from starkware.cairo.common.bool import FALSE +from starkware.cairo.common.cairo_builtins import HashBuiltin +from starkware.starknet.common.syscalls import ( + call_contract, + deploy, + get_caller_address, + get_contract_address, +) + +@constructor +func constructor{ + syscall_ptr: felt*, + pedersen_ptr: HashBuiltin*, + range_check_ptr, +}() { + // Call some syscalls so we get a non-trivial fee increase + get_caller_address(); + get_caller_address(); + get_caller_address(); + get_caller_address(); + get_caller_address(); + get_caller_address(); + get_caller_address(); + return (); +} + +@view +func assert_only_self{syscall_ptr: felt*}() { + let (self) = get_contract_address(); + let (caller) = get_caller_address(); + assert self = caller; + return (); +} + +@external +func __validate_declare__(class_hash: felt) { + return (); +} + +@external +func __validate_deploy__(class_hash: felt, contract_address_salt: felt) { + return (); +} + +@external +func __validate__(contract_address, selector: felt, calldata_len: felt, calldata: felt*) { + return (); +} + +@external +@raw_output +func __execute__{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( + contract_address, selector: felt, calldata_len: felt, calldata: felt* +) -> (retdata_size: felt, retdata: felt*) { + let (retdata_size: felt, retdata: felt*) = call_contract( + contract_address=contract_address, + function_selector=selector, + calldata_size=calldata_len, + calldata=calldata, + ); + return (retdata_size=retdata_size, retdata=retdata); +} + +@external +func deploy_contract{syscall_ptr: felt*}( + class_hash: felt, + contract_address_salt: felt, + constructor_calldata_len: felt, + constructor_calldata: felt*, +) -> (contract_address: felt) { + assert_only_self(); + let (contract_address) = deploy( + class_hash=class_hash, + contract_address_salt=contract_address_salt, + constructor_calldata_size=constructor_calldata_len, + constructor_calldata=constructor_calldata, + deploy_from_zero=FALSE, + ); + return (contract_address=contract_address); +} diff --git a/starknet_programs/cairo2/example_contract.cairo b/starknet_programs/cairo2/example_contract.cairo new file mode 100644 index 000000000..bcb981da0 --- /dev/null +++ b/starknet_programs/cairo2/example_contract.cairo @@ -0,0 +1,32 @@ +#[starknet::interface] +trait IExampleContract { + fn get_balance(ref self: TContractState) -> u128; + fn increase_balance(ref self: TContractState, amount: u128); +} + +#[starknet::contract] +mod ExampleContract { + use traits::Into; + use starknet::info::get_contract_address; + + #[storage] + struct Storage { + balance: u128, + } + + #[constructor] + fn constructor(ref self: ContractState) { + } + + #[external(v0)] + impl ExampleContract of super::IExampleContract { + fn get_balance(ref self: ContractState) -> u128 { + self.balance.read() + } + + fn increase_balance(ref self: ContractState, amount: u128) { + let balance = self.balance.read(); + self.balance.write(balance + amount); + } + } +} diff --git a/starknet_programs/cairo2/factorial_tr.cairo b/starknet_programs/cairo2/factorial_tr.cairo new file mode 100644 index 000000000..b2230662f --- /dev/null +++ b/starknet_programs/cairo2/factorial_tr.cairo @@ -0,0 +1,26 @@ +#[starknet::interface] +trait IFactorial { + fn factorial(self: @TContractState, n: felt252) -> felt252; +} + +#[starknet::contract] +mod Factorial { + #[storage] + struct Storage { + } + + fn factorial_tr(acc: felt252, n: felt252) -> felt252 { + if n == 0 || n == 1 { + acc + } else { + factorial_tr(acc*n, n-1) + } + } + + #[external(v0)] + impl Factorial of super::IFactorial { + fn factorial(self: @ContractState, n: felt252) -> felt252 { + factorial_tr(1, n) + } + } +} diff --git a/starknet_programs/cairo2/get_block_hash_basic.cairo b/starknet_programs/cairo2/get_block_hash_basic.cairo new file mode 100644 index 000000000..4334790f3 --- /dev/null +++ b/starknet_programs/cairo2/get_block_hash_basic.cairo @@ -0,0 +1,19 @@ +#[starknet::interface] +trait IGetBlockHashBasic { + fn get_block_hash(self: @TContractState, block_number: u64) -> felt252; +} + +#[starknet::contract] +mod GetBlockHashBasic { + use core::{debug::PrintTrait, result::ResultTrait, starknet::get_block_hash_syscall}; + + #[storage] + struct Storage {} + + #[external(v0)] + impl GetBlockHashBasic of super::IGetBlockHashBasic { + fn get_block_hash(self: @ContractState, block_number: u64) -> felt252 { + get_block_hash_syscall(block_number).unwrap() + } + } +} diff --git a/starknet_programs/keccak/test_cairo_keccak.cairo b/starknet_programs/cairo2/test_cairo_keccak.cairo similarity index 100% rename from starknet_programs/keccak/test_cairo_keccak.cairo rename to starknet_programs/cairo2/test_cairo_keccak.cairo diff --git a/starknet_programs/deployer.cairo b/starknet_programs/deployer.cairo new file mode 100644 index 000000000..a54a66098 --- /dev/null +++ b/starknet_programs/deployer.cairo @@ -0,0 +1,49 @@ +// Code taken from Universal Deployer Proposal in starknet forum https://community.starknet.io/t/universal-deployer-contract-proposal/1864 +%lang starknet + +from starkware.starknet.common.syscalls import get_caller_address, deploy +from starkware.cairo.common.cairo_builtins import HashBuiltin +from starkware.cairo.common.hash import hash2 +from starkware.cairo.common.bool import FALSE + +@event +func ContractDeployed( + contractAddress: felt, + deployer: felt, + classHash: felt, + salt: felt + ){ + } + +@external +func deploy_contract{ + syscall_ptr: felt*, + pedersen_ptr: HashBuiltin*, + range_check_ptr, + } ( + class_hash: felt, + salt: felt, + constructor_calldata_len: felt, + constructor_calldata: felt*, + ) -> (contract_address: felt){ + + let (deployer) = get_caller_address(); + let (unique_salt) = hash2{hash_ptr=pedersen_ptr}(deployer, salt); + + let (contract_address) = deploy( + class_hash=class_hash, + contract_address_salt=unique_salt, + constructor_calldata_size=constructor_calldata_len, + constructor_calldata=constructor_calldata, + deploy_from_zero=FALSE + ); + + ContractDeployed.emit( + contractAddress=contract_address, + deployer=deployer, + classHash=class_hash, + salt=salt + ); + + return (contract_address=contract_address); +} diff --git a/starknet_programs/keccak/test_cairo_keccak.casm b/starknet_programs/keccak/test_cairo_keccak.casm deleted file mode 100644 index faa22d975..000000000 --- a/starknet_programs/keccak/test_cairo_keccak.casm +++ /dev/null @@ -1,2033 +0,0 @@ -{ - "prime": "0x800000000000011000000000000000000000000000000000000000000000001", - "compiler_version": "2.1.0", - "bytecode": [ - "0xa0680017fff8000", - "0x7", - "0x482680017ffa8000", - "0xfffffffffffffffffffffffffffe896e", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x5e", - "0x4825800180007ffa", - "0x17692", - "0x400280007ff97fff", - "0x48297ffc80007ffd", - "0x482680017ff98000", - "0x1", - "0x4824800180007ffe", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x13", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x5e", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x400080007ffe7fff", - "0x48127ff87fff8000", - "0x48127ff57fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x1104800180018000", - "0x4ea", - "0x482480017fff8000", - "0x4e9", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4824800180007ff7", - "0x0", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400080007ff77fff", - "0x10780017fff7fff", - "0x24", - "0x4824800180007ff7", - "0x0", - "0x400080007ff87fff", - "0x482480017ff88000", - "0x1", - "0x48127ffe7fff8000", - "0x480a7ffb7fff8000", - "0x1104800180018000", - "0x3b", - "0x20680017fff7ffd", - "0x11", - "0x40780017fff7fff", - "0x1", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0xfa", - "0x48127ff27fff8000", - "0x48127ff27fff8000", - "0x48127ff27fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482480017ff58000", - "0x1", - "0x48127ff27fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x4", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x1", - "0x400080007ffe7fff", - "0x480680017fff8000", - "0x2", - "0x400080017ffd7fff", - "0x480680017fff8000", - "0x3", - "0x400080027ffc7fff", - "0x480680017fff8000", - "0x4", - "0x400080037ffb7fff", - "0x480680017fff8000", - "0x5", - "0x400080047ffa7fff", - "0x480680017fff8000", - "0x6", - "0x400080057ff97fff", - "0x480680017fff8000", - "0x7", - "0x400080067ff87fff", - "0x480680017fff8000", - "0x8", - "0x400080077ff77fff", - "0x480680017fff8000", - "0x9", - "0x400080087ff67fff", - "0x480680017fff8000", - "0xa", - "0x400080097ff57fff", - "0x480680017fff8000", - "0xb", - "0x4000800a7ff47fff", - "0x480680017fff8000", - "0xc", - "0x4000800b7ff37fff", - "0x480680017fff8000", - "0xd", - "0x4000800c7ff27fff", - "0x40137ff27fff8002", - "0x402580017ff28003", - "0xd", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a80027fff8000", - "0x480a80037fff8000", - "0x1104800180018000", - "0x9b", - "0x20680017fff7ffd", - "0x8c", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ffd7fff8000", - "0x480a80027fff8000", - "0x480a80037fff8000", - "0x480680017fff8000", - "0x11000010", - "0x480680017fff8000", - "0x4", - "0x40137ff77fff8000", - "0x40137ff87fff8001", - "0x1104800180018000", - "0xa6", - "0x20680017fff7ffb", - "0x75", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x43ccdbe17ae03b02b308ebe4a23c4cc9", - "0x1104800180018000", - "0xea", - "0x20680017fff7fff", - "0x10", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x57726f6e672068617368206c6f772031", - "0x400080007ffe7fff", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0xf3cc56e9bd860f83e3e3bc69919b176a", - "0x1104800180018000", - "0xd5", - "0x20680017fff7fff", - "0x10", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x57726f6e67206861736820686967682031", - "0x400080007ffe7fff", - "0x48127fea7fff8000", - "0x48127fea7fff8000", - "0x48127fea7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127fec7fff8000", - "0x48127fec7fff8000", - "0x48127fec7fff8000", - "0x480a80007fff8000", - "0x480a80017fff8000", - "0x480680017fff8000", - "0xaaaaaaaa11000010", - "0x480680017fff8000", - "0x4", - "0x1104800180018000", - "0x6f", - "0x20680017fff7ffb", - "0x36", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x43ccdbe17ae03b02b308ebe4a23c4cc9", - "0x1104800180018000", - "0xb3", - "0x20680017fff7fff", - "0x10", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x57726f6e672068617368206c6f772032", - "0x400080007ffe7fff", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x48127ff07fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0xf3cc56e9bd860f83e3e3bc69919b176a", - "0x1104800180018000", - "0x9e", - "0x20680017fff7fff", - "0x10", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x57726f6e67206861736820686967682032", - "0x400080007ffe7fff", - "0x48127fea7fff8000", - "0x48127fea7fff8000", - "0x48127fea7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x482480017ff98000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127fec7fff8000", - "0x48127fec7fff8000", - "0x48127fec7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffa7fff8000", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x400380007ffd7ffb", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x48127ffb7fff8000", - "0x48127ffa7fff8000", - "0x1104800180018000", - "0x69", - "0x20680017fff7ffb", - "0x9", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ff77fff8000", - "0x480a7ff87fff8000", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0xb9", - "0x20680017fff7ffd", - "0x37", - "0x48127ffe7fff8000", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x4b656363616b", - "0x400280007ff97fff", - "0x400280017ff97ff9", - "0x400280027ff97ffd", - "0x400280037ff97ffe", - "0x480280057ff98000", - "0x20680017fff7fff", - "0xb", - "0x480280047ff98000", - "0x482680017ff98000", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480280067ff98000", - "0x480280077ff98000", - "0x10780017fff7fff", - "0x9", - "0x480280047ff98000", - "0x482680017ff98000", - "0x8", - "0x480680017fff8000", - "0x1", - "0x480280067ff98000", - "0x480280077ff98000", - "0x1104800180018000", - "0x1e0", - "0x20680017fff7ffd", - "0xc", - "0x48127fed7fff8000", - "0x48127ff57fff8000", - "0x48127ff57fff8000", - "0x480680017fff8000", - "0x0", - "0x48127fec7fff8000", - "0x48127fec7fff8000", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x208b7fff7fff7ffe", - "0x48127fed7fff8000", - "0x48127ff57fff8000", - "0x48127ff57fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x208b7fff7fff7ffe", - "0x48297ffd80007ffc", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x1104800180018000", - "0x35c", - "0x482480017fff8000", - "0x35b", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4825800180007ff9", - "0xf82", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400280007ff87fff", - "0x10780017fff7fff", - "0x4a", - "0x4825800180007ff9", - "0xf82", - "0x400280007ff87fff", - "0x482680017ff88000", - "0x1", - "0x48297ffa80007ffb", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xa", - "0x482680017ffa8000", - "0x1", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffa7fff8000", - "0x10780017fff7fff", - "0x8", - "0x480a7ffa7fff8000", - "0x480a7ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x20680017fff7ffc", - "0x25", - "0x480080007ffd8000", - "0x1104800180018000", - "0x18f", - "0x400280007ffd7fff", - "0x48127ff47fff8000", - "0x48127ff27fff8000", - "0x48127ff87fff8000", - "0x48127ff87fff8000", - "0x480a7ffc7fff8000", - "0x482680017ffd8000", - "0x1", - "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffcc", - "0x20680017fff7ffb", - "0xb", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff87fff8000", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff88000", - "0x1", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ff97fff8000", - "0x482480017ff88000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x11", - "0x1104800180018000", - "0x152", - "0x20680017fff7ffd", - "0x13b", - "0x20680017fff7ffe", - "0x12c", - "0x48297ffa80007ffb", - "0x480280007ff88004", - "0x4824800180037fff", - "0x1", - "0x48307ffe7fff7ffc", - "0x480280017ff87ffe", - "0x480280027ff87fff", - "0x40507ffe7ff97ffd", - "0x40307fff7ffd7ffa", - "0x482680017ff88000", - "0x3", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x8", - "0x1104800180018000", - "0x14e", - "0x20680017fff7ffd", - "0x113", - "0x48127ffc7fff8000", - "0x48127ffe7fff8000", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x162", - "0x20680017fff7ffd", - "0x105", - "0x4825800180007ffd", - "0x0", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x94", - "0x4825800180007ffd", - "0x1", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x55", - "0x4825800180007ffd", - "0x2", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x49", - "0x4825800180007ffd", - "0x3", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x3d", - "0x4825800180007ffd", - "0x4", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x31", - "0x4825800180007ffd", - "0x5", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x25", - "0x4825800180007ffd", - "0x6", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x19", - "0x4825800180007ffd", - "0x7", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0xf", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4b656363616b206c61737420696e70757420776f7264203e3762", - "0x400080007ffe7fff", - "0x48127ff27fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x482480017ffa8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x100000000000000", - "0x10780017fff7fff", - "0x6", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x1000000000000", - "0x10780017fff7fff", - "0x6", - "0x40780017fff7fff", - "0x2", - "0x480680017fff8000", - "0x10000000000", - "0x10780017fff7fff", - "0x6", - "0x40780017fff7fff", - "0x3", - "0x480680017fff8000", - "0x100000000", - "0x10780017fff7fff", - "0x6", - "0x40780017fff7fff", - "0x4", - "0x480680017fff8000", - "0x1000000", - "0x10780017fff7fff", - "0x6", - "0x40780017fff7fff", - "0x5", - "0x480680017fff8000", - "0x10000", - "0x10780017fff7fff", - "0x6", - "0x40780017fff7fff", - "0x6", - "0x480680017fff8000", - "0x100", - "0x1104800180018000", - "0x126", - "0x20680017fff7ffd", - "0x2c", - "0x20680017fff7ffe", - "0x1d", - "0x480080007fe18004", - "0x4824800180037fff", - "0x1", - "0x48307ffe7fff7ffd", - "0x480080017fde7ffe", - "0x480080027fdd7fff", - "0x40507ffe7ffa7ffd", - "0x40317fff7ffd7ffc", - "0x482480017fdc8000", - "0x3", - "0x48127fe77fff8000", - "0x48127ffd7fff8000", - "0x1104800180018000", - "0x124", - "0x20680017fff7ffd", - "0x6", - "0x48127ffc7fff8000", - "0x48127ffe7fff8000", - "0x10780017fff7fff", - "0x22", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7074696f6e3a3a756e77726170206661696c65642e", - "0x400080007ffe7fff", - "0x48127fdf7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x482480017ffa8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127fe17fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x35", - "0x48127fc67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffe7fff8000", - "0x480680017fff8000", - "0x11", - "0x480680017fff8000", - "0x1", - "0x1104800180018000", - "0x122", - "0x20680017fff7ffd", - "0x58", - "0x48307fff80007f87", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x3b", - "0x400280007ffb7fe8", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x11", - "0x480680017fff8000", - "0x1", - "0x1104800180018000", - "0x113", - "0x480a7ffa7fff8000", - "0x482680017ffb8000", - "0x1", - "0x20680017fff7ffb", - "0x27", - "0x48127ffa7fff8000", - "0x48127ffc7fff8000", - "0x48127f6c7fff8000", - "0x1104800180018000", - "0x109", - "0x20680017fff7ffd", - "0x19", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x48127fe67fff8000", - "0x48127fe67fff8000", - "0x48127ffb7fff8000", - "0x1104800180018000", - "0x12b", - "0x20680017fff7ffd", - "0x9", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffa7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x8000000000000000", - "0x48127fe67fff8000", - "0x1104800180018000", - "0xb1", - "0x20680017fff7ffd", - "0xb", - "0x400280007ffb7fff", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffa7fff8000", - "0x482680017ffb8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffc7fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7074696f6e3a3a756e77726170206661696c65642e", - "0x400080007ffe7fff", - "0x480a7ff87fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x482480017ffa8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ff87fff8000", - "0x480a7ff97fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0x7", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x480a7ffc7fff8000", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x119", - "0x20680017fff7ffd", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffb7fff8000", - "0x484a7ffd7ffc8000", - "0x1104800180018000", - "0x120", - "0x20680017fff7ffe", - "0xb", - "0x40780017fff7fff", - "0x2", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffa7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x7533325f6d756c204f766572666c6f77", - "0x400080007ffe7fff", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffc7fff8000", - "0x482480017ffb8000", - "0x1", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x8", - "0x482a7ffd7ffc8000", - "0x4824800180007fff", - "0x100000000", - "0x400280007ffb7fff", - "0x10780017fff7fff", - "0xd", - "0x482a7ffd7ffc8001", - "0x4824800180007fff", - "0xffffffffffffffffffffffff00000000", - "0x400280007ffb7ffe", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffd7fff8000", - "0x10780017fff7fff", - "0x7", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x7533325f616464204f766572666c6f77", - "0x1104800180018000", - "0x105", - "0x20680017fff7ffd", - "0x9", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x106", - "0x20680017fff7ffd", - "0x8", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x48127ffd7fff8000", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x8", - "0x482a7ffd7ffc8000", - "0x4824800180007fff", - "0x10000000000000000", - "0x400280007ffb7fff", - "0x10780017fff7fff", - "0xd", - "0x482a7ffd7ffc8001", - "0x4824800180007fff", - "0xffffffffffffffff0000000000000000", - "0x400280007ffb7ffe", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffd7fff8000", - "0x10780017fff7fff", - "0x7", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x480680017fff8000", - "0x7536345f616464204f766572666c6f77", - "0x1104800180018000", - "0xf5", - "0x20680017fff7ffd", - "0x9", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x48297ffd80017ffc", - "0xa0680017fff7fff", - "0x7", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400280007ffb7fff", - "0x10780017fff7fff", - "0xc", - "0x400280007ffb7fff", - "0x40780017fff7fff", - "0x1", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x10780017fff7fff", - "0x8", - "0x482680017ffb8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x482480017ffc8000", - "0x100000000", - "0x480680017fff8000", - "0x7533325f737562204f766572666c6f77", - "0x1104800180018000", - "0x9f", - "0x20680017fff7ffd", - "0x9", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ff67fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x1104800180018000", - "0xe4", - "0x482480017fff8000", - "0xe3", - "0x480080007fff8000", - "0xa0680017fff8000", - "0x9", - "0x4825800180007ffa", - "0x1612", - "0x482480017fff8000", - "0x100000000000000000000000000000000", - "0x400280007ff97fff", - "0x10780017fff7fff", - "0x44", - "0x4825800180007ffa", - "0x1612", - "0x400280007ff97fff", - "0x482680017ff98000", - "0x1", - "0x4825800180007ffd", - "0x1", - "0x20680017fff7fff", - "0x4", - "0x10780017fff7fff", - "0x2e", - "0x480680017fff8000", - "0x0", - "0x400280007ffc7fff", - "0x48127ffd7fff8000", - "0x480a7ffd7fff8000", - "0x480680017fff8000", - "0x1", - "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffb6", - "0x480a7ffb7fff8000", - "0x482680017ffc8000", - "0x1", - "0x20680017fff7ffb", - "0x19", - "0x48127ffa7fff8000", - "0x48127fe37fff8000", - "0x48127ffc7fff8000", - "0x48127ffc7fff8000", - "0x48127ff97fff8000", - "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffd5", - "0x20680017fff7ffd", - "0x9", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x48127ffa7fff8000", - "0x48127fe37fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ff97fff8000", - "0x48127ff97fff8000", - "0x208b7fff7fff7ffe", - "0x480680017fff8000", - "0x8000000000000000", - "0x400280007ffc7fff", - "0x48127ffd7fff8000", - "0x48127ffb7fff8000", - "0x480680017fff8000", - "0x0", - "0x480a7ffb7fff8000", - "0x482680017ffc8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x4f7574206f6620676173", - "0x400080007ffe7fff", - "0x482680017ff98000", - "0x1", - "0x480a7ffa7fff8000", - "0x480680017fff8000", - "0x1", - "0x48127ffb7fff8000", - "0x482480017ffa8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x6d", - "0x20680017fff7ffe", - "0xa", - "0x40780017fff7fff", - "0x2", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x7533322069732030", - "0x400080007ffe7fff", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x482480017ffc8000", - "0x1", - "0x208b7fff7fff7ffe", - "0xa0680017fff8000", - "0x7", - "0x4825800180007ffd", - "0x100000000", - "0x400280007ffc7fff", - "0x10780017fff7fff", - "0xc", - "0x482680017ffd8000", - "0xffffffffffffffffffffffff00000000", - "0x400280007ffc7fff", - "0x482680017ffc8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x10780017fff7fff", - "0x8", - "0x482680017ffc8000", - "0x1", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0xa", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x400180007fff7ffd", - "0x480680017fff8000", - "0x1", - "0x48127ffe7fff8000", - "0x482480017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x480a7ffd7fff8000", - "0x1104800180018000", - "0x36", - "0x20680017fff7ffe", - "0xa", - "0x40780017fff7fff", - "0x2", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x48127ffb7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x7536342069732030", - "0x400080007ffe7fff", - "0x480680017fff8000", - "0x1", - "0x48127ffd7fff8000", - "0x482480017ffc8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffb", - "0xa", - "0x40780017fff7fff", - "0x1", - "0x480680017fff8000", - "0x0", - "0x480680017fff8000", - "0x0", - "0x480a7ffc7fff8000", - "0x208b7fff7fff7ffe", - "0x40780017fff7fff", - "0x1", - "0x400180007fff7ffd", - "0x480680017fff8000", - "0x1", - "0x48127ffe7fff8000", - "0x482480017ffd8000", - "0x1", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffd", - "0x8", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x5", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe", - "0x20780017fff7ffd", - "0x8", - "0x480680017fff8000", - "0x1", - "0x480680017fff8000", - "0x0", - "0x10780017fff7fff", - "0x5", - "0x480680017fff8000", - "0x0", - "0x480a7ffd7fff8000", - "0x208b7fff7fff7ffe" - ], - "hints": [ - [ - 0, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x17692" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 22, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 41, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x0" - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -8 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 61, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 84, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 99, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 118, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 192, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 213, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 247, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 268, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 321, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 365, - [ - { - "SystemCall": { - "system": { - "Deref": { - "register": "FP", - "offset": -7 - } - } - } - } - ] - ], - [ - 439, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0xf82" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -7 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 520, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 547, - [ - { - "DivMod": { - "lhs": { - "Deref": { - "register": "AP", - "offset": -1 - } - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -2 - } - }, - "quotient": { - "register": "AP", - "offset": 3 - }, - "remainder": { - "register": "AP", - "offset": 4 - } - } - } - ] - ], - [ - 619, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 676, - [ - { - "DivMod": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -4 - } - }, - "rhs": { - "Deref": { - "register": "AP", - "offset": -1 - } - }, - "quotient": { - "register": "AP", - "offset": 3 - }, - "remainder": { - "register": "AP", - "offset": 4 - } - } - } - ] - ], - [ - 703, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 844, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 909, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 921, - [ - { - "TestLessThan": { - "lhs": { - "BinOp": { - "op": "Add", - "a": { - "register": "FP", - "offset": -4 - }, - "b": { - "Deref": { - "register": "FP", - "offset": -3 - } - } - } - }, - "rhs": { - "Immediate": "0x100000000" - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 980, - [ - { - "TestLessThan": { - "lhs": { - "BinOp": { - "op": "Add", - "a": { - "register": "FP", - "offset": -4 - }, - "b": { - "Deref": { - "register": "FP", - "offset": -3 - } - } - } - }, - "rhs": { - "Immediate": "0x10000000000000000" - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1024, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -4 - } - }, - "dst": { - "register": "AP", - "offset": -1 - } - } - } - ] - ], - [ - 1071, - [ - { - "TestLessThanOrEqual": { - "lhs": { - "Immediate": "0x1612" - }, - "rhs": { - "Deref": { - "register": "FP", - "offset": -6 - } - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1146, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1173, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1184, - [ - { - "TestLessThan": { - "lhs": { - "Deref": { - "register": "FP", - "offset": -3 - } - }, - "rhs": { - "Immediate": "0x100000000" - }, - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1218, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1240, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ], - [ - 1261, - [ - { - "AllocSegment": { - "dst": { - "register": "AP", - "offset": 0 - } - } - } - ] - ] - ], - "pythonic_hints": [ - [ - 0, - [ - "memory[ap + 0] = 95890 <= memory[fp + -6]" - ] - ], - [ - 22, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 41, - [ - "memory[ap + 0] = 0 <= memory[ap + -8]" - ] - ], - [ - 61, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 84, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 99, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 118, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 192, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 213, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 247, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 268, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 321, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 365, - [ - "syscall_handler.syscall(syscall_ptr=memory[fp + -7])" - ] - ], - [ - 439, - [ - "memory[ap + 0] = 3970 <= memory[fp + -7]" - ] - ], - [ - 520, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 547, - [ - "(memory[ap + 3], memory[ap + 4]) = divmod(memory[ap + -1], memory[ap + -2])" - ] - ], - [ - 619, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 676, - [ - "(memory[ap + 3], memory[ap + 4]) = divmod(memory[fp + -4], memory[ap + -1])" - ] - ], - [ - 703, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 844, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 909, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 921, - [ - "memory[ap + 0] = memory[fp + -4] + memory[fp + -3] < 4294967296" - ] - ], - [ - 980, - [ - "memory[ap + 0] = memory[fp + -4] + memory[fp + -3] < 18446744073709551616" - ] - ], - [ - 1024, - [ - "memory[ap + -1] = memory[fp + -3] <= memory[fp + -4]" - ] - ], - [ - 1071, - [ - "memory[ap + 0] = 5650 <= memory[fp + -6]" - ] - ], - [ - 1146, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 1173, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 1184, - [ - "memory[ap + 0] = memory[fp + -3] < 4294967296" - ] - ], - [ - 1218, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 1240, - [ - "memory[ap + 0] = segments.add()" - ] - ], - [ - 1261, - [ - "memory[ap + 0] = segments.add()" - ] - ] - ], - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x3d91620ebfd3035266d72c83df4f0f314ade6a3449bc2193fe8078df7553873", - "offset": 0, - "builtins": [ - "range_check" - ] - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - } -} \ No newline at end of file diff --git a/starknet_programs/keccak/test_cairo_keccak.sierra b/starknet_programs/keccak/test_cairo_keccak.sierra deleted file mode 100644 index bb1ff0663..000000000 --- a/starknet_programs/keccak/test_cairo_keccak.sierra +++ /dev/null @@ -1,943 +0,0 @@ -{ - "sierra_program": [ - "0x1", - "0x3", - "0x0", - "0x2", - "0x1", - "0x0", - "0x1db", - "0x25", - "0x39", - "0x52616e6765436865636b", - "0x0", - "0x4761734275696c74696e", - "0x66656c74323532", - "0x4172726179", - "0x1", - "0x2", - "0x536e617073686f74", - "0x3", - "0x537472756374", - "0x1baeba72e79e9db2587cf44fedb2f3700b2075a5e8e39a562584862c4b71f62", - "0x4", - "0x753332", - "0x53797374656d", - "0x2ee1e2b1b89f8c495f200e4956278a4d47395fe262f27b52e5865c9524c08c3", - "0x16a4c8d7c05909052238a862d8cc3e7975bf05a07b3a69c6b28951083a6d672", - "0x9", - "0x5", - "0x456e756d", - "0x9931c641b913035ae674b400b61a51476d506bbe8bba2ff8a6272790aba9e6", - "0xb", - "0xa", - "0x4275696c74696e436f737473", - "0x1c05ce70474a4304f1383f206fe0f8fb502ee40248665da23dc692001473105", - "0x10203be321c62a7bd4c060d69539c1fbe065baa9e253c74d2cc48be163e259", - "0xf", - "0x753634", - "0x11", - "0x556e696e697469616c697a6564", - "0x12", - "0x8fb98e1acdfdf8aff6b13f16b57042f28186321f7727a98c6627f268fa3619", - "0x15", - "0x75313238", - "0x25e2ca4b84968c2d8b83ef476ca8549410346b00836ce79beaf538155990bb2", - "0x17", - "0x18", - "0x14bafead7fe2e5d5098831b6ce460a4ea41734e96452eff510098bded016639", - "0x19", - "0x3288d594b9a45d15bb2fcb7903f06cdb06b27f0ba88186ec4cfaa98307cb972", - "0x8", - "0x3f829a4bc463d91621ba418d447cc38c95ddc483f9ccfebae79050eb7b3dcb6", - "0x14", - "0x1c", - "0x14a41abf590beba6e5ad84c90179e42ae9c264ddc050feb3ce783a67e66479e", - "0x1d", - "0x25e50662218619229b3f53f1dc3253192a0f68ca423d900214253db415a90b4", - "0x1f", - "0xccf52bb0646785c5ad2a653e9ec60b68f9843823a0c386724530f0e305f2c4", - "0x2ce4352eafa6073ab4ecf9445ae96214f99c2c33a29c01fcae68ba501d10e2c", - "0x22", - "0x426f78", - "0x10aadf20f2da2fb70102a7c61aae18a1e861ef78a0161983e81cb182f71363c", - "0x24", - "0x4e6f6e5a65726f", - "0x6", - "0x23d687e999cab78c31d6bd5cbdf8daae101a3c11ab2222105379d7c36f36ea1", - "0x26", - "0x27", - "0xdf75ca2cf6afb9bc933cc3f65b045ad15bd70726819d90effa48df72a2f1c1", - "0x28", - "0x3ab802bcce3a9ca953b0e1f31a5b29eb27a9b727c891e24300e1b5cc57387ba", - "0x2a", - "0x1c93399c577f87390e51b8cb506e46bf14730a3503957dbfa913537c3269e72", - "0x2c", - "0x2d", - "0x1cd2b418923aab36f139f976a4924eeee496567cc062738dc66f7e858c458f6", - "0x2e", - "0x1ee471fea880cdb75aff7b143b1653e4803b9dca47f4fcdd349d11fec9d7a16", - "0x30", - "0x30e6087648fb5594b78751a87d38cc4bb23c443ca7457f975ed5e20cb5c0da3", - "0x32", - "0x19b9ae4ba181a54f9e7af894a81b44a60aea4c9803939708d6cc212759ee94c", - "0x39a088813bcc109470bd475058810a7465bd632650a449e0ab3aee56f2e4e69", - "0x231651df0179b7c1db8cfe7d4b2d0450f932a95f500c3fe114d8a2321ea362", - "0x36", - "0x2fffb69a24c0eccf3220a0a3685e1cefee1b1f63c6dcbe4030d1d50aa7a7b42", - "0x10d", - "0x7265766f6b655f61705f747261636b696e67", - "0x77697468647261775f676173", - "0x6272616e63685f616c69676e", - "0x7374727563745f6465636f6e737472756374", - "0x61727261795f6c656e", - "0x736e617073686f745f74616b65", - "0x64726f70", - "0x7533325f636f6e7374", - "0x72656e616d65", - "0x73746f72655f74656d70", - "0x7533325f6571", - "0x7", - "0x66756e6374696f6e5f63616c6c", - "0x61727261795f6e6577", - "0x66656c743235325f636f6e7374", - "0x496e70757420746f6f206c6f6e6720666f7220617267756d656e7473", - "0x61727261795f617070656e64", - "0x7374727563745f636f6e737472756374", - "0x656e756d5f696e6974", - "0xc", - "0x6765745f6275696c74696e5f636f737473", - "0xd", - "0x77697468647261775f6761735f616c6c", - "0xe", - "0x656e756d5f6d61746368", - "0x10", - "0x4f7574206f6620676173", - "0x616c6c6f635f6c6f63616c", - "0x66696e616c697a655f6c6f63616c73", - "0x64697361626c655f61705f747261636b696e67", - "0x7536345f636f6e7374", - "0x73746f72655f6c6f63616c", - "0x16", - "0x11000010", - "0x1a", - "0x753132385f636f6e7374", - "0x43ccdbe17ae03b02b308ebe4a23c4cc9", - "0x1b", - "0x57726f6e672068617368206c6f772031", - "0xf3cc56e9bd860f83e3e3bc69919b176a", - "0x57726f6e67206861736820686967682031", - "0xaaaaaaaa11000010", - "0x57726f6e672068617368206c6f772032", - "0x57726f6e67206861736820686967682032", - "0x13", - "0x1e", - "0x656e61626c655f61705f747261636b696e67", - "0x20", - "0x6b656363616b5f73797363616c6c", - "0x21", - "0x6a756d70", - "0x23", - "0x753132385f6571", - "0x61727261795f736e617073686f745f706f705f66726f6e74", - "0x25", - "0x756e626f78", - "0x29", - "0x7533325f736166655f6469766d6f64", - "0x647570", - "0x2b", - "0x4b656363616b206c61737420696e70757420776f7264203e3762", - "0x100000000000000", - "0x1000000000000", - "0x10000000000", - "0x100000000", - "0x1000000", - "0x10000", - "0x100", - "0x2f", - "0x7536345f736166655f6469766d6f64", - "0x31", - "0x4f7074696f6e3a3a756e77726170206661696c65642e", - "0x8000000000000000", - "0x33", - "0x7533325f776964655f6d756c", - "0x34", - "0x7533325f6d756c204f766572666c6f77", - "0x7533325f6f766572666c6f77696e675f616464", - "0x35", - "0x7533325f616464204f766572666c6f77", - "0x37", - "0x7536345f6f766572666c6f77696e675f616464", - "0x38", - "0x7536345f616464204f766572666c6f77", - "0x7533325f6f766572666c6f77696e675f737562", - "0x7533325f737562204f766572666c6f77", - "0x7533322069732030", - "0x646f776e63617374", - "0x7536342069732030", - "0x7533325f69735f7a65726f", - "0x7536345f69735f7a65726f", - "0x4bc", - "0xffffffffffffffff", - "0x54", - "0x47", - "0x40", - "0x3a", - "0x3b", - "0x3c", - "0x3d", - "0x3e", - "0x3f", - "0x41", - "0x42", - "0x43", - "0x44", - "0x45", - "0x46", - "0x48", - "0x49", - "0x4a", - "0x4b", - "0x4c", - "0x4d", - "0x4e", - "0x4f", - "0x50", - "0x51", - "0x52", - "0x53", - "0x55", - "0x56", - "0x57", - "0x58", - "0x59", - "0x148", - "0x140", - "0xc8", - "0x5a", - "0x5b", - "0x5c", - "0x5d", - "0x5e", - "0x60", - "0x61", - "0x5f", - "0x62", - "0xe6", - "0x63", - "0x64", - "0x65", - "0x66", - "0x67", - "0x68", - "0x69", - "0x6a", - "0x6b", - "0x6c", - "0x6d", - "0x6e", - "0x6f", - "0x74", - "0x75", - "0x76", - "0x77", - "0x78", - "0x79", - "0x70", - "0x71", - "0x72", - "0x73", - "0x7a", - "0x139", - "0x7b", - "0x7c", - "0x7d", - "0x7e", - "0x7f", - "0x80", - "0x81", - "0x82", - "0x83", - "0x84", - "0x85", - "0x86", - "0x87", - "0x88", - "0x8a", - "0x8b", - "0x89", - "0x8c", - "0x112", - "0x8d", - "0x8e", - "0x8f", - "0x90", - "0x91", - "0x92", - "0x93", - "0x94", - "0x95", - "0x96", - "0x97", - "0x98", - "0x99", - "0x9a", - "0x9b", - "0x9c", - "0x9d", - "0x9e", - "0x9f", - "0xa0", - "0xa2", - "0xa3", - "0xa1", - "0xa4", - "0x12f", - "0xa5", - "0xa6", - "0xa7", - "0xa8", - "0xa9", - "0xaa", - "0xab", - "0xac", - "0xad", - "0xae", - "0xaf", - "0xb0", - "0xb1", - "0xb2", - "0xb3", - "0xb4", - "0xb5", - "0xb6", - "0xb7", - "0xb8", - "0xb9", - "0xba", - "0xbb", - "0xbc", - "0xbd", - "0xbe", - "0xbf", - "0xc0", - "0xc1", - "0xc2", - "0xc3", - "0xc4", - "0xc5", - "0x16a", - "0x1a0", - "0x185", - "0x18a", - "0x197", - "0x1b2", - "0x1b6", - "0x1f0", - "0x1c4", - "0x1c9", - "0x1e6", - "0x1e0", - "0x365", - "0x355", - "0x34a", - "0x33f", - "0x2ce", - "0x291", - "0x28b", - "0x285", - "0x27f", - "0x279", - "0x273", - "0x26f", - "0x277", - "0x27d", - "0x283", - "0x289", - "0x28f", - "0x295", - "0x2c3", - "0x2b1", - "0x2a8", - "0x2d4", - "0x335", - "0x31c", - "0x314", - "0x30d", - "0x307", - "0xc6", - "0xc7", - "0xc9", - "0xca", - "0xcb", - "0xcc", - "0xcd", - "0xce", - "0xcf", - "0xd0", - "0xd1", - "0xd2", - "0xd3", - "0xd4", - "0xd5", - "0xd6", - "0xd7", - "0xda", - "0xdb", - "0xdc", - "0xd8", - "0xd9", - "0xdd", - "0x32e", - "0xde", - "0xdf", - "0xe0", - "0xe1", - "0xe2", - "0xe3", - "0xe4", - "0xe5", - "0xe7", - "0xe8", - "0xe9", - "0xea", - "0xeb", - "0xec", - "0xed", - "0xee", - "0xef", - "0xf0", - "0xf1", - "0xf2", - "0xf3", - "0xf4", - "0xf5", - "0xf6", - "0xf7", - "0xf8", - "0xf9", - "0xfa", - "0xfb", - "0xfc", - "0xfd", - "0xfe", - "0xff", - "0x101", - "0x102", - "0x103", - "0x374", - "0x387", - "0x396", - "0x3a8", - "0x3ac", - "0x3b8", - "0x3c7", - "0x3d1", - "0x3d5", - "0x3e1", - "0x3ec", - "0x3f0", - "0x3fc", - "0x444", - "0x438", - "0x431", - "0x42b", - "0x45a", - "0x46b", - "0x470", - "0x47a", - "0x48b", - "0x104", - "0x49d", - "0x105", - "0x4ac", - "0x106", - "0x107", - "0x4af", - "0x108", - "0x109", - "0x4b7", - "0x10a", - "0x10b", - "0x4ba", - "0x10c", - "0x151", - "0x157", - "0x170", - "0x1a8", - "0x1b8", - "0x1ff", - "0x36e", - "0x37a", - "0x37d", - "0x38b", - "0x3a2", - "0x3bd", - "0x3cb", - "0x3e6", - "0x401", - "0x452", - "0x465", - "0x473", - "0x483", - "0x496", - "0x4a6", - "0x4b1", - "0x2b11", - "0x181402070081a0c0302c0407050240c060401c0c06028080802018080200", - "0x182a060a0081213090181e02038281206088181e02048282002030281e02", - "0x700c06028083616030680c190102426070303c0407050600406050082e16", - "0x8120a010842c06100183e020484c3c06078080e0a0f0180c080f0180c1d", - "0xa00c27010242616030980c25010242624030780c0f0102414230308c0c22", - "0x282c061681858020484c50060f018560607808180a150185202038285006", - "0x3c0407050240c24030c00409098580c2f030b80409098a00c1e0303c0409", - "0x4c6e06030d850061a81868020484c3806030cc2c061901862020484c4806", - "0xdc0c0f0101c1416030f00c3b01024263a0303c0407050a00c39030e00409", - "0x4c8206078080e0a1401880061f80812130e0180c360b0187c061e8081213", - "0xe40c0f0101c1416031140c4401024261c0303c0407050580c43031080409", - "0x80e0a1b8186e06248081213140186e062400812130b0188e06230081213", - "0x14404500113c044e268700c1c031300409098580c4b031280409099000c0f", - "0xdc0c062b8dc0c062b0080e062a8dc0c062a0dc0c062981c0c06290480c06", - "0x15cba07031700e060316c5006031500c0903168b2060315c0458010180c57", - "0x18ae0603018ae06039840c07300580c062f8440c062f81c0c062f01c0c06", - "0x168ca060315cca0603150ca060314cca060317c0464318180c5701188c206", - "0x2412062d0240c062b81c0c062a01c0c06298680c062899c0c063301c1206", - "0x150d007031700407308180e600a8180c5f090180c5f048180c54048180c53", - "0x180e06360700c062d808d602350780c06348a00c062b8a00c062f8480c06", - "0x1c0c6c0901c0c6c0601c0c6c0481c0c6c0381c0c6c0e0180c5e0e0180c57", - "0x18d86103818d81503818d81603818d81103818d82803818d85903818d837", - "0x1b0400603144dc060319818090316854060315c3c060314c3c06031b4c607", - "0x780c062a0980c06289c00c063304812062d0780c062b8300e062a9bc0e06", - "0x180c661b8240c5a118180c573901c0c71118180c54118180c53120180c51", - "0x1dc0e06361d80e062e1d40e063899c0c062b8180e670301cc07403818b873", - "0x158f406031500407338180e600d0180c5f0301c0c5c3c81c0c5c3c01c0c5c", - "0xac0c062a0b40c06289ec0c063316412062d0ac0c062b8ac0c062f81c0c06", - "0x198047c140240c5a0301cdc0603980dc060315c0407370180e60100180c5f", - "0x180e7f0301cc002401fc0c062b8080e7f0301cc0023f0bc0c06289f40c06", - "0x15c0407380180e60130180c5f190180c51408180c66088240c5a3f8180c56", - "0x1cc07303018ae02039cc0c0730009042303018ac06039c00c07301c00c06", - "0x18108060315c0407420180e600e0180c83158180c51398180c560301ce606", - "0x80e7b0301cc02d03018be1604818b41c030190a8403018cc0603a100c07", - "0x1987806031450c06031982a09031683807031540c073d8180e603d8180c57", - "0x18a28903018cc6104818b43703019102803818aa02438700c06290e80c06", - "0x1542407031541207031540e07031540c07031547c0603150c609031687c06", - "0x18d87d03018ae06039f40c07302280e062e0700c062a1640e062a8dc0e06", - "0x1b12007031b11e07031b11c07031b11a07031b03806031591807031b11607", - "0x18b402499040c063310c0c0628a480c063319412062d0700c06442440e06", - "0x1805e060317c380903168ce09031692a07031708a06031452806031983409", - "0x2040c062b8080e810301cc03203018be7f03018cc9603818d802039f40c07", - "0x180c5f0101c7406039808e06031452e06031983c09031680c07408180e60", - "0x2640c06331e812062d009300603a180c07302180c062b8080e860301cc03c", - "0x180049b0301d12060398134070317112060315c0407448180e601f0180c5f", - "0xa812062d2700c062b2740e062e0180e9c0301cc09c03018ae0203a700c07", - "0x1d24060398086060317c0407208180e60258180c514f0180c66100240c5a", - "0x2800c07302800c062b8080ea00301cc0024f8180e920301cc09203018ae02", - "0x180c570101d2806039808a060317cdc09031694006031594207031700c07", - "0x1cc04703018be2304818b40203818d8a303818b802510180e940301cc094", - "0x180e601b818380603a940c074b8180e605201c0c5c4b8180c570101d2e06", - "0x18b49c03018cc9903018ac0203018ac0603a640c07302640c062b8080e99", - "0x1980c074f0180e605301c0c5c4f0180c570101d3c060398096060317c4809", - "0x180e410301cc002540e80c062b0e80c062b8180e3a0301cc00253a800c06", - "0x1d56120601d5407030080e060100954060100804a9208180c56208180c57", - "0x182402088195406140181802140195406048181202012a80c0203808b237", - "0x1d5406308182402308195406011640402550182c061b8082a1603aa80c11", - "0x440467032a80c65030a0041a032a80c15030a0040255018c6061b808ca63", - "0x80e02010bc04aa0399c34070a80818065501818060b0083406550183406", - "0x954060f018ca020f0700eaa031e80c63011e80caa0301c0c61010095406", - "0x8054070f00840065501840060e0084006550180467010a80caa030083402", - "0x1954061201840021201954063708c0e2a0108c0caa03008f402370195406", - "0x8c042b032a80c1c031840473032a80c12031b80470032a80c0c030580426", - "0x98047b032a80c021200804aa030080e02168ace670060185a06550184c06", - "0x954060101c04323f81d587d1781d54073d848180938008f60655018f606", - "0xbc0c160100954061a8185a02420d40eaa032040c2b012040caa03008e602", - "0x19540642018f60220019540603818c2024481954063e818dc021f0195406", - "0x924065690c0caa03a180c7d01218783a1c831540620901123e060bc0441", - "0x1d54062281864024a0195406010680445032a80c43031fc0402550180407", - "0x210049e032a80c94030d4044b032a80c97030700402550188e06408092e47", - "0x187402002800eaa032640c390100954064e018ca024e2640eaa032789607", - "0x195406578187c02578195406570190c02570195406000187802012a80ca0", - "0x8c04b3032a80c3c0318404b2032a80c3a031b804b1032a80c390305804b0", - "0x968065501924061000804aa030080e0256acd64b1060195a06550196006", - "0x2d00c23012dc0caa030f00c61012d80caa030e80c6e012d40caa030e40c16", - "0x180489012e40caa030083402012a80c020380970b75b2d418065c0195406", - "0x2ec0caa03008f4025d0195406562e40e1e012b00caa032b00c1c012b00caa", - "0x1b804be032a80c7f0305804bd032a80cbc0308004bc032a80cba5d81c5402", - "0x3017ebe060198206550197a06118098006550180e06308097e06550186406", - "0x1954060122404c2032a80c020d00804aa030240c400100954060101c04c1", - "0xa804c5032a80c023d00988065501986c20387804c3032a80cc30307004c3", - "0x1640c6e0131c0caa030dc0c16013180caa032ac0c20012ac0caa033118a07", - "0x994c96431c180665019540663018460264819540603818c202640195406", - "0x81207038181206550180c06218080e06550180406308080c06550180441", - "0xb40402550180494010095406011140459032a80c02490082406550180492", - "0x440caa030440c99010440caa030092e021401954060111c0402550181206", - "0x1d38020a81954060a81932020a81954060112c0416032a80c111401d3802", - "0x18c66103a700463032a80c63032640463032a80c024f008c206550182a16", - "0x19c0caa03068ca074e00834065501834064c80834065501804a0011940caa", - "0x95c020f01954060e19c0e9c010700caa030700c99010700caa030080002", - "0x195406012bc042a032a80c7a0f01d38023d01954063d01932023d0195406", - "0x2640423032a80c0258008dc0655018402a03a700420032a80c20032640420", - "0x184c064c8084c065501804b1010900caa0308cdc074e0084606550184606", - "0x1cc0caa031cc0c99011cc0caa030096402380195406130900e9c010980caa", - "0x1d3802168195406168193202168195406012cc042b032a80c733801d3802", - "0x185e7b03a70042f032a80c2f03264042f032a80c0256808f606550185a2b", - "0xdc0caa031fcfa074e008fe0655018fe064c808fe065501804b4011f40caa", - "0x874065501804060b009023203aa80c37032d80437032a80c372c81d6a02", - "0xe5083504aa80c861e0e812b8012180caa032040cb7010f00caa030180c6e", - "0x2e8040c032a80c3e032b00402550180407012240ccb1f01954071c8197202", - "0x19540642018dc022381954061a8182c02208195406012ec0440032a80c02", - "0x44044b032a80c4003264049c032a80c32032f00499032a80c07031840497", - "0x3154064f12d38994b91c6ebd010300caa0303024075a8093c06550188206", - "0x2a80ca0032fc0402550180407010000ccc5001954074a0197c024a1152443", - "0x2c80eaa032c00cc2012c56007550195e066080804aa032b80cc0012bd5c07", - "0x98802012a80cad0330c04b45681d5406598198402012a80cb20330c04b3", - "0x1d54065b8198402012a80cb60330c04b75b01d54065a81984025a8195406", - "0x2ac04bb032a80cb90331404ba032a80cb40331404025501970066180972b8", - "0x18ca02012a80c02038097a0666af00caa03ab00cc6012b00caa032ed7407", - "0x31c04be032a80c020d00804aa032c40cc3010095406060198002012a80cbc", - "0x2a80c023d0098006550197ebe0387804bf032a80cbf0307004bf032a80c02", - "0x3100caa0310c0c160130c0caa033080cc8013080caa033018207150098206", - "0x310180663019540661819920255819540622818c20262819540649018dc02", - "0x30c04c86381d5406588198402012a80cbd0319404025501804070131956c5", - "0x1954060132804025501992066180994c903aa80cc8033080402550198e06", - "0x9a4d103aa80cd0033080402550199e0661809a0cf03aa80cce0330804ce", - "0x351a60755809a80655019a40662809a6065501994066280804aa033440cc3", - "0x2a80cd6031940402550180407013600cd76b01954076a8198c026a8195406", - "0x19b4060e009b4065501804ce013640caa030083402012a80c0c033000402", - "0x1954066db700e2a013700caa03008f4026d81954066d3640e1e013680caa", - "0x18404e0032a80c92031b804df032a80c430305804de032a80cdd0332004dd", - "0x804aa030080e0271385c0df06019c40655019bc0664809c206550188a06", - "0x195406218182c02720195406012ec04e3032a80c026780804aa033600c65", - "0x26404e8032a80c0c032f004e7032a80c450318404e6032a80c92031b804e5", - "0x3ac18aa033a9d2e873b99ca375e809d40655019c80608809d20655019c606", - "0x1d5406778197e02012a80c0203809e206783bc0caa03bb80cbe013b9daec", - "0x3ddec0755019e80661009eaf403aa80cf303304040255019e40660009e6f2", - "0x1804c40100954067c01986027cbe00eaa033dc0cc20100954067b0198602", - "0x3f40eaa033f00cc20100954067d81986027e3ec0eaa033e80cc2013e80caa", - "0x1d56028001954067f0198a027f81954067c8198a02012a80cfd0330c04fe", - "0x4080c650100954060101c05040340e04065501e02066300a02065501a00ff", - "0x183802830195406013400505032a80c020d00804aa033d40cc3010095406", - "0x1a0f08038a80508032a80c023d00a0e065501a0d05038780506032a80d06", - "0x4300caa033b00c6e0142c0caa033ac0c16014280caa034240cc8014240caa", - "0x2a80c020380a1d0d8642c180687019540685019920286819540676818c202", - "0x198402012a80d0f0330c05108781d54067a8198402012a80d04031940402", - "0x1d54068981984028981954060132804025501a22066180a251103aa80d10", - "0x31404025501a2c066180a2f1603aa80d150330804025501a28066180a2b14", - "0x4680cc6014680caa0346630075580a32065501a2e066280a30065501a2406", - "0x4780caa030083402012a80d1b031940402550180407014740d1c8d8195407", - "0x8f4029001954068fc780e1e0147c0caa0347c0c1c0147c0caa03009a202", - "0x2a80ceb030580523032a80d22033200522032a80d209081c5402908195406", - "0x1a4e065501a46066480a4c0655019da063080a4a0655019d8063700a4806", - "0x3540528032a80c026900804aa034740c650100954060101c052793496480c", - "0x19d8063700a560655019d6060b00a54065501a52066980a52065501a5006", - "0x1c052e96cb2560c034b80caa034a80cc9014b40caa033b40c61014b00caa", - "0x19540676018dc02980195406758182c02978195406788199002012a80c02", - "0x180407014ce6531980300d33032a80d2f033240532032a80ced031840531", - "0x1b80535032a80c43030580534032a80c000332004025501818066000804aa", - "0x4de6d350601a70065501a68066480a6e06550188a063080a6c06550192406", - "0x2a80c890332004025501824066a00804aa030c80cc00100954060101c0538", - "0xa7806550180e063080a76065501908063700a7406550186a060b00a7206", - "0x180e06038780407032a80c0203358053d9e4ee740c034f40caa034e40cc9", - "0x186e065501818062180824065501812061a8081806550180441010240caa", - "0x182c0206019540603819b0020481954060111c0402550180494010dc2407", - "0x2a80c09032f00416032a80c0c033640411032a80c06031b80428032a80c02", - "0x8c6069f1840caa039640cdb011646e1204aa80c150b044500c6d0082a06", - "0x18ce063280804aa031940cdd0119c346504aa80c61033700402550180407", - "0x8f4065501824060b0083c065501838066f80838065501834066f00804aa", - "0x804aa030080e02100a8f409030800caa030780ce0010a80caa030dc0c6e", - "0x1b80ce0010900caa030dc0c6e0108c0caa030480c16011b80caa0318c0ce1", - "0x2f00416032a80c06031b80411032a80c020305804261208c1206130195406", - "0x58221271008c60655018240608808c2065501818064c8082a06550181206", - "0x834069f9940caa038a00ce40100954060138c04282c8dc12aa0318cc215", - "0x2a80c67032d8040255018380632808386703aa80c65033ac0402550180407", - "0x2a80e2a0396412ec010a80caa030a80cd9010a80caa031e80cd8011e83c07", - "0x800c6e011cc0caa0308c0ced0100954060101c0470130901340119b84009", - "0x8054103009ca023d819540639819dc0216819540637018c202158195406", - "0x2a80c2603184042b032a80c24031b8042f032a80c70033980402550180407", - "0x8fa0655018fe0674008fe0655018f60673808f606550185e06770085a06", - "0x1864067500804aa030092802012a80c02038090206a10c80caa039f40ce9", - "0x1954061b8182c021c819540642019e2024201954061a8780eef010d40caa", - "0x300c3e032a80c39033c80486032a80c2d03184043c032a80c2b031b8043a", - "0x2040cf30100954060f0198002012a80c024a00804aa030080e021f218783a", - "0x19540616818c20220819540615818dc022001954061b8182c02448195406", - "0x95406012500402550180407012488641200300c92032a80c89033c80443", - "0x18c2022381954062c818dc024a01954061b8182c022281954060d019e602", - "0x1c0caa030080cf4012652e474a0300c99032a80c45033c80497032a80c07", - "0x1dea0209019540604819e80206019540603819e80204819540603019e802", - "0x1954061b819ec021b81954060110404025501804070100a86025501c240c", - "0x1954060110404025501804070100a8806013940428032a80c59033dc0459", - "0x180c15032a80c28033e40428032a80c16033dc0416032a80c11033e00411", - "0xdc24075501c180601024e002060195406060184c02060195406010900415", - "0x824065501824060b0082206550180e067d00804aa030080e02141640f45", - "0x2dc0463032a80c15033f00402550180407011840d460a8580eaa038440cfb", - "0x804aa030080e020151c0c0272808340655018c6067e808ca06550182c06", - "0x1838067e808ca0655018c2065b808380655018ce067f008ce06550180441", - "0x1e80caa038680d01010780caa030780cd9010780caa031940cd8010680caa", - "0x800c99010800caa031e80cff010095406012500402550180407010a80d48", - "0x2a80c12030580424032a80c6e0481d38023701954061181a0002118195406", - "0x85e065501848065e008f606550183c066c8085a06550186e06370085606", - "0x180407011fc0d493e819540739819b602399c04c09550185e7b168ac18da", - "0x190806820090806550186a811902604021aa04640955018fa066e00804aa", - "0x2180caa030e40d05010f00caa031c00c6e010e80caa030980c16010e40caa", - "0x2240caa030980c16010f80caa031fc0d060100954060101c04861e0e81206", - "0x954060101c04412022412062081954061f01a0a0220019540638018dc02", - "0x1886090f02604022181954060110404025501854063280804aa030092802", - "0x11c0caa030dc0c6e012500caa030480c16011140caa032480d04012480caa", - "0x37404025501804940100954060101c049723a5012064b81954062281a0a02", - "0x93806550180489012640caa030083402012a80c09033000402550180e06", - "0x2780e2a012780caa03008f4022581954064e2640e1e012700caa032700c1c", - "0x2a80c28031b804ae032a80c59030580400032a80ca00341804a0032a80c4b", - "0x1954060141c0402550180494012c15eae048196006550180006828095e06", - "0x1a9428032a80e37034240437032a80c59034200459032a80c12030440412", - "0x8c206a58540caa038580d0b010580caa030a00d0a0100954060101c0411", - "0x18340608808340655018ca0686008ca6303aa80c07032d80402550180407", - "0x2a80c028700804aa030700c3701078386704aa80c150d008130d010680caa", - "0x8c0caa0308c0c110108c3c07550183c0687808dc0655018ce060b008f406", - "0x44404025501804e30108054075501848233702620021201954063d0182202", - "0xa80c16011cc0caa030980d120100954060101c0470035304c065501c4006", - "0x2a80c7d03044047d0601d54060601a1e021781954063981822023d8195406", - "0x80e021901a9a7f032a80e2d03444042d1581d54063e8bcf60989808fa06", - "0x90806550180459010d502075501818060900804aa031fc0d14010095406", - "0xe80c28010f00caa030d40c280100954061c8186e021d0e40eaa032100c12", - "0x1d5406408182402012a80c0203808054e012a80e861e01c2a02430195406", - "0xa004025501882061b808864103aa80c40030480440032a80c028a809123e", - "0x80e020153c04aa0391524070a8088a06550188606140092406550191206", - "0x2640eaa0325c0c120125c0caa0300a2c0223a500eaa030f80c12010095406", - "0x1c2a024f01954064e0185002258195406238185002012a80c99030dc049c", - "0x2a80c028b80800a003aa80c940304804025501804070100aa0025501d3c4b", - "0x962065501800061400804aa032bc0c37012c15e07550195c06090095c06", - "0x2800c120100954060101c0402a88095407592c40e15012c80caa032c00c28", - "0x2a80cb5030dc04b65a81d54065a01824025a0195406012ec04ad5981d5406", - "0xaa4025501d70b70385404b8032a80cb6030a004b7032a80cad030a00402", - "0x19740609009740655018051a012b172075501966060900804aa030080e02", - "0x2f80caa032f00c28012f40caa032b00c280100954065d8186e025e2ec0eaa", - "0x46004c05f81d54065c8182402012a80c02038080553012a80ebe5e81c2a02", - "0x2a80cc0030a004025501984061b80986c203aa80cc10304804c1032a80c02", - "0x804aa030080e020155004aa03b1588070a8098a06550198606140098806", - "0x198e06090098e06550180519010095406558186e02632ac0eaa032fc0c12", - "0x3380caa033240c28013280caa033180c28010095406640186e0264b200eaa", - "0x18c6066000804aa030092802012a80c02038080555012a80ece6501c2a02", - "0x18051d0133c0caa030083402012a80c090346c0402550183c061b80804aa", - "0x3480caa03008f4026881954066833c0e1e013400caa033400c1c013400caa", - "0x1b804d4032a80c2b0305804d3032a80cd50347804d5032a80cd16901c5402", - "0x480040255018040701361acd404819b00655019a6068f809ac06550180c06", - "0xdc04025501804070100aac060139404da032a80cd90326404d9032a80c02", - "0x1954066d01a44026d01954066d81932026d8195406014840402550197e06", - "0x3740caa0300a4602012a80cb9030dc04025501804070100aae060139404dc", - "0x2a80c0203808055803009ca026f01954066e01a44026e01954066e8193202", - "0x3780d22013780caa0337c0c990137c0caa0300a4802012a80cb3030dc0402", - "0x180525010095406500186e02012a80c0203808055903009ca02700195406", - "0x1c0402ad01804e5013880caa033800d22013800caa033840c99013840caa", - "0x9c40655019c6064c809c6065501805260100954064a0186e02012a80c02", - "0x804aa030f80c370100954060101c0402ad81804e5013900caa033880d22", - "0x3b40d29013b5c80755019c80694009c80655019d6064c809d606550180527", - "0x2a80cee034ac0402550180407013940d5c7701954077601a5402760195406", - "0x2a80ce7048ac132d0100954060101c04e803575ce065501dcc0696009cc06", - "0x3d00caa033900c99013cc0caa033a40c160100954067501a360277ba9d209", - "0x3d80caa03bc80d2f013c9e20755019eaf4798265c027a8195406778193202", - "0x26404f9032a80cf10305804f8032a80cf6034c00402550180407013dc0d5e", - "0x198002012a80c024a00804aa030080e020157c0c0272809f40655019f006", - "0x3f00caa033c40c16013ec0caa033dc0d1e0100954060f0186e02012a80c63", - "0x954060101c04fe7ebf012067f01954067d81a3e027e819540603018dc02", - "0x954060f0186e02012a80c6303300040255019d0063280804aa030092802", - "0x195406014c40501032a80c020d00804aa030240d1b0100954067201a3602", - "0xa80502032a80c023d00a000655019ff010387804ff032a80cff0307004ff", - "0x180c6e014180caa030ac0c16014140caa034100d1e014100caa034020407", - "0x1804940100954060101c050883c1812068401954068281a3e02838195406", - "0x240d1b0100954067201a3602012a80c1e030dc040255018c6066000804aa", - "0x42c0caa030180c6e014280caa030ac0c16014240caa033940d1e010095406", - "0x804aa030240d1b0100954060101c050c85c2812068601954068481a3e02", - "0x2a80d0d0326404f9032a80c2b03058050d032a80c024b80804aa032040c37", - "0xa2a028801954060141c050f8701d54060f0182402012a80c024a009f406", - "0x1954068881822028a81954068801822028a01954067c8182c02888195406", - "0x180407014680d608b81954078981a220289c480eaa0345a2b1404cc80516", - "0x804aa034640c370146e32075501a30060900a30065501a2e068900804aa", - "0x1c0402b080954078f4740e15014780caa0346c0c28014740caa0343c0c28", - "0x4840caa0300a2a029001954060141c051f032a80cfa3181d3802012a80c02", - "0x266402930195406908182202928195406900182202920195406890182c02", - "0x4a00d629381954079181a22028f81954068f819780291c880eaa0349a4b24", - "0x1a52060880a58065501a44060b00a52065501a4e068900804aa030080e02", - "0x1e56068880a572a03aa80d2e96cb01332014b80caa034380c11014b40caa", - "0x195406950182c029881954069781a2402012a80c020380a6006b1cbc0caa", - "0x4cc0538032a80d31030440537032a80d1f032f00536032a80c06031b80535", - "0x2a80c020380a7406b24e40caa03cd00ce4014d2673204aa80d389bcda6a0c", - "0x1e68029e81954060110404025501a78063280a793b03aa80d39033ac0402", - "0x1a6606370099a065501a64060b00acc065501aca069a80aca065501a7b3b", - "0x1a74068f00804aa030080e02b459d9a09035a00caa035980d1f0159c0caa", - "0x5b00caa035a40d1f015ac0caa034cc0c6e015a80caa034c80c16015a40caa", - "0xada065501a60068f00804aa0347c0cc00100954060101c056cb5da81206", - "0x5bedc09035c00caa035b40d1f015bc0caa030180c6e015b80caa034a80c16", - "0x2a80d280347804025501a1c061b80804aa0347c0cc00100954060101c0570", - "0x1ae8065501ae2068f80ae606550180c063700ae4065501a44060b00ae206", - "0x182c02ba8195406014d804025501a1c061b80804aa030080e02ba5cee409", - "0x5e2ef7604cb80578032a80cfa032640577032a80d75032640576032a80d12", - "0x1af6069800804aa030080e02be81af97b032a80f7a034bc057abc81d5406", - "0x195406c05fc0f34016000caa030088202bf8195406bf18c0e9c015f80caa", - "0x47c0584032a80c06031b80583032a80d79030580582032a80d81034d40581", - "0x1a3c02012a80c630330004025501804070135f098304819ae065501b0406", - "0x2a80d850347c0587032a80c06031b80586032a80d79030580585032a80d7d", - "0x954067d01a3602012a80d0e030dc0402550180407016230f860481b1006", - "0x1a24060b00b12065501a34068f00804aa0343c0c37010095406318198002", - "0x80e02c662f1409036300caa036240d1f0162c0caa030180c6e016280caa", - "0x240d1b0100954060f0186e02012a80c63033000402550180494010095406", - "0xb1c065501856060b00b1a065501864068f00804aa030300c37010095406", - "0x804aa030080e02c863f1c09036400caa036340d1f0163c0caa030180c6e", - "0x804aa030780c37010095406318198002012a80c0c030dc0402550180494", - "0x180c063700b24065501854060b00b220655018e0068f00804aa030240d1b", - "0x18c2063280804aa030080e02ca64f2409036500caa036440d1f0164c0caa", - "0x18041a010095406038198002012a80c090346c04025501818061b80804aa", - "0x65c0caa0365b2a070f00b2c065501b2c060e00b2c06550180531016540caa", - "0x182c02cd0195406cc81a3c02cc8195406cbe600e2a016600caa03008f402", - "0xb3b9ccd8240d9d032a80d9a0347c059c032a80c06031b8059b032a80c02", - "0x804aa0301c0cc00100954060481a3602012a80c0c030dc0402550180407", - "0x2440d1f0167c0caa030180c6e016780caa030080c16012440caa030440d1e", - "0x804aa030080e020381b4206032a80e02034dc05a0cfe781206d00195406", - "0x82406030480caa030300d3a010300caa030240d39010240caa030180d38", - "0x2a80c59034ec0459032a80c071b81c54021b8195406011e80402550180407", - "0x2a80c06032640406032a80c020348804110301822065501850069d0085006", - "0x2a80e06034f40406032a80c07034f00407032a80c02030440407030180e06", - "0xdc0caa030480d66010480caa030240d650100954060101c040c036881206", - "0x440c060881954061401ad0021401954062c81ace022c81954061b8199a02", - "0x5a80415030182a06550182c06b40082c06550181806b480804aa030080e02", - "0xdc0f6b011640caa030240c99010dc0caa030080c16010240caa0301c0c07", - "0xa00d6d0100954060101c04110368c50065501c2406b6008240c03aa80c59", - "0x1954060a81ade02308195406060182c020a81954060b01adc020b0195406", - "0x5c00465032a80c020d00804aa030440c650100954060101c04633081c0c63", - "0x2a80c023d008ce0655018346503878041a032a80c1a03070041a032a80c02", - "0xa80caa030300c16011e80caa030780d71010780caa0319c3807150083806", - "0xdc2407d203012075501c0e0601026e402100a80e061001954063d01ade02", - "0x18b206ba00850065501812060b008b206550181806b980804aa030080e02", - "0x480c16010580caa030dc0d750100954060101c0402d281804e5010440caa", - "0x18c0caa030440d7a010540caa0300af2020881954060b01ae802140195406", - "0x1b4c1a032a80e61034440461032a80c653181eec023281954060a8183802", - "0x780d6e010780caa030700d6d010700caa030680d120100954060101c0467", - "0x80e02100a80e061001954063d01ade02150195406140182c023d0195406", - "0x900caa031b80d6f0108c0caa030a00c16011b80caa0319c0d71010095406", - "0x1954070301af0020301954060381aee020381954060101932021208c0e06", - "0x86e06550182406be8082406550181206bd80804aa030080e020601b4e09", - "0x82206030440caa030a00d80010a00caa031640d7f011640caa030dc0d7e", - "0x2704020a8180c15032a80c16036000416032a80c0c036040402550180407", - "0x8b206550181806c180804aa030080e021b8480fa8060240eaa0381c0c02", - "0x954060101c0402d481804e5010440caa031640d84010a00caa030240c16", - "0xb0a020881954060b01b0802140195406090182c020b01954061b819ae02", - "0x2a80c653181f0e023281954060a81838023181954060881b0c020a8195406", - "0x700caa030680d300100954060101c0467036a834065501cc20697808c206", - "0x1b1402150195406140182c023d01954060f01b12020f01954060e01b1002", - "0xa00c16011b80caa0319c0d8b0100954060101c04201501c0c20032a80c7a", - "0x3012075501c0e060102718021208c0e061201954063701b1402118195406", - "0x850065501812060b008b206550181806b980804aa030080e021b8480fab", - "0x580caa030dc0d750100954060101c0402d601804e5010440caa031640d74", - "0x440d7a010540caa0300b1a020881954060b01ae802140195406090182c02", - "0x2a80e61034440461032a80c653181eec023281954060a8183802318195406", - "0x780caa030700d6d010700caa030680d120100954060101c0467036b43406", - "0xa80e061001954063d01ade02150195406140182c023d01954060f01adc02", - "0x1b80d6f0108c0caa030a00c16011b80caa0319c0d710100954060101c0420", - "0x2a80c0c03098040c032a80c021200804aa0300928021208c0e06120195406", - "0x240c120100954060101c04282c81f5c370901d5407060180409380081806", - "0x2a80c61030dc04633081d54060a81824020a81954060145404160881d5406", - "0x540412032a80c1203058041a032a80c63030a00465032a80c16030a00402", - "0x2a80c67032640467032a80c02c700804aa030080e02016bc04aa03868ca07", - "0x840065501824060b0083c06550180515010700caa0319c0e074e008ce06", - "0x8547a03aa80c233708013320108c0caa030780c11011b80caa030440c11", - "0x1a2402012a80c02038084c06d80900caa038a80d11010700caa030700cbc", - "0x2a80c1c032f0042f032a80c37031b8047b032a80c7a030580470032a80c24", - "0xb40ce4010b4567304aa80c7f3e8bcf60c99808fe0655018e00608808fa06", - "0x19080632809083503aa80c32033ac0402550180407012040db1190195407", - "0x878065501874069a808740655018723503cd00439032a80c022080804aa", - "0xf90c09032240caa030f00d1f010f80caa030ac0c6e012180caa031cc0c16", - "0xac0c6e011040caa031cc0c16011000caa032040d1e0100954060101c0489", - "0x700cc00100954060101c04922190412064901954062001a3e02218195406", - "0x11c0caa030dc0c6e012500caa031e80c16011140caa030980d1e010095406", - "0x804aa030440c370100954060101c049723a5012064b81954062281a3e02", - "0x180441012700caa032640e074e00932065501932064c8093206550180536", - "0x195406090182c025001954064f01a6a024f019540625a700f340112c0caa", - "0x2a80c02038095eae000240caf032a80ca00347c04ae032a80c37031b80400", - "0x2a80c0244809600655018041a010095406038198002012a80c09030dc0402", - "0x9660655018047a012c80caa032c560070f00962065501962060e0096206", - "0x18dc025a81954062c8182c025a01954065681a3c02568195406592cc0e2a", - "0x80e06550180406088096eb65a8240cb7032a80cb40347c04b6032a80c28", - "0x1b2002012a80c02038081806d90240caa038180d0b010180caa0301c0d8f", - "0x80e022c8180c59032a80c37036480437032a80c12036440412032a80c09", - "0x1838020881954060164c0428032a80c020d00804aa030300c65010095406", - "0x182c15038a80415032a80c023d0082c06550182228038780411032a80c11", - "0x180407ca808ca06031940caa0318c0d920118c0caa031840d94011840caa", - "0x180e060b0082406550181206cb00804aa030080e020601b66090381d5407", - "0x1804410100954060101c0402da01804e5011640caa030480d97010dc0caa", - "0x1640caa030440d97010dc0caa030300c16010440caa030a00d98010a00caa", - "0x1954070101b36020a8580e060a81954062c81b34020b01954061b81b3202", - "0x5b8040c032a80c07035b40402550180c064080804aa030080e020481b6a07", - "0x240c370100954060101c0437030186e06550182406b78082406550181806", - "0x8220655018047a010a00caa03018b2070f008b20655018041a010095406", - "0x1840c063081954060a81ade020a81954060b01ae2020b0195406140440e2a", - "0x300db60481954070301a58020301954060381b3802038195406010193202", - "0x186e06cf0086e06550182406488082406550181206ce80804aa030080e02", - "0x8500655018041a01009540606018ca02012a80c0203808b206031640caa", - "0x18047a010580caa0304450070f00822065501822060e008220655018059f", - "0x1954063181b3c023181954063081b40023081954060b0540e2a010540caa", - "0x2a80c06032040402550180407010240db80381954070101b6e02328180c65", - "0x180c37032a80c12036280412032a80c0c03624040c032a80c07036200402", - "0x180c59038780459032a80c020d00804aa030240d1b0100954060101c0437", - "0x540caa030580d8b010580caa030a0220715008220655018047a010a00caa", - "0x954060101c0406036e804aa038080db9011840c063081954060a81b1402", - "0x1804e5010300caa030240dbc010240caa0301c0dbb0101c0caa030088202", - "0x1b7c020601954060901b78020901954060301acc02012a80c020380805bd", - "0x88202012a80c02038080c06e000954070101b7e021b8180c37032a80c0c", - "0x805c303009ca020601954060481b84020481954060381b8202038195406", - "0x2a80c0c03710040c032a80c12037080412032a80c06035f40402550180407", - "0x85059039640c020481c0c02309640c0206048b206010304c37030186e06", - "0x813c5030085009038240e076d8240e060119cb20601030ca590300818d6", - "0x30120703008e0590300818370e078b206010df8c0703008dc06010245406", - "0x180412e48240e06011ec0c02048785606010339006011cc0c231181f8e12", - "0xdc0dcc010700c1c0372c0481031fc0dca060240e06011f40c02048dc381e", - "0x1b9e07030091202038dc6e0204f380e060122404071b8dc0409e68090c06", - "0x7480e060122404071b8dc0409e881c0c024a0080e1c0e00813d0012480c1c", - "0x93202038700407ea0092e061b81ba60903818047d0300812370f018040c", - "0x186e06ec01804940301d4007eb8093c060e01bac06012240c074e01faa06", - "0x1da011040c1c03764043a" - ], - "sierra_program_debug_info": { - "type_names": [], - "libfunc_names": [], - "user_func_names": [] - }, - "contract_class_version": "0.1.0", - "entry_points_by_type": { - "EXTERNAL": [ - { - "selector": "0x3d91620ebfd3035266d72c83df4f0f314ade6a3449bc2193fe8078df7553873", - "function_idx": 0 - } - ], - "L1_HANDLER": [], - "CONSTRUCTOR": [] - }, - "abi": [ - { - "type": "impl", - "name": "Keccak", - "interface_name": "test_cairo_keccak::test_cairo_keccak::IKeccak" - }, - { - "type": "interface", - "name": "test_cairo_keccak::test_cairo_keccak::IKeccak", - "items": [ - { - "type": "function", - "name": "cairo_keccak_test", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "test_cairo_keccak::test_cairo_keccak::Keccak::Event", - "kind": "enum", - "variants": [] - } - ] -} \ No newline at end of file diff --git a/tests/account_panic.rs b/tests/account_panic.rs index 195b21d9f..0de6d50f1 100644 --- a/tests/account_panic.rs +++ b/tests/account_panic.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{collections::HashMap, sync::Arc}; use cairo_vm::felt::Felt252; use starknet_in_rust::{ diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index c43af7bb6..4a8db67ab 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -6,7 +6,6 @@ use cairo_vm::{ use num_bigint::BigUint; use num_traits::{Num, One, Zero}; use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; -use starknet_in_rust::utils::calculate_sn_keccak; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ @@ -26,6 +25,7 @@ use starknet_in_rust::{ utils::{Address, ClassHash}, EntryPointType, }; +use starknet_in_rust::{utils::calculate_sn_keccak, EntryPointType}; use std::{ collections::{HashMap, HashSet}, sync::Arc, @@ -1572,7 +1572,8 @@ fn replace_class_contract_call() { block_context.invoke_tx_max_n_steps(), ) .unwrap(); - assert_eq!(result.call_info.unwrap().retdata, vec![17.into()]); + assert_eq!(result.call_info.clone().unwrap().retdata, vec![17.into()]); + assert_eq!(result.call_info.unwrap().failure_flag, false); } #[test] @@ -3006,7 +3007,7 @@ fn send_messages_to_l1_different_contract_calls_cairo0_to_cairo1() { #[test] #[cfg(not(feature = "cairo_1_tests"))] fn keccak_syscall() { - let program_data = include_bytes!("../starknet_programs/keccak/test_cairo_keccak.casm"); + let program_data = include_bytes!("../starknet_programs/cairo2/test_cairo_keccak.casm"); let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); let entrypoints = contract_class.clone().entry_points_by_type; let read_storage_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; @@ -3067,9 +3068,543 @@ fn keccak_syscall() { ) .unwrap(); - let retdata = call_info.call_info.unwrap().retdata; + let call_info = call_info.call_info.unwrap(); + + assert_eq!(call_info.retdata[0], Felt252::one()); + assert_eq!(call_info.gas_consumed, 545370); +} + +#[test] +fn library_call_recursive_50_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/square_root_recursive.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/square_root_recursive.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let entrypoints = contract_class.clone().entry_points_by_type; + let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add lib contract to the state + + #[cfg(not(feature = "cairo_1_tests"))] + let lib_program_data = include_bytes!("../starknet_programs/cairo2/math_lib.casm"); + #[cfg(feature = "cairo_1_tests")] + let lib_program_data = include_bytes!("../starknet_programs/cairo1/math_lib.casm"); + + let lib_contract_class: CasmContractClass = serde_json::from_slice(lib_program_data).unwrap(); + + let lib_address = Address(1112.into()); + let lib_class_hash: ClassHash = [2; 32]; + let lib_nonce = Felt252::zero(); + + contract_class_cache.insert( + lib_class_hash, + CompiledClass::Casm(Arc::new(lib_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(lib_address.clone(), lib_class_hash); + state_reader + .address_to_nonce_mut() + .insert(lib_address, lib_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + // Create an execution entry point + let calldata = [ + felt_str!("1125899906842624"), + Felt252::from_bytes_be(&lib_class_hash), + Felt252::from(50), + ] + .to_vec(); + let caller_address = Address(0000.into()); + let entry_point_type = EntryPointType::External; + + let exec_entry_point = ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(entrypoint_selector.clone()), + caller_address, + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u128::MAX, + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + let expected_execution_resources_internal_call = ExecutionResources { + #[cfg(not(feature = "cairo_1_tests"))] + n_steps: 80, + #[cfg(feature = "cairo_1_tests")] + n_steps: 85, + n_memory_holes: 5, + builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 7)]), + }; + + let call_info = exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + + assert_eq!(call_info.internal_calls.len(), 50); + assert_eq!( + call_info.internal_calls[0], + CallInfo { + caller_address: Address(0.into()), + call_type: Some(CallType::Delegate), + contract_address: Address(1111.into()), + entry_point_selector: Some( + Felt252::from_str_radix( + "544923964202674311881044083303061611121949089655923191939299897061511784662", + 10, + ) + .unwrap(), + ), + entry_point_type: Some(EntryPointType::External), + calldata: vec![felt_str!("1125899906842624")], + retdata: [felt_str!("33554432")].to_vec(), + execution_resources: Some(expected_execution_resources_internal_call), + class_hash: Some(lib_class_hash), + gas_consumed: 0, + ..Default::default() + } + ); + assert_eq!(call_info.retdata, [1.into()].to_vec()); + assert!(!call_info.failure_flag); +} + +#[test] +fn call_contract_storage_write_read_recursive_50_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( + "increase_balance_recursive".as_bytes(), + )); + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add simple_wallet contract to the state + #[cfg(not(feature = "cairo_1_tests"))] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); + #[cfg(feature = "cairo_1_tests")] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); + + let simple_wallet_contract_class: CasmContractClass = + serde_json::from_slice(simple_wallet_program_data).unwrap(); + let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class + .entry_points_by_type + .constructor + .get(0) + .unwrap() + .selector + .clone(); + + let simple_wallet_address = Address(1112.into()); + let simple_wallet_class_hash: ClassHash = [2; 32]; + let simple_wallet_nonce = Felt252::zero(); + + contract_class_cache.insert( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(simple_wallet_address.clone(), simple_wallet_class_hash); + state_reader + .address_to_nonce_mut() + .insert(simple_wallet_address.clone(), simple_wallet_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + + let mut resources_manager = ExecutionResourcesManager::default(); + + let create_execute_extrypoint = |selector: &BigUint, + calldata: Vec, + entry_point_type: EntryPointType, + class_hash: [u8; 32], + address: Address| + -> ExecutionEntryPoint { + ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(selector.clone()), + Address(0000.into()), + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u64::MAX.into(), + ) + }; + + // RUN SIMPLE_WALLET CONSTRUCTOR + // Create an execution entry point + let calldata = [25.into()].to_vec(); + let constructor_exec_entry_point = create_execute_extrypoint( + &simple_wallet_constructor_entrypoint_selector, + calldata, + EntryPointType::Constructor, + simple_wallet_class_hash, + simple_wallet_address.clone(), + ); + + // Run constructor entrypoint + constructor_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0.clone()].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); + + // RUN INCREASE_BALANCE + // Create an execution entry point + let calldata = [50.into(), simple_wallet_address.0.clone()].to_vec(); + let increase_balance_entry_point = create_execute_extrypoint( + increase_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run increase_balance entrypoint + let call_info = increase_balance_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + // Check that the recursive function did in fact call the simple_wallet contract 50 times + assert_eq!(call_info.internal_calls.len(), 50); + assert!(!call_info.failure_flag); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address, + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [75.into()]) +} + +#[test] +fn call_contract_storage_write_read_recursive_100_calls() { + // Create program and entry point types for contract class + #[cfg(not(feature = "cairo_1_tests"))] + let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); + #[cfg(feature = "cairo_1_tests")] + let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); + + let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let get_balance_entrypoint_selector = + &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); + let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( + "increase_balance_recursive".as_bytes(), + )); + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add simple_wallet contract to the state + #[cfg(not(feature = "cairo_1_tests"))] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); + #[cfg(feature = "cairo_1_tests")] + let simple_wallet_program_data = + include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); + + let simple_wallet_contract_class: CasmContractClass = + serde_json::from_slice(simple_wallet_program_data).unwrap(); + let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class + .entry_points_by_type + .constructor + .get(0) + .unwrap() + .selector + .clone(); + + let simple_wallet_address = Address(1112.into()); + let simple_wallet_class_hash: ClassHash = [2; 32]; + let simple_wallet_nonce = Felt252::zero(); + + contract_class_cache.insert( + simple_wallet_class_hash, + CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), + ); + state_reader + .address_to_class_hash_mut() + .insert(simple_wallet_address.clone(), simple_wallet_class_hash); + state_reader + .address_to_nonce_mut() + .insert(simple_wallet_address.clone(), simple_wallet_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + + let mut resources_manager = ExecutionResourcesManager::default(); + + let create_execute_extrypoint = |selector: &BigUint, + calldata: Vec, + entry_point_type: EntryPointType, + class_hash: [u8; 32], + address: Address| + -> ExecutionEntryPoint { + ExecutionEntryPoint::new( + address, + calldata, + Felt252::new(selector.clone()), + Address(0000.into()), + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + u64::MAX.into(), + ) + }; + + // RUN SIMPLE_WALLET CONSTRUCTOR + // Create an execution entry point + let calldata = [25.into()].to_vec(); + let constructor_exec_entry_point = create_execute_extrypoint( + &simple_wallet_constructor_entrypoint_selector, + calldata, + EntryPointType::Constructor, + simple_wallet_class_hash, + simple_wallet_address.clone(), + ); + + // Run constructor entrypoint + constructor_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0.clone()].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); - assert_eq!(retdata[0], Felt252::one()); + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); + + // RUN INCREASE_BALANCE + // Create an execution entry point + let calldata = [100.into(), simple_wallet_address.0.clone()].to_vec(); + let increase_balance_entry_point = create_execute_extrypoint( + increase_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address.clone(), + ); + + // Run increase_balance entrypoint + let call_info = increase_balance_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + // Check that the recursive function did in fact call the simple_wallet contract 50 times + assert_eq!(call_info.internal_calls.len(), 100); + assert!(!call_info.failure_flag); + + // RUN GET_BALANCE + // Create an execution entry point + let calldata = [simple_wallet_address.0].to_vec(); + let get_balance_exec_entry_point = create_execute_extrypoint( + get_balance_entrypoint_selector, + calldata, + EntryPointType::External, + class_hash, + address, + ); + + // Run get_balance entrypoint + let call_info = get_balance_exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap(); + assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) } #[test] diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs index dfa10b1de..870eba9f2 100644 --- a/tests/cairo_native.rs +++ b/tests/cairo_native.rs @@ -2,18 +2,21 @@ use crate::CallType::Call; use cairo_lang_starknet::casm_contract_class::CasmContractEntryPoints; +use cairo_lang_starknet::contract_class::ContractClass; use cairo_lang_starknet::contract_class::ContractEntryPoints; use cairo_vm::felt::Felt252; use num_bigint::BigUint; -use num_traits::One; -use num_traits::Zero; +use num_traits::{Num, One, Zero}; use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +#[cfg(feature = "cairo-native")] +use starknet_api::hash::StarkHash; use starknet_in_rust::definitions::block_context::BlockContext; use starknet_in_rust::execution::{Event, OrderedEvent}; use starknet_in_rust::hash_utils::calculate_contract_address; use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; use starknet_in_rust::state::contract_class_cache::ContractClassCache; use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; +use starknet_in_rust::state::state_api::State; use starknet_in_rust::CasmContractClass; use starknet_in_rust::EntryPointType::{self, External}; use starknet_in_rust::{ @@ -25,10 +28,164 @@ use starknet_in_rust::{ state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{Address, ClassHash}, }; - +use std::collections::HashMap; use std::collections::HashSet; use std::sync::Arc; +fn insert_sierra_class_into_cache( + contract_class_cache: &mut HashMap, + class_hash: ClassHash, + sierra_class: ContractClass, +) { + let sierra_program = sierra_class.extract_sierra_program().unwrap(); + let entry_points = sierra_class.entry_points_by_type; + contract_class_cache.insert( + class_hash, + CompiledClass::Sierra(Arc::new((sierra_program, entry_points))), + ); +} + +#[test] +#[cfg(feature = "cairo-native")] +fn get_block_hash_test() { + use starknet_in_rust::utils::felt_to_hash; + + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_block_hash_basic.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + let casm_data = include_bytes!("../starknet_programs/cairo2/get_block_hash_basic.casm"); + let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + let native_entrypoints = sierra_contract_class.clone().entry_points_by_type; + let native_external_selector = &native_entrypoints.external.get(0).unwrap().selector; + + let casm_entrypoints = casm_contract_class.clone().entry_points_by_type; + let casm_external_selector = &casm_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + let native_class_hash: ClassHash = [1; 32]; + let casm_class_hash: ClassHash = [2; 32]; + let caller_address = Address(1.into()); + + insert_sierra_class_into_cache( + &mut contract_class_cache, + native_class_hash, + sierra_contract_class, + ); + + contract_class_cache.insert( + casm_class_hash, + CompiledClass::Casm(Arc::new(casm_contract_class)), + ); + + let mut state_reader = InMemoryStateReader::default(); + let nonce = Felt252::zero(); + + state_reader + .address_to_class_hash_mut() + .insert(caller_address.clone(), casm_class_hash); + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let state_reader = Arc::new(state_reader); + let mut state_vm = CachedState::new(state_reader.clone(), contract_class_cache.clone()); + + state_vm.cache_mut().storage_initial_values_mut().insert( + (Address(1.into()), felt_to_hash(&Felt252::from(10))), + Felt252::from_bytes_be(StarkHash::new([5; 32]).unwrap().bytes()), + ); + let mut state_native = CachedState::new(state_reader, contract_class_cache); + state_native + .cache_mut() + .storage_initial_values_mut() + .insert( + (Address(1.into()), felt_to_hash(&Felt252::from(10))), + Felt252::from_bytes_be(StarkHash::new([5; 32]).unwrap().bytes()), + ); + + // block number + let calldata = [10.into()].to_vec(); + + let native_result = execute( + &mut state_native, + &caller_address, + &caller_address, + native_external_selector, + &calldata, + EntryPointType::External, + &native_class_hash, + ); + + let vm_result = execute( + &mut state_vm, + &caller_address, + &caller_address, + casm_external_selector, + &calldata, + EntryPointType::External, + &casm_class_hash, + ); + + assert_eq!(vm_result.caller_address, caller_address); + assert_eq!(vm_result.call_type, Some(CallType::Delegate)); + assert_eq!(vm_result.contract_address, caller_address); + assert_eq!( + vm_result.entry_point_selector, + Some(Felt252::new(casm_external_selector)) + ); + assert_eq!(vm_result.entry_point_type, Some(EntryPointType::External)); + assert_eq!(vm_result.calldata, calldata); + assert!(!vm_result.failure_flag); + assert_eq!( + vm_result.retdata, + [Felt252::from_bytes_be( + StarkHash::new([5; 32]).unwrap().bytes() + )] + .to_vec() + ); + assert_eq!(vm_result.class_hash, Some(casm_class_hash)); + + assert_eq!(native_result.caller_address, caller_address); + assert_eq!(native_result.call_type, Some(CallType::Delegate)); + assert_eq!(native_result.contract_address, caller_address); + assert_eq!( + native_result.entry_point_selector, + Some(Felt252::new(native_external_selector)) + ); + assert_eq!( + native_result.entry_point_type, + Some(EntryPointType::External) + ); + assert_eq!(native_result.calldata, calldata); + assert!(!native_result.failure_flag); + assert_eq!( + native_result.retdata, + [Felt252::from_bytes_be( + StarkHash::new([5; 32]).unwrap().bytes() + )] + .to_vec() + ); + assert_eq!(native_result.execution_resources, None); + assert_eq!(native_result.class_hash, Some(native_class_hash)); + assert_eq!(native_result.gas_consumed, vm_result.gas_consumed); + + assert_eq!(vm_result.events, native_result.events); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); +} + #[test] fn integration_test_erc20() { let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = @@ -56,11 +213,12 @@ fn integration_test_erc20() { let caller_address = Address(123456789.into()); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, NATIVE_CLASS_HASH, - CompiledClass::Sierra(Arc::new(sierra_contract_class)), + sierra_contract_class, ); - contract_class_cache.set_contract_class( + contract_class_cache.insert( CASM_CLASS_HASH, CompiledClass::Casm(Arc::new(casm_contract_class)), ); @@ -148,6 +306,7 @@ fn integration_test_erc20() { assert_eq!(native_result.retdata, [].to_vec()); assert_eq!(native_result.execution_resources, None); assert_eq!(native_result.class_hash, Some(NATIVE_CLASS_HASH)); + assert_eq!(native_result.gas_consumed, 126270); assert_eq!(vm_result.events, native_result.events); assert_eq!( @@ -452,13 +611,16 @@ fn call_contract_test() { let callee_class_hash: ClassHash = [2; 32]; let callee_nonce = Felt252::zero(); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, caller_class_hash, - CompiledClass::Sierra(Arc::new(caller_contract_class)), + caller_contract_class, ); - contract_class_cache.set_contract_class( + + insert_sierra_class_into_cache( + &mut contract_class_cache, callee_class_hash, - CompiledClass::Sierra(Arc::new(callee_contract_class)), + callee_contract_class, ); let mut state_reader = InMemoryStateReader::default(); @@ -537,14 +699,16 @@ fn call_echo_contract_test() { let callee_class_hash: ClassHash = [2; 32]; let callee_nonce = Felt252::zero(); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, caller_class_hash, - CompiledClass::Sierra(Arc::new(caller_contract_class)), + caller_contract_class, ); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, callee_class_hash, - CompiledClass::Sierra(Arc::new(callee_contract_class)), + callee_contract_class, ); let mut state_reader = InMemoryStateReader::default(); @@ -625,14 +789,16 @@ fn call_events_contract_test() { let callee_class_hash: ClassHash = [2; 32]; let callee_nonce = Felt252::zero(); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, caller_class_hash, - CompiledClass::Sierra(Arc::new(caller_contract_class)), + caller_contract_class, ); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, callee_class_hash, - CompiledClass::Sierra(Arc::new(callee_contract_class)), + callee_contract_class, ); let mut state_reader = InMemoryStateReader::default(); @@ -708,8 +874,426 @@ fn call_events_contract_test() { assert_eq!(sorted_events, vec![event]); } +#[test] +fn replace_class_test() { + // Create program and entry point types for contract class + let contract_class_a: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_number_a.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + let casm_data = include_bytes!("../starknet_programs/cairo2/get_number_a.casm"); + let casm_contract_class: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + let entrypoints_a = contract_class_a.clone().entry_points_by_type; + let replace_selector = &entrypoints_a.external.get(0).unwrap().selector; + + let casm_entrypoints = casm_contract_class.clone().entry_points_by_type; + let casm_replace_selector = &casm_entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + let address = Address(1111.into()); + let casm_address = Address(2222.into()); + + static CLASS_HASH_A: ClassHash = [1; 32]; + static CASM_CLASS_HASH_A: ClassHash = [2; 32]; + + let nonce = Felt252::zero(); + + insert_sierra_class_into_cache(&mut contract_class_cache, CLASS_HASH_A, contract_class_a); + + contract_class_cache.insert( + CASM_CLASS_HASH_A, + CompiledClass::Casm(Arc::new(casm_contract_class)), + ); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), CLASS_HASH_A); + state_reader + .address_to_class_hash_mut() + .insert(casm_address.clone(), CASM_CLASS_HASH_A); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add get_number_b contract to the state (only its contract_class) + let contract_class_b: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_number_b.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + let casm_data = include_bytes!("../starknet_programs/cairo2/get_number_b.casm"); + let casm_contract_class_b: CasmContractClass = serde_json::from_slice(casm_data).unwrap(); + + static CLASS_HASH_B: ClassHash = [3; 32]; + static CASM_CLASS_HASH_B: ClassHash = [4; 32]; + + insert_sierra_class_into_cache( + &mut contract_class_cache, + CLASS_HASH_B, + contract_class_b.clone(), + ); + + contract_class_cache.insert( + CASM_CLASS_HASH_B, + CompiledClass::Casm(Arc::new(casm_contract_class_b.clone())), + ); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader.clone()), contract_class_cache.clone()); + let mut vm_state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + // Run upgrade entrypoint and check that the storage was updated with the new contract class + // Create an execution entry point + let calldata = [Felt252::from_bytes_be(&CLASS_HASH_B)].to_vec(); + let caller_address = Address(0000.into()); + let entry_point_type = EntryPointType::External; + let native_result = execute( + &mut state, + &caller_address, + &address, + replace_selector, + &calldata, + entry_point_type, + &CLASS_HASH_A, + ); + let calldata = [Felt252::from_bytes_be(&CASM_CLASS_HASH_B)].to_vec(); + let vm_result = execute( + &mut vm_state, + &caller_address, + &casm_address, + casm_replace_selector, + &calldata, + entry_point_type, + &CASM_CLASS_HASH_A, + ); + + // Check that the class was indeed replaced in storage + assert_eq!(state.get_class_hash_at(&address).unwrap(), CLASS_HASH_B); + // Check that the class_hash_b leads to contract_class_b for soundness + let sierra_program = contract_class_b.extract_sierra_program().unwrap(); + let entry_points = contract_class_b.entry_points_by_type; + assert_eq!( + state.get_contract_class(&CLASS_HASH_B).unwrap(), + CompiledClass::Sierra(Arc::new((sierra_program, entry_points))), + ); + + // Check that the class was indeed replaced in storage + assert_eq!( + vm_state.get_class_hash_at(&casm_address).unwrap(), + CASM_CLASS_HASH_B + ); + // Check that the class_hash_b leads to contract_class_b for soundness + assert_eq!( + vm_state.get_contract_class(&CASM_CLASS_HASH_B).unwrap(), + CompiledClass::Casm(Arc::new(casm_contract_class_b)) + ); + + assert_eq!(native_result.retdata, vm_result.retdata); + assert_eq!(native_result.events, vm_result.events); + assert_eq!( + native_result.accessed_storage_keys, + vm_result.accessed_storage_keys + ); + assert_eq!(native_result.l2_to_l1_messages, vm_result.l2_to_l1_messages); + assert_eq!(native_result.gas_consumed, vm_result.gas_consumed); + assert_eq!(native_result.failure_flag, vm_result.failure_flag); + assert_eq_sorted!(native_result.internal_calls, vm_result.internal_calls); + assert_eq!(native_result.class_hash.unwrap(), CLASS_HASH_A); + assert_eq!(vm_result.class_hash.unwrap(), CASM_CLASS_HASH_A); + assert_eq!(native_result.caller_address, caller_address); + assert_eq!(vm_result.caller_address, caller_address); + assert_eq!(native_result.call_type, vm_result.call_type); + assert_eq!(native_result.contract_address, address); + assert_eq!(vm_result.contract_address, casm_address); + assert_eq!(native_result.code_address, vm_result.code_address); + assert_eq!( + native_result.entry_point_selector, + vm_result.entry_point_selector + ); + assert_eq!(native_result.entry_point_type, vm_result.entry_point_type); +} + +#[test] +fn replace_class_contract_call() { + fn compare_results(native_result: CallInfo, vm_result: CallInfo) { + assert_eq!(vm_result.retdata, native_result.retdata); + assert_eq!(vm_result.events, native_result.events); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!(vm_result.l2_to_l1_messages, native_result.l2_to_l1_messages); + assert_eq!(vm_result.gas_consumed, native_result.gas_consumed); + assert_eq!(vm_result.failure_flag, false); + assert_eq!(native_result.failure_flag, false); + assert_eq_sorted!(vm_result.internal_calls, native_result.internal_calls); + assert_eq!( + vm_result.accessed_storage_keys, + native_result.accessed_storage_keys + ); + assert_eq!( + vm_result.storage_read_values, + native_result.storage_read_values + ); + assert_eq!(vm_result.class_hash, native_result.class_hash); + } + // Same execution than cairo_1_syscalls.rs test but comparing results to native execution. + + // SET GET_NUMBER_A + // Add get_number_a.cairo to storage + let program_data = include_bytes!("../starknet_programs/cairo2/get_number_a.casm"); + let casm_contract_class_a: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + + let sierra_class_a: cairo_lang_starknet::contract_class::ContractClass = serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_number_a.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + let mut native_contract_class_cache = HashMap::new(); + + let address = Address(Felt252::one()); + let class_hash_a: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache.insert( + class_hash_a, + CompiledClass::Casm(Arc::new(casm_contract_class_a)), + ); + insert_sierra_class_into_cache( + &mut native_contract_class_cache, + class_hash_a, + sierra_class_a, + ); + + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash_a); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce.clone()); + + let mut native_state_reader = InMemoryStateReader::default(); + native_state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash_a); + + // SET GET_NUMBER_B + + // Add get_number_b contract to the state (only its contract_class) + + let program_data = include_bytes!("../starknet_programs/cairo2/get_number_b.casm"); + let contract_class_b: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + + let sierra_class_b: cairo_lang_starknet::contract_class::ContractClass = serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_number_b.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + let class_hash_b: ClassHash = [2; 32]; + + contract_class_cache.insert( + class_hash_b, + CompiledClass::Casm(Arc::new(contract_class_b)), + ); + insert_sierra_class_into_cache( + &mut native_contract_class_cache, + class_hash_b, + sierra_class_b, + ); + + // SET GET_NUMBER_WRAPPER + + // Create program and entry point types for contract class + let program_data = include_bytes!("../starknet_programs/cairo2/get_number_wrapper.casm"); + let wrapper_contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); + let entrypoints = wrapper_contract_class.clone().entry_points_by_type; + let get_number_entrypoint_selector = &entrypoints.external.get(1).unwrap().selector; + let upgrade_entrypoint_selector: &BigUint = &entrypoints.external.get(0).unwrap().selector; + + let wrapper_sierra_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_number_wrapper.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + let native_entrypoints = wrapper_sierra_class.clone().entry_points_by_type; + + let native_get_number_entrypoint_selector = + &native_entrypoints.external.get(1).unwrap().selector; + let native_upgrade_entrypoint_selector: &BigUint = + &native_entrypoints.external.get(0).unwrap().selector; + + let wrapper_address = Address(Felt252::from(2)); + let wrapper_class_hash: ClassHash = [3; 32]; + + contract_class_cache.insert( + wrapper_class_hash, + CompiledClass::Casm(Arc::new(wrapper_contract_class)), + ); + insert_sierra_class_into_cache( + &mut native_contract_class_cache, + wrapper_class_hash, + wrapper_sierra_class, + ); + + state_reader + .address_to_class_hash_mut() + .insert(wrapper_address.clone(), wrapper_class_hash); + state_reader + .address_to_nonce_mut() + .insert(wrapper_address.clone(), nonce); + + native_state_reader + .address_to_class_hash_mut() + .insert(wrapper_address, wrapper_class_hash); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader.clone()), contract_class_cache.clone()); + let mut native_state = CachedState::new(Arc::new(state_reader), contract_class_cache); + // CALL GET_NUMBER BEFORE REPLACE_CLASS + + let calldata = [].to_vec(); + let caller_address = Address(0000.into()); + let entry_point_type = EntryPointType::External; + + let vm_result = execute( + &mut state, + &caller_address, + &address, + get_number_entrypoint_selector, + &calldata, + entry_point_type, + &wrapper_class_hash, + ); + + let native_result = execute( + &mut native_state, + &caller_address, + &address, + native_get_number_entrypoint_selector, + &calldata, + entry_point_type, + &wrapper_class_hash, + ); + compare_results(native_result, vm_result); + + // REPLACE_CLASS + + let calldata = [Felt252::from_bytes_be(&class_hash_b)].to_vec(); + + let vm_result = execute( + &mut state, + &caller_address, + &address, + upgrade_entrypoint_selector, + &calldata, + entry_point_type, + &wrapper_class_hash, + ); + + let native_result = execute( + &mut native_state, + &caller_address, + &address, + native_upgrade_entrypoint_selector, + &calldata, + entry_point_type, + &wrapper_class_hash, + ); + compare_results(native_result, vm_result); + // CALL GET_NUMBER AFTER REPLACE_CLASS + + let calldata = [].to_vec(); + + let vm_result = execute( + &mut state, + &caller_address, + &address, + get_number_entrypoint_selector, + &calldata, + entry_point_type, + &wrapper_class_hash, + ); + + let native_result = execute( + &mut native_state, + &caller_address, + &address, + native_get_number_entrypoint_selector, + &calldata, + entry_point_type, + &wrapper_class_hash, + ); + compare_results(native_result, vm_result); +} + +#[test] +#[cfg(feature = "cairo-native")] +fn keccak_syscall_test() { + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/test_cairo_keccak.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + let native_entrypoints = sierra_contract_class.clone().entry_points_by_type; + let native_entrypoint_selector = &native_entrypoints.external.get(0).unwrap().selector; + + let native_class_hash: ClassHash = [1; 32]; + + let caller_address = Address(123456789.into()); + let mut contract_class_cache = HashMap::new(); + + insert_sierra_class_into_cache( + &mut contract_class_cache, + native_class_hash, + sierra_contract_class, + ); + + let mut state_reader = InMemoryStateReader::default(); + let nonce = Felt252::zero(); + + state_reader + .address_to_nonce_mut() + .insert(caller_address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + let native_result = execute( + &mut state, + &caller_address, + &caller_address, + native_entrypoint_selector, + &[], + EntryPointType::External, + &native_class_hash, + ); + + assert!(!native_result.failure_flag); + assert_eq!(native_result.gas_consumed, 545370); +} + +#[allow(clippy::too_many_arguments)] fn execute( - state: &mut CachedState, + state: &mut CachedState, caller_address: &Address, callee_address: &Address, selector: &BigUint, @@ -729,7 +1313,10 @@ fn execute( ); // Execute the entrypoint - let block_context = BlockContext::default(); + // Set up the current block number + let mut block_context = BlockContext::default(); + block_context.block_info_mut().block_number = 30; + let mut tx_execution_context = TransactionExecutionContext::new( Address(0.into()), Felt252::zero(), @@ -755,8 +1342,153 @@ fn execute( .unwrap() } +#[test] +fn library_call() { + // Create program and entry point types for contract class + let contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_slice(include_bytes!( + "../starknet_programs/cairo2/square_root.sierra" + )) + .unwrap(); + + let entrypoints = contract_class.clone().entry_points_by_type; + let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + contract_class_cache.insert( + class_hash, + CompiledClass::Sierra(Arc::new(( + contract_class.extract_sierra_program().unwrap(), + entrypoints.clone(), + ))), + ); + let mut state_reader = InMemoryStateReader::default(); + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Add lib contract to the state + + let lib_program_data = include_bytes!("../starknet_programs/cairo2/math_lib.sierra"); + + let lib_contract_class: ContractClass = serde_json::from_slice(lib_program_data).unwrap(); + + let lib_address = Address(1112.into()); + let lib_class_hash: ClassHash = [2; 32]; + let lib_nonce = Felt252::zero(); + + insert_sierra_class_into_cache( + &mut contract_class_cache, + lib_class_hash, + lib_contract_class, + ); + + state_reader + .address_to_class_hash_mut() + .insert(lib_address.clone(), lib_class_hash); + state_reader + .address_to_nonce_mut() + .insert(lib_address, lib_nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + // Create an execution entry point + let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); + let caller_address = Address(0000.into()); + let entry_point_type = EntryPointType::External; + + let exec_entry_point = ExecutionEntryPoint::new( + address, + calldata.clone(), + Felt252::new(entrypoint_selector.clone()), + caller_address, + entry_point_type, + Some(CallType::Delegate), + Some(class_hash), + 100000, + ); + + // Execute the entrypoint + let block_context = BlockContext::default(); + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + Vec::new(), + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + // expected results + let expected_call_info = CallInfo { + caller_address: Address(0.into()), + call_type: Some(CallType::Delegate), + contract_address: Address(1111.into()), + entry_point_selector: Some(Felt252::new(entrypoint_selector)), + entry_point_type: Some(EntryPointType::External), + calldata, + retdata: [5.into()].to_vec(), + execution_resources: None, + class_hash: Some(class_hash), + internal_calls: vec![CallInfo { + caller_address: Address(0.into()), + call_type: Some(CallType::Delegate), + contract_address: Address(1111.into()), + entry_point_selector: Some( + Felt252::from_str_radix( + "544923964202674311881044083303061611121949089655923191939299897061511784662", + 10, + ) + .unwrap(), + ), + entry_point_type: Some(EntryPointType::External), + calldata: vec![25.into()], + retdata: [5.into()].to_vec(), + execution_resources: None, + class_hash: Some(lib_class_hash), + gas_consumed: 0, + ..Default::default() + }], + code_address: None, + events: vec![], + l2_to_l1_messages: vec![], + storage_read_values: vec![], + accessed_storage_keys: HashSet::new(), + gas_consumed: 78250, + ..Default::default() + }; + + assert_eq_sorted!( + exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps() + ) + .unwrap() + .call_info + .unwrap(), + expected_call_info + ); +} + fn execute_deploy( - state: &mut CachedState, + state: &mut CachedState, caller_address: &Address, selector: &BigUint, calldata: &[Felt252], @@ -843,14 +1575,16 @@ fn deploy_syscall_test() { let deployee_class_hash: ClassHash = Felt252::one().to_be_bytes(); let _deployee_nonce = Felt252::zero(); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, deployer_class_hash, - CompiledClass::Sierra(Arc::new(deployer_contract_class)), + deployer_contract_class, ); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, deployee_class_hash, - CompiledClass::Sierra(Arc::new(deployee_contract_class)), + deployee_contract_class, ); let mut state_reader = InMemoryStateReader::default(); @@ -948,14 +1682,16 @@ fn deploy_syscall_address_unavailable_test() { // Insert contract to be deployed so that its address is taken let deployee_address = expected_deployed_contract_address; - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, deployer_class_hash, - CompiledClass::Sierra(Arc::new(deployer_contract_class)), + deployer_contract_class, ); - contract_class_cache.set_contract_class( + insert_sierra_class_into_cache( + &mut contract_class_cache, deployee_class_hash, - CompiledClass::Sierra(Arc::new(deployee_contract_class)), + deployee_contract_class, ); let mut state_reader = InMemoryStateReader::default(); @@ -999,3 +1735,111 @@ fn deploy_syscall_address_unavailable_test() { assert_eq!(result.failure_flag, true); assert!(result.internal_calls.is_empty()); } + +#[test] +#[cfg(feature = "cairo-native")] +fn get_execution_info_test() { + // Same test as test_get_execution_info in the cairo_1_syscalls.rs but in native + + let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = + serde_json::from_str( + std::fs::read_to_string("starknet_programs/cairo2/get_execution_info.sierra") + .unwrap() + .as_str(), + ) + .unwrap(); + + // Contract entrypoints + let entrypoints = sierra_contract_class.clone().entry_points_by_type; + let selector = &entrypoints.external.get(0).unwrap().selector; + + // Create state reader with class hash data + let mut contract_class_cache = HashMap::new(); + + // Contract data + let address = Address(1111.into()); + let class_hash: ClassHash = [1; 32]; + let nonce = Felt252::zero(); + + insert_sierra_class_into_cache(&mut contract_class_cache, class_hash, sierra_contract_class); + + let mut state_reader = InMemoryStateReader::default(); + + // Insert caller contract info into state reader + state_reader + .address_to_class_hash_mut() + .insert(address.clone(), class_hash); + state_reader + .address_to_nonce_mut() + .insert(address.clone(), nonce); + + // Create state from the state_reader and contract cache. + let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + + let calldata = [].to_vec(); + + // Create the entrypoint + let exec_entry_point = ExecutionEntryPoint::new( + address.clone(), + calldata.to_vec(), + Felt252::new(selector), + Address(0.into()), + EntryPointType::External, + Some(CallType::Delegate), + Some(class_hash), + u128::MAX, + ); + + // Create default BlockContext + let block_context = BlockContext::default(); + + // Create TransactionExecutionContext + let mut tx_execution_context = TransactionExecutionContext::new( + Address(0.into()), + Felt252::zero(), + vec![22.into(), 33.into()], + 0, + 10.into(), + block_context.invoke_tx_max_n_steps(), + TRANSACTION_VERSION.clone(), + ); + let mut resources_manager = ExecutionResourcesManager::default(); + + // Execute the entrypoint + let call_info = exec_entry_point + .execute( + &mut state, + &block_context, + &mut resources_manager, + &mut tx_execution_context, + false, + block_context.invoke_tx_max_n_steps(), + ) + .unwrap() + .call_info + .unwrap(); + + let expected_ret_data = vec![ + block_context.block_info().sequencer_address.0.clone(), + 0.into(), + 0.into(), + address.0.clone(), + ]; + + let expected_gas_consumed = 22980; + + let expected_call_info = CallInfo { + caller_address: Address(0.into()), + call_type: Some(CallType::Delegate), + contract_address: address, + class_hash: Some(class_hash), + entry_point_selector: Some(selector.into()), + entry_point_type: Some(EntryPointType::External), + retdata: expected_ret_data, + execution_resources: None, + gas_consumed: expected_gas_consumed, + ..Default::default() + }; + + assert_eq!(call_info, expected_call_info); +} diff --git a/tests/deploy_account.rs b/tests/deploy_account.rs index f6330312c..c02aae9f6 100644 --- a/tests/deploy_account.rs +++ b/tests/deploy_account.rs @@ -7,7 +7,8 @@ use num_traits::Zero; use starknet_in_rust::{ core::contract_address::compute_deprecated_class_hash, definitions::{ - block_context::StarknetChainId, constants::CONSTRUCTOR_ENTRY_POINT_SELECTOR, + block_context::StarknetChainId, + constants::{CONSTRUCTOR_ENTRY_POINT_SELECTOR, VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR}, transaction_type::TransactionType, }, execution::{CallInfo, CallType, TransactionExecutionInfo}, @@ -56,7 +57,7 @@ fn internal_deploy_account() { let internal_deploy_account = DeployAccount::new( class_hash_bytes, 0, - 0.into(), + 1.into(), Felt252::zero(), vec![], vec![ @@ -87,7 +88,20 @@ fn internal_deploy_account() { assert_eq!( tx_info, TransactionExecutionInfo::new( - None, + Some(CallInfo { + call_type: Some(CallType::Call), + contract_address: Address(contract_address.clone()), + class_hash: Some(class_hash_bytes), + entry_point_selector: Some(VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR.clone()), + entry_point_type: Some(EntryPointType::External), + calldata: vec![class_hash, contract_address_salt], + execution_resources: Some(ExecutionResources { + n_steps: 13, + n_memory_holes: 0, + ..Default::default() + }), + ..Default::default() + }), Some(CallInfo { call_type: Some(CallType::Call), contract_address: Address(contract_address), @@ -100,7 +114,7 @@ fn internal_deploy_account() { None, 0, [ - ("n_steps", 3612), + ("n_steps", 3625), ("pedersen_builtin", 23), ("range_check_builtin", 83), ("l1_gas_usage", 3060) diff --git a/tests/internals.rs b/tests/internals.rs index e54d26240..96b90d306 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -14,8 +14,24 @@ use cairo_vm::{ }; use lazy_static::lazy_static; use num_bigint::BigUint; -use num_traits::{FromPrimitive, Num, One, Zero}; -use pretty_assertions_sorted::assert_eq_sorted; +use num_traits::{Num, One, Zero}; +use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +use starknet_in_rust::core::contract_address::{ + compute_casm_class_hash, compute_sierra_class_hash, +}; +use starknet_in_rust::core::errors::state_errors::StateError; +use starknet_in_rust::definitions::constants::{ + DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS, VALIDATE_ENTRY_POINT_SELECTOR, +}; +use starknet_in_rust::execution::execution_entry_point::ExecutionEntryPoint; +use starknet_in_rust::execution::TransactionExecutionContext; +use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; +use starknet_in_rust::services::api::contract_classes::deprecated_contract_class::ContractClass; +use starknet_in_rust::state::ExecutionResourcesManager; +use starknet_in_rust::transaction::fee::calculate_tx_fee; +use starknet_in_rust::transaction::{DeclareV2, Deploy}; +use starknet_in_rust::CasmContractClass; +use starknet_in_rust::EntryPointType; use starknet_in_rust::{ core::{ contract_address::{compute_casm_class_hash, compute_sierra_class_hash}, @@ -97,7 +113,7 @@ lazy_static! { felt_str!("2542253978940891427830343982984992363331567580652119103860970381451088310289"); // Others. - static ref INITIAL_BALANCE: Felt252 = Felt252::from_u128(100000).unwrap(); + static ref INITIAL_BALANCE: Felt252 = Felt252::from(u128::MAX); static ref GAS_PRICE: u128 = 1; } @@ -207,7 +223,92 @@ fn create_account_tx_test_state() -> Result< Ok((block_context, cached_state)) } -fn expected_state_before_tx() -> CachedState { +fn create_account_tx_test_state_revert_test( +) -> Result<(BlockContext, CachedState), Box> { + let block_context = new_starknet_block_context_for_testing(); + + let test_contract_class_hash = felt_to_hash(&TEST_CLASS_HASH.clone()); + let test_account_contract_class_hash = felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH.clone()); + let test_erc20_class_hash = felt_to_hash(&TEST_ERC20_CONTRACT_CLASS_HASH.clone()); + let class_hash_to_class = HashMap::from([ + ( + test_account_contract_class_hash, + ContractClass::from_path( + "starknet_programs/account_without_validation_and_expensive_constructor.json", + )?, + ), + ( + test_contract_class_hash, + ContractClass::from_path(TEST_CONTRACT_PATH)?, + ), + ( + test_erc20_class_hash, + ContractClass::from_path(ERC20_CONTRACT_PATH)?, + ), + ]); + + let test_contract_address = TEST_CONTRACT_ADDRESS.clone(); + let test_account_contract_address = TEST_ACCOUNT_CONTRACT_ADDRESS.clone(); + let test_erc20_address = block_context + .starknet_os_config() + .fee_token_address() + .clone(); + let address_to_class_hash = HashMap::from([ + (test_contract_address, test_contract_class_hash), + ( + test_account_contract_address, + test_account_contract_class_hash, + ), + (test_erc20_address.clone(), test_erc20_class_hash), + ]); + + let test_erc20_account_balance_key = TEST_ERC20_ACCOUNT_BALANCE_KEY.clone(); + + let storage_view = HashMap::from([( + (test_erc20_address, test_erc20_account_balance_key), + INITIAL_BALANCE.clone(), + )]); + + let cached_state = CachedState::new( + { + let mut state_reader = InMemoryStateReader::default(); + for (contract_address, class_hash) in address_to_class_hash { + let storage_keys: HashMap<(Address, ClassHash), Felt252> = storage_view + .iter() + .filter_map(|((address, storage_key), storage_value)| { + (address == &contract_address).then_some(( + (address.clone(), felt_to_hash(storage_key)), + storage_value.clone(), + )) + }) + .collect(); + + let stored: HashMap = storage_keys; + + state_reader + .address_to_class_hash_mut() + .insert(contract_address.clone(), class_hash); + + state_reader + .address_to_nonce_mut() + .insert(contract_address.clone(), Felt252::zero()); + state_reader.address_to_storage_mut().extend(stored); + } + for (class_hash, contract_class) in class_hash_to_class { + state_reader.class_hash_to_compiled_class_mut().insert( + class_hash, + CompiledClass::Deprecated(Arc::new(contract_class)), + ); + } + Arc::new(state_reader) + }, + HashMap::new(), + ); + + Ok((block_context, cached_state)) +} + +fn expected_state_before_tx() -> CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); CachedState::new( @@ -766,6 +867,7 @@ fn declare_tx() -> Declare { skip_execute: false, skip_fee_transfer: false, skip_validate: false, + skip_nonce_check: false, } } @@ -783,7 +885,7 @@ fn declarev2_tx() -> DeclareV2 { DeclareV2 { sender_address: TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), validate_entry_point_selector: VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(), - version: 1.into(), + version: 2.into(), max_fee: 50000000, signature: vec![], nonce: 0.into(), @@ -795,6 +897,7 @@ fn declarev2_tx() -> DeclareV2 { skip_execute: false, skip_fee_transfer: false, skip_validate: false, + skip_nonce_check: false, } } @@ -1341,7 +1444,7 @@ fn test_invoke_tx_exceeded_max_fee() { Felt252::from(1), // CONTRACT_CALLDATA LEN Felt252::from(2), // CONTRACT_CALLDATA ]; - let max_fee = 3; + let max_fee = 2483; let actual_fee = 2490; let invoke_tx = invoke_tx(calldata, max_fee); @@ -1518,7 +1621,7 @@ fn test_invoke_with_declarev2_tx() { Felt252::from(0), // b Felt252::from(0), // n ]; - let invoke_tx = invoke_tx_with_nonce(calldata, u128::MAX, Felt252::one()); + let invoke_tx = invoke_tx_with_nonce(calldata, u64::MAX as u128, Felt252::one()); let expected_gas_consumed = 5551; let result = invoke_tx @@ -1648,13 +1751,14 @@ fn test_deploy_account() { #[test] fn test_deploy_account_revert() { - let (block_context, mut state) = create_account_tx_test_state().unwrap(); + let (block_context, mut state) = create_account_tx_test_state_revert_test().unwrap(); - let expected_fee = 1; + let actual_fee = 3100; + let max_fee = 3097; let deploy_account_tx = DeployAccount::new( felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH), - 1, + max_fee, TRANSACTION_VERSION.clone(), Default::default(), Default::default(), @@ -1730,14 +1834,14 @@ fn test_deploy_account_revert() { Address(0x1001.into()), felt_to_hash(&TEST_ERC20_DEPLOYED_ACCOUNT_BALANCE_KEY), ), - INITIAL_BALANCE.clone() - Felt252::one(), // minus the max fee that will be transfered + INITIAL_BALANCE.clone() - max_fee as u32, // minus the max fee that will be transfered ); state_reverted.cache_mut().storage_writes_mut().insert( ( Address(0x1001.into()), felt_to_hash(&TEST_ERC20_SEQUENCER_BALANCE_KEY), ), - Felt252::one(), // the max fee received by the sequencer + max_fee.into(), // the max fee received by the sequencer ); // Set nonce @@ -1751,11 +1855,11 @@ fn test_deploy_account_revert() { let expected_fee_transfer_call_info = expected_fee_transfer_call_info( &block_context, deploy_account_tx.contract_address(), - expected_fee, + max_fee, ); let resources = HashMap::from([ - ("n_steps".to_string(), 3625), + ("n_steps".to_string(), 3914), ("range_check_builtin".to_string(), 83), ("pedersen_builtin".to_string(), 23), ("l1_gas_usage".to_string(), 3060), @@ -1763,22 +1867,22 @@ fn test_deploy_account_revert() { let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap(); - assert_eq!(fee, 3097); + assert_eq!(fee, actual_fee); let mut expected_execution_info = TransactionExecutionInfo::new( None, None, None, None, - expected_fee, + max_fee, // Entry **not** in blockifier. // Default::default(), resources, TransactionType::DeployAccount.into(), ) - .to_revert_error(format!("Calculated fee ({}) exceeds max fee ({})", fee, 1).as_str()); + .to_revert_error(format!("Calculated fee ({}) exceeds max fee ({})", fee, max_fee).as_str()); - expected_execution_info.set_fee_info(expected_fee, expected_fee_transfer_call_info.into()); + expected_execution_info.set_fee_info(max_fee, expected_fee_transfer_call_info.into()); assert_eq_sorted!(tx_info, expected_execution_info); @@ -1789,7 +1893,7 @@ fn test_deploy_account_revert() { let hash = TEST_ERC20_DEPLOYED_ACCOUNT_BALANCE_KEY.to_be_bytes(); - validate_final_balances(&mut state, &block_context, &hash, expected_fee); + validate_final_balances(&mut state, &block_context, &hash, max_fee); let class_hash_from_state = state .get_class_hash_at(deploy_account_tx.contract_address()) @@ -2174,7 +2278,7 @@ fn test_invoke_tx_wrong_entrypoint() { TEST_ACCOUNT_CONTRACT_ADDRESS.clone(), // Entrypoiont that doesnt exits in the contract Felt252::from_bytes_be(&calculate_sn_keccak(b"none_function")), - 1, + 2483, TRANSACTION_VERSION.clone(), vec![ test_contract_address, // CONTRACT_ADDRESS @@ -2203,7 +2307,7 @@ fn test_deploy_undeclared_account() { // Deploy transaction with a not_deployed_class_hash class_hash let deploy_account_tx = DeployAccount::new( not_deployed_class_hash, - 2, + 0, TRANSACTION_VERSION.clone(), Default::default(), Default::default(), From 498c4a6d23194e0fb74191b99bf3421c6f347eb6 Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 14 Nov 2023 13:16:11 -0300 Subject: [PATCH 50/56] Fix code --- bench/native_bench.rs | 43 +- examples/contract_execution/src/main.rs | 10 +- src/execution/execution_entry_point.rs | 13 +- src/syscalls/native_syscall_handler.rs | 19 +- src/transaction/declare.rs | 9 +- src/transaction/declare_v2.rs | 4 +- src/transaction/deploy_account.rs | 9 +- src/transaction/invoke_function.rs | 6 +- tests/account_panic.rs | 2 +- tests/cairo_1_syscalls.rs | 535 +----------------------- tests/cairo_native.rs | 101 ++--- tests/internals.rs | 46 +- 12 files changed, 139 insertions(+), 658 deletions(-) diff --git a/bench/native_bench.rs b/bench/native_bench.rs index d01e4a936..e923c50df 100644 --- a/bench/native_bench.rs +++ b/bench/native_bench.rs @@ -23,6 +23,8 @@ use num_traits::Zero; use starknet_in_rust::definitions::block_context::BlockContext; use starknet_in_rust::definitions::block_context::StarknetChainId; use starknet_in_rust::services::api::contract_classes::compiled_class::CompiledClass; +use starknet_in_rust::state::contract_class_cache::ContractClassCache; +use starknet_in_rust::state::contract_class_cache::PermanentContractClassCache; use starknet_in_rust::state::state_api::State; use starknet_in_rust::transaction::DeployAccount; use starknet_in_rust::utils::calculate_sn_keccak; @@ -68,7 +70,7 @@ pub fn main() { fn bench_fibo(executions: usize, native: bool) { // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); static CASM_CLASS_HASH: ClassHash = [2; 32]; let (contract_class, constructor_selector) = match native { @@ -102,7 +104,7 @@ fn bench_fibo(executions: usize, native: bool) { let caller_address = Address(123456789.into()); - contract_class_cache.insert(CASM_CLASS_HASH, contract_class); + contract_class_cache.set_contract_class(CASM_CLASS_HASH, contract_class); let mut state_reader = InMemoryStateReader::default(); let nonce = Felt252::zero(); @@ -115,7 +117,7 @@ fn bench_fibo(executions: usize, native: bool) { // Create state from the state_reader and contract cache. let state_reader = Arc::new(state_reader); - let state = CachedState::new(state_reader, contract_class_cache); + let state = CachedState::new(state_reader, Arc::new(contract_class_cache)); /* f0, f1, N */ let mut calldata = [1.into(), 1.into(), 2000000.into()]; @@ -126,7 +128,7 @@ fn bench_fibo(executions: usize, native: bool) { for _ in 0..executions { calldata[2] = &calldata[2] + 1usize; let result = execute( - &mut state.clone(), + &mut state.clone_for_testing(), &caller_address, &caller_address, &Felt252::new(constructor_selector.clone()), @@ -142,7 +144,7 @@ fn bench_fibo(executions: usize, native: bool) { fn bench_fact(executions: usize, native: bool) { // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); static CASM_CLASS_HASH: ClassHash = [2; 32]; let (contract_class, constructor_selector) = match native { @@ -178,7 +180,7 @@ fn bench_fact(executions: usize, native: bool) { // FACT 1M // FIBO 2M - contract_class_cache.insert(CASM_CLASS_HASH, contract_class); + contract_class_cache.set_contract_class(CASM_CLASS_HASH, contract_class); let mut state_reader = InMemoryStateReader::default(); let nonce = Felt252::zero(); @@ -191,7 +193,7 @@ fn bench_fact(executions: usize, native: bool) { // Create state from the state_reader and contract cache. let state_reader = Arc::new(state_reader); - let state = CachedState::new(state_reader, contract_class_cache); + let state = CachedState::new(state_reader, Arc::new(contract_class_cache)); /* N */ let mut calldata = [2000000.into()]; @@ -202,7 +204,7 @@ fn bench_fact(executions: usize, native: bool) { for _ in 0..executions { calldata[0] = &calldata[0] + 1usize; let result = execute( - &mut state.clone(), + &mut state.clone_for_testing(), &caller_address, &caller_address, &Felt252::new(constructor_selector.clone()), @@ -219,7 +221,7 @@ fn bench_fact(executions: usize, native: bool) { fn bench_erc20(executions: usize, native: bool) { // 1. setup ERC20 contract and state. // Create state reader and preload the contract classes. - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); lazy_static! { static ref ERC20_CLASS_HASH: ClassHash = felt_str!("2").to_be_bytes(); @@ -244,7 +246,10 @@ fn bench_erc20(executions: usize, native: bool) { static ref ERC20_DEPLOYMENT_CALLER_ADDRESS: Address = Address(0000.into()); } - let (erc20_address, mut state): (Address, CachedState) = match native { + let (erc20_address, mut state): ( + Address, + CachedState, + ) = match native { true => { let erc20_sierra_class = include_bytes!("../starknet_programs/cairo2/erc20.sierra"); let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = @@ -264,11 +269,11 @@ fn bench_erc20(executions: usize, native: bool) { let deploy_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // insert deployer and erc20 classes into the cache. - contract_class_cache.insert( + contract_class_cache.set_contract_class( *DEPLOYER_CLASS_HASH, CompiledClass::Casm(Arc::new(erc20_deployer_class)), ); - contract_class_cache.insert(*ERC20_CLASS_HASH, erc20_contract_class); + contract_class_cache.set_contract_class(*ERC20_CLASS_HASH, erc20_contract_class); let mut state_reader = InMemoryStateReader::default(); // setup deployer nonce and address into the state reader @@ -280,7 +285,8 @@ fn bench_erc20(executions: usize, native: bool) { .insert(DEPLOYER_ADDRESS.clone(), Felt252::zero()); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = + CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // deploy the erc20 contract by calling the deployer contract. @@ -342,11 +348,11 @@ fn bench_erc20(executions: usize, native: bool) { let deploy_entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // insert deployer and erc20 classes into the cache. - contract_class_cache.insert( + contract_class_cache.set_contract_class( *DEPLOYER_CLASS_HASH, CompiledClass::Casm(Arc::new(erc20_deployer_class)), ); - contract_class_cache.insert(*ERC20_CLASS_HASH, erc20_contract_class); + contract_class_cache.set_contract_class(*ERC20_CLASS_HASH, erc20_contract_class); let mut state_reader = InMemoryStateReader::default(); // setup deployer nonce and address into the state reader @@ -358,7 +364,8 @@ fn bench_erc20(executions: usize, native: bool) { .insert(DEPLOYER_ADDRESS.clone(), Felt252::zero()); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = + CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // deploy the erc20 contract by calling the deployer contract. @@ -499,7 +506,7 @@ fn bench_erc20(executions: usize, native: bool) { for _ in 0..executions { let result = execute( - &mut state.clone(), + &mut state.clone_for_testing(), &account1_address, &erc20_address, &transfer_entrypoint_selector.clone(), @@ -516,7 +523,7 @@ fn bench_erc20(executions: usize, native: bool) { #[inline(never)] #[allow(clippy::too_many_arguments)] fn execute( - state: &mut CachedState, + state: &mut CachedState, caller_address: &Address, callee_address: &Address, selector: &Felt252, diff --git a/examples/contract_execution/src/main.rs b/examples/contract_execution/src/main.rs index d41a1b097..7f8911553 100644 --- a/examples/contract_execution/src/main.rs +++ b/examples/contract_execution/src/main.rs @@ -17,13 +17,14 @@ use starknet_in_rust::{ compiled_class::CompiledClass, deprecated_contract_class::ContractClass, }, state::{ - cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, state_api::State, + cached_state::CachedState, contract_class_cache::PermanentContractClassCache, + in_memory_state_reader::InMemoryStateReader, state_api::State, }, transaction::{DeclareV2, DeployAccount, InvokeFunction}, utils::{calculate_sn_keccak, felt_to_hash, Address}, CasmContractClass, SierraContractClass, }; -use std::{collections::HashMap, fs::File, io::BufReader, path::Path, str::FromStr, sync::Arc}; +use std::{fs::File, io::BufReader, path::Path, str::FromStr, sync::Arc}; fn main() { // replace this with the path to your compiled contract @@ -67,7 +68,10 @@ fn test_contract( //* Initialize state //* -------------------------------------------- let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new(state_reader, HashMap::new()); + let mut state = CachedState::new( + state_reader, + Arc::new(PermanentContractClassCache::default()), + ); //* -------------------------------------------- //* Deploy deployer contract diff --git a/src/execution/execution_entry_point.rs b/src/execution/execution_entry_point.rs index 07641ee85..5a6bcd94d 100644 --- a/src/execution/execution_entry_point.rs +++ b/src/execution/execution_entry_point.rs @@ -52,10 +52,12 @@ use std::sync::Arc; use { crate::syscalls::native_syscall_handler::NativeSyscallHandler, cairo_native::{ - context::NativeContext, execution_result::NativeExecutionResult, executor::NativeExecutor, + context::NativeContext, execution_result::NativeExecutionResult, metadata::syscall_handler::SyscallHandlerMeta, utils::felt252_bigint, }, + core::cell::RefCell, serde_json::Value, + std::rc::Rc, }; #[derive(Debug, Default)] @@ -179,7 +181,7 @@ impl ExecutionEntryPoint { } #[cfg(feature = "cairo-native")] CompiledClass::Sierra(sierra_program_and_entrypoints) => { - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; let native_context = NativeContext::new(); let program_cache = Rc::new(RefCell::new(ProgramCache::new(&native_context))); @@ -226,9 +228,9 @@ impl ExecutionEntryPoint { } #[cfg(feature = "cairo-native")] - pub fn execute_with_native_cache( + pub fn execute_with_native_cache( &self, - state: &mut CachedState, + state: &mut CachedState, block_context: &BlockContext, resources_manager: &mut ExecutionResourcesManager, tx_execution_context: &mut TransactionExecutionContext, @@ -238,6 +240,7 @@ impl ExecutionEntryPoint { ) -> Result where T: StateReader, + C: ContractClassCache, { // lookup the compiled class from the state. let class_hash = self.get_code_class_hash(state)?; @@ -291,7 +294,7 @@ impl ExecutionEntryPoint { } } CompiledClass::Sierra(sierra_contract_class) => { - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; match self.native_execute( &mut transactional_state, diff --git a/src/syscalls/native_syscall_handler.rs b/src/syscalls/native_syscall_handler.rs index 275b9694f..6715ccb85 100644 --- a/src/syscalls/native_syscall_handler.rs +++ b/src/syscalls/native_syscall_handler.rs @@ -1,3 +1,4 @@ +use crate::ContractClassCache; use std::{cell::RefCell, rc::Rc}; use cairo_native::{ @@ -36,11 +37,12 @@ use crate::{ }; #[derive(Debug)] -pub struct NativeSyscallHandler<'a, 'cache, S> +pub struct NativeSyscallHandler<'a, 'cache, S, C> where S: StateReader, + C: ContractClassCache, { - pub(crate) starknet_storage_state: ContractStorageState<'a, S>, + pub(crate) starknet_storage_state: ContractStorageState<'a, S, C>, pub(crate) contract_address: Address, pub(crate) caller_address: Address, pub(crate) entry_point_selector: Felt252, @@ -53,7 +55,7 @@ where pub(crate) program_cache: Rc>>, } -impl<'a, 'cache, S: StateReader> NativeSyscallHandler<'a, 'cache, S> { +impl<'a, 'cache, S: StateReader, C: ContractClassCache> NativeSyscallHandler<'a, 'cache, S, C> { /// Generic code that needs to be run on all syscalls. fn handle_syscall_request(&mut self, gas: &mut u128, syscall_name: &str) -> SyscallResult<()> { let required_gas = SYSCALL_GAS_COST @@ -76,7 +78,9 @@ impl<'a, 'cache, S: StateReader> NativeSyscallHandler<'a, 'cache, S> { } } -impl<'a, 'cache, S: StateReader> StarkNetSyscallHandler for NativeSyscallHandler<'a, 'cache, S> { +impl<'a, 'cache, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler + for NativeSyscallHandler<'a, 'cache, S, C> +{ fn get_block_hash( &mut self, block_number: u64, @@ -594,9 +598,10 @@ impl<'a, 'cache, S: StateReader> StarkNetSyscallHandler for NativeSyscallHandler } } -impl<'a, 'cache, S> NativeSyscallHandler<'a, 'cache, S> +impl<'a, 'cache, S, C> NativeSyscallHandler<'a, 'cache, S, C> where S: StateReader, + C: ContractClassCache, { fn execute_constructor_entry_point( &mut self, @@ -621,7 +626,7 @@ where if self.constructor_entry_points_empty(compiled_class)? { if !constructor_calldata.is_empty() { - return Err(StateError::ConstructorCalldataEmpty()); + return Err(StateError::ConstructorCalldataEmpty); } let call_info = CallInfo::empty_constructor_call( @@ -654,7 +659,7 @@ where false, u64::MAX, ) - .map_err(|_| StateError::ExecutionEntryPoint())?; + .map_err(|_| StateError::ExecutionEntryPoint)?; let call_info = call_info.ok_or(StateError::CustomError("Execution error".to_string()))?; diff --git a/src/transaction/declare.rs b/src/transaction/declare.rs index e5dd10323..bdf66592d 100644 --- a/src/transaction/declare.rs +++ b/src/transaction/declare.rs @@ -922,11 +922,10 @@ mod tests { Felt252::zero(), ) .unwrap(); - let result = internal_declare - .execute::>( - &mut CachedState::default(), - &BlockContext::default(), - ); + let result = internal_declare.execute( + &mut CachedState::::default(), + &BlockContext::default(), + ); assert_matches!( result, diff --git a/src/transaction/declare_v2.rs b/src/transaction/declare_v2.rs index 4d9389015..24d6338bd 100644 --- a/src/transaction/declare_v2.rs +++ b/src/transaction/declare_v2.rs @@ -940,8 +940,8 @@ mod tests { Felt252::zero(), ) .unwrap(); - let result = internal_declare.execute::>( - &mut CachedState::default(), + let result = internal_declare.execute( + &mut CachedState::::default(), &BlockContext::default(), ); diff --git a/src/transaction/deploy_account.rs b/src/transaction/deploy_account.rs index a074744a5..28b2ad5cd 100644 --- a/src/transaction/deploy_account.rs +++ b/src/transaction/deploy_account.rs @@ -744,11 +744,10 @@ mod tests { chain_id, ) .unwrap(); - let result = internal_declare - .execute::>( - &mut CachedState::default(), - &BlockContext::default(), - ); + let result = internal_declare.execute( + &mut CachedState::::default(), + &BlockContext::default(), + ); assert_matches!( result, diff --git a/src/transaction/invoke_function.rs b/src/transaction/invoke_function.rs index f8f828921..d2cff2190 100644 --- a/src/transaction/invoke_function.rs +++ b/src/transaction/invoke_function.rs @@ -345,7 +345,7 @@ impl InvokeFunction { self.handle_nonce(state)?; - let mut transactional_state = state.create_transactional(); + let mut transactional_state = state.create_transactional()?; let mut tx_exec_info = self.apply(&mut transactional_state, block_context, remaining_gas)?; @@ -1493,8 +1493,8 @@ mod tests { Some(Felt252::zero()), ) .unwrap(); - let result = internal_declare.execute::>( - &mut CachedState::default(), + let result = internal_declare.execute( + &mut CachedState::::default(), &BlockContext::default(), u128::MAX, ); diff --git a/tests/account_panic.rs b/tests/account_panic.rs index 0de6d50f1..195b21d9f 100644 --- a/tests/account_panic.rs +++ b/tests/account_panic.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, sync::Arc}; +use std::sync::Arc; use cairo_vm::felt::Felt252; use starknet_in_rust::{ diff --git a/tests/cairo_1_syscalls.rs b/tests/cairo_1_syscalls.rs index 4a8db67ab..1d931060c 100644 --- a/tests/cairo_1_syscalls.rs +++ b/tests/cairo_1_syscalls.rs @@ -6,6 +6,7 @@ use cairo_vm::{ use num_bigint::BigUint; use num_traits::{Num, One, Zero}; use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; +use starknet_in_rust::utils::calculate_sn_keccak; use starknet_in_rust::{ definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, execution::{ @@ -25,7 +26,6 @@ use starknet_in_rust::{ utils::{Address, ClassHash}, EntryPointType, }; -use starknet_in_rust::{utils::calculate_sn_keccak, EntryPointType}; use std::{ collections::{HashMap, HashSet}, sync::Arc, @@ -3074,539 +3074,6 @@ fn keccak_syscall() { assert_eq!(call_info.gas_consumed, 545370); } -#[test] -fn library_call_recursive_50_calls() { - // Create program and entry point types for contract class - #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/square_root_recursive.casm"); - #[cfg(feature = "cairo_1_tests")] - let program_data = include_bytes!("../starknet_programs/cairo1/square_root_recursive.casm"); - - let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let entrypoints = contract_class.clone().entry_points_by_type; - let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; - - // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); - - let address = Address(1111.into()); - let class_hash: ClassHash = [1; 32]; - let nonce = Felt252::zero(); - - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(address.clone(), nonce); - - // Add lib contract to the state - - #[cfg(not(feature = "cairo_1_tests"))] - let lib_program_data = include_bytes!("../starknet_programs/cairo2/math_lib.casm"); - #[cfg(feature = "cairo_1_tests")] - let lib_program_data = include_bytes!("../starknet_programs/cairo1/math_lib.casm"); - - let lib_contract_class: CasmContractClass = serde_json::from_slice(lib_program_data).unwrap(); - - let lib_address = Address(1112.into()); - let lib_class_hash: ClassHash = [2; 32]; - let lib_nonce = Felt252::zero(); - - contract_class_cache.insert( - lib_class_hash, - CompiledClass::Casm(Arc::new(lib_contract_class)), - ); - state_reader - .address_to_class_hash_mut() - .insert(lib_address.clone(), lib_class_hash); - state_reader - .address_to_nonce_mut() - .insert(lib_address, lib_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); - - // Create an execution entry point - let calldata = [ - felt_str!("1125899906842624"), - Felt252::from_bytes_be(&lib_class_hash), - Felt252::from(50), - ] - .to_vec(); - let caller_address = Address(0000.into()); - let entry_point_type = EntryPointType::External; - - let exec_entry_point = ExecutionEntryPoint::new( - address, - calldata, - Felt252::new(entrypoint_selector.clone()), - caller_address, - entry_point_type, - Some(CallType::Delegate), - Some(class_hash), - u128::MAX, - ); - - // Execute the entrypoint - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - let mut resources_manager = ExecutionResourcesManager::default(); - let expected_execution_resources_internal_call = ExecutionResources { - #[cfg(not(feature = "cairo_1_tests"))] - n_steps: 80, - #[cfg(feature = "cairo_1_tests")] - n_steps: 85, - n_memory_holes: 5, - builtin_instance_counter: HashMap::from([(RANGE_CHECK_BUILTIN_NAME.to_string(), 7)]), - }; - - let call_info = exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap(); - - assert_eq!(call_info.internal_calls.len(), 50); - assert_eq!( - call_info.internal_calls[0], - CallInfo { - caller_address: Address(0.into()), - call_type: Some(CallType::Delegate), - contract_address: Address(1111.into()), - entry_point_selector: Some( - Felt252::from_str_radix( - "544923964202674311881044083303061611121949089655923191939299897061511784662", - 10, - ) - .unwrap(), - ), - entry_point_type: Some(EntryPointType::External), - calldata: vec![felt_str!("1125899906842624")], - retdata: [felt_str!("33554432")].to_vec(), - execution_resources: Some(expected_execution_resources_internal_call), - class_hash: Some(lib_class_hash), - gas_consumed: 0, - ..Default::default() - } - ); - assert_eq!(call_info.retdata, [1.into()].to_vec()); - assert!(!call_info.failure_flag); -} - -#[test] -fn call_contract_storage_write_read_recursive_50_calls() { - // Create program and entry point types for contract class - #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); - #[cfg(feature = "cairo_1_tests")] - let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); - - let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let get_balance_entrypoint_selector = - &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); - let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( - "increase_balance_recursive".as_bytes(), - )); - - // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); - - let address = Address(1111.into()); - let class_hash: ClassHash = [1; 32]; - let nonce = Felt252::zero(); - - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(address.clone(), nonce); - - // Add simple_wallet contract to the state - #[cfg(not(feature = "cairo_1_tests"))] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); - #[cfg(feature = "cairo_1_tests")] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); - - let simple_wallet_contract_class: CasmContractClass = - serde_json::from_slice(simple_wallet_program_data).unwrap(); - let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class - .entry_points_by_type - .constructor - .get(0) - .unwrap() - .selector - .clone(); - - let simple_wallet_address = Address(1112.into()); - let simple_wallet_class_hash: ClassHash = [2; 32]; - let simple_wallet_nonce = Felt252::zero(); - - contract_class_cache.insert( - simple_wallet_class_hash, - CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), - ); - state_reader - .address_to_class_hash_mut() - .insert(simple_wallet_address.clone(), simple_wallet_class_hash); - state_reader - .address_to_nonce_mut() - .insert(simple_wallet_address.clone(), simple_wallet_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); - - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - - let mut resources_manager = ExecutionResourcesManager::default(); - - let create_execute_extrypoint = |selector: &BigUint, - calldata: Vec, - entry_point_type: EntryPointType, - class_hash: [u8; 32], - address: Address| - -> ExecutionEntryPoint { - ExecutionEntryPoint::new( - address, - calldata, - Felt252::new(selector.clone()), - Address(0000.into()), - entry_point_type, - Some(CallType::Delegate), - Some(class_hash), - u64::MAX.into(), - ) - }; - - // RUN SIMPLE_WALLET CONSTRUCTOR - // Create an execution entry point - let calldata = [25.into()].to_vec(); - let constructor_exec_entry_point = create_execute_extrypoint( - &simple_wallet_constructor_entrypoint_selector, - calldata, - EntryPointType::Constructor, - simple_wallet_class_hash, - simple_wallet_address.clone(), - ); - - // Run constructor entrypoint - constructor_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0.clone()].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); - - // RUN INCREASE_BALANCE - // Create an execution entry point - let calldata = [50.into(), simple_wallet_address.0.clone()].to_vec(); - let increase_balance_entry_point = create_execute_extrypoint( - increase_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run increase_balance entrypoint - let call_info = increase_balance_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap(); - // Check that the recursive function did in fact call the simple_wallet contract 50 times - assert_eq!(call_info.internal_calls.len(), 50); - assert!(!call_info.failure_flag); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address, - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [75.into()]) -} - -#[test] -fn call_contract_storage_write_read_recursive_100_calls() { - // Create program and entry point types for contract class - #[cfg(not(feature = "cairo_1_tests"))] - let program_data = include_bytes!("../starknet_programs/cairo2/wallet_wrapper.casm"); - #[cfg(feature = "cairo_1_tests")] - let program_data = include_bytes!("../starknet_programs/cairo1/wallet_wrapper.casm"); - - let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap(); - let get_balance_entrypoint_selector = - &BigUint::from_bytes_be(&calculate_sn_keccak("get_balance".as_bytes())); - let increase_balance_entrypoint_selector = &BigUint::from_bytes_be(&calculate_sn_keccak( - "increase_balance_recursive".as_bytes(), - )); - - // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); - - let address = Address(1111.into()); - let class_hash: ClassHash = [1; 32]; - let nonce = Felt252::zero(); - - contract_class_cache.insert(class_hash, CompiledClass::Casm(Arc::new(contract_class))); - let mut state_reader = InMemoryStateReader::default(); - state_reader - .address_to_class_hash_mut() - .insert(address.clone(), class_hash); - state_reader - .address_to_nonce_mut() - .insert(address.clone(), nonce); - - // Add simple_wallet contract to the state - #[cfg(not(feature = "cairo_1_tests"))] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo2/simple_wallet.casm"); - #[cfg(feature = "cairo_1_tests")] - let simple_wallet_program_data = - include_bytes!("../starknet_programs/cairo1/simple_wallet.casm"); - - let simple_wallet_contract_class: CasmContractClass = - serde_json::from_slice(simple_wallet_program_data).unwrap(); - let simple_wallet_constructor_entrypoint_selector = simple_wallet_contract_class - .entry_points_by_type - .constructor - .get(0) - .unwrap() - .selector - .clone(); - - let simple_wallet_address = Address(1112.into()); - let simple_wallet_class_hash: ClassHash = [2; 32]; - let simple_wallet_nonce = Felt252::zero(); - - contract_class_cache.insert( - simple_wallet_class_hash, - CompiledClass::Casm(Arc::new(simple_wallet_contract_class)), - ); - state_reader - .address_to_class_hash_mut() - .insert(simple_wallet_address.clone(), simple_wallet_class_hash); - state_reader - .address_to_nonce_mut() - .insert(simple_wallet_address.clone(), simple_wallet_nonce); - - // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); - - let block_context = BlockContext::default(); - let mut tx_execution_context = TransactionExecutionContext::new( - Address(0.into()), - Felt252::zero(), - Vec::new(), - 0, - 10.into(), - block_context.invoke_tx_max_n_steps(), - TRANSACTION_VERSION.clone(), - ); - - let mut resources_manager = ExecutionResourcesManager::default(); - - let create_execute_extrypoint = |selector: &BigUint, - calldata: Vec, - entry_point_type: EntryPointType, - class_hash: [u8; 32], - address: Address| - -> ExecutionEntryPoint { - ExecutionEntryPoint::new( - address, - calldata, - Felt252::new(selector.clone()), - Address(0000.into()), - entry_point_type, - Some(CallType::Delegate), - Some(class_hash), - u64::MAX.into(), - ) - }; - - // RUN SIMPLE_WALLET CONSTRUCTOR - // Create an execution entry point - let calldata = [25.into()].to_vec(); - let constructor_exec_entry_point = create_execute_extrypoint( - &simple_wallet_constructor_entrypoint_selector, - calldata, - EntryPointType::Constructor, - simple_wallet_class_hash, - simple_wallet_address.clone(), - ); - - // Run constructor entrypoint - constructor_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0.clone()].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [25.into()]); - - // RUN INCREASE_BALANCE - // Create an execution entry point - let calldata = [100.into(), simple_wallet_address.0.clone()].to_vec(); - let increase_balance_entry_point = create_execute_extrypoint( - increase_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address.clone(), - ); - - // Run increase_balance entrypoint - let call_info = increase_balance_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap() - .call_info - .unwrap(); - // Check that the recursive function did in fact call the simple_wallet contract 50 times - assert_eq!(call_info.internal_calls.len(), 100); - assert!(!call_info.failure_flag); - - // RUN GET_BALANCE - // Create an execution entry point - let calldata = [simple_wallet_address.0].to_vec(); - let get_balance_exec_entry_point = create_execute_extrypoint( - get_balance_entrypoint_selector, - calldata, - EntryPointType::External, - class_hash, - address, - ); - - // Run get_balance entrypoint - let call_info = get_balance_exec_entry_point - .execute( - &mut state, - &block_context, - &mut resources_manager, - &mut tx_execution_context, - false, - block_context.invoke_tx_max_n_steps(), - ) - .unwrap(); - assert_eq!(call_info.call_info.unwrap().retdata, [125.into()]) -} - #[test] fn library_call_recursive_50_calls() { // Create program and entry point types for contract class diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs index 870eba9f2..4a3b5586e 100644 --- a/tests/cairo_native.rs +++ b/tests/cairo_native.rs @@ -33,13 +33,13 @@ use std::collections::HashSet; use std::sync::Arc; fn insert_sierra_class_into_cache( - contract_class_cache: &mut HashMap, + contract_class_cache: &PermanentContractClassCache, class_hash: ClassHash, sierra_class: ContractClass, ) { let sierra_program = sierra_class.extract_sierra_program().unwrap(); let entry_points = sierra_class.entry_points_by_type; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Sierra(Arc::new((sierra_program, entry_points))), ); @@ -48,7 +48,9 @@ fn insert_sierra_class_into_cache( #[test] #[cfg(feature = "cairo-native")] fn get_block_hash_test() { - use starknet_in_rust::utils::felt_to_hash; + use starknet_in_rust::{ + state::contract_class_cache::PermanentContractClassCache, utils::felt_to_hash, + }; let sierra_contract_class: cairo_lang_starknet::contract_class::ContractClass = serde_json::from_str( @@ -68,19 +70,19 @@ fn get_block_hash_test() { let casm_external_selector = &casm_entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let native_class_hash: ClassHash = [1; 32]; let casm_class_hash: ClassHash = [2; 32]; let caller_address = Address(1.into()); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, native_class_hash, sierra_contract_class, ); - contract_class_cache.insert( + contract_class_cache.set_contract_class( casm_class_hash, CompiledClass::Casm(Arc::new(casm_contract_class)), ); @@ -97,13 +99,14 @@ fn get_block_hash_test() { // Create state from the state_reader and contract cache. let state_reader = Arc::new(state_reader); - let mut state_vm = CachedState::new(state_reader.clone(), contract_class_cache.clone()); + let mut state_vm = + CachedState::new(state_reader.clone(), Arc::new(contract_class_cache.clone())); state_vm.cache_mut().storage_initial_values_mut().insert( (Address(1.into()), felt_to_hash(&Felt252::from(10))), Felt252::from_bytes_be(StarkHash::new([5; 32]).unwrap().bytes()), ); - let mut state_native = CachedState::new(state_reader, contract_class_cache); + let mut state_native = CachedState::new(state_reader, Arc::new(contract_class_cache)); state_native .cache_mut() .storage_initial_values_mut() @@ -214,11 +217,11 @@ fn integration_test_erc20() { let caller_address = Address(123456789.into()); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, NATIVE_CLASS_HASH, sierra_contract_class, ); - contract_class_cache.insert( + contract_class_cache.set_contract_class( CASM_CLASS_HASH, CompiledClass::Casm(Arc::new(casm_contract_class)), ); @@ -612,13 +615,13 @@ fn call_contract_test() { let callee_nonce = Felt252::zero(); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, caller_class_hash, caller_contract_class, ); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, callee_class_hash, callee_contract_class, ); @@ -700,13 +703,13 @@ fn call_echo_contract_test() { let callee_nonce = Felt252::zero(); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, caller_class_hash, caller_contract_class, ); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, callee_class_hash, callee_contract_class, ); @@ -790,13 +793,13 @@ fn call_events_contract_test() { let callee_nonce = Felt252::zero(); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, caller_class_hash, caller_contract_class, ); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, callee_class_hash, callee_contract_class, ); @@ -894,7 +897,7 @@ fn replace_class_test() { let casm_replace_selector = &casm_entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let casm_address = Address(2222.into()); @@ -906,7 +909,7 @@ fn replace_class_test() { insert_sierra_class_into_cache(&mut contract_class_cache, CLASS_HASH_A, contract_class_a); - contract_class_cache.insert( + contract_class_cache.set_contract_class( CASM_CLASS_HASH_A, CompiledClass::Casm(Arc::new(casm_contract_class)), ); @@ -936,19 +939,22 @@ fn replace_class_test() { static CASM_CLASS_HASH_B: ClassHash = [4; 32]; insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, CLASS_HASH_B, contract_class_b.clone(), ); - contract_class_cache.insert( + contract_class_cache.set_contract_class( CASM_CLASS_HASH_B, CompiledClass::Casm(Arc::new(casm_contract_class_b.clone())), ); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader.clone()), contract_class_cache.clone()); - let mut vm_state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader.clone()), + Arc::new(contract_class_cache.clone()), + ); + let mut vm_state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Run upgrade entrypoint and check that the storage was updated with the new contract class // Create an execution entry point @@ -1060,14 +1066,14 @@ fn replace_class_contract_call() { .unwrap(); // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); - let mut native_contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); + let mut native_contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); let class_hash_a: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_a, CompiledClass::Casm(Arc::new(casm_contract_class_a)), ); @@ -1105,7 +1111,7 @@ fn replace_class_contract_call() { .unwrap(); let class_hash_b: ClassHash = [2; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash_b, CompiledClass::Casm(Arc::new(contract_class_b)), ); @@ -1141,7 +1147,7 @@ fn replace_class_contract_call() { let wrapper_address = Address(Felt252::from(2)); let wrapper_class_hash: ClassHash = [3; 32]; - contract_class_cache.insert( + contract_class_cache.set_contract_class( wrapper_class_hash, CompiledClass::Casm(Arc::new(wrapper_contract_class)), ); @@ -1163,8 +1169,11 @@ fn replace_class_contract_call() { .insert(wrapper_address, wrapper_class_hash); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader.clone()), contract_class_cache.clone()); - let mut native_state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new( + Arc::new(state_reader.clone()), + Arc::new(contract_class_cache.clone()), + ); + let mut native_state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // CALL GET_NUMBER BEFORE REPLACE_CLASS let calldata = [].to_vec(); @@ -1259,10 +1268,10 @@ fn keccak_syscall_test() { let native_class_hash: ClassHash = [1; 32]; let caller_address = Address(123456789.into()); - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, native_class_hash, sierra_contract_class, ); @@ -1275,7 +1284,7 @@ fn keccak_syscall_test() { .insert(caller_address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let native_result = execute( &mut state, @@ -1293,7 +1302,7 @@ fn keccak_syscall_test() { #[allow(clippy::too_many_arguments)] fn execute( - state: &mut CachedState, + state: &mut CachedState, caller_address: &Address, callee_address: &Address, selector: &BigUint, @@ -1355,13 +1364,13 @@ fn library_call() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; let nonce = Felt252::zero(); - contract_class_cache.insert( + contract_class_cache.set_contract_class( class_hash, CompiledClass::Sierra(Arc::new(( contract_class.extract_sierra_program().unwrap(), @@ -1386,11 +1395,7 @@ fn library_call() { let lib_class_hash: ClassHash = [2; 32]; let lib_nonce = Felt252::zero(); - insert_sierra_class_into_cache( - &mut contract_class_cache, - lib_class_hash, - lib_contract_class, - ); + insert_sierra_class_into_cache(&contract_class_cache, lib_class_hash, lib_contract_class); state_reader .address_to_class_hash_mut() @@ -1400,7 +1405,7 @@ fn library_call() { .insert(lib_address, lib_nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); // Create an execution entry point let calldata = [25.into(), Felt252::from_bytes_be(&lib_class_hash)].to_vec(); @@ -1488,7 +1493,7 @@ fn library_call() { } fn execute_deploy( - state: &mut CachedState, + state: &mut CachedState, caller_address: &Address, selector: &BigUint, calldata: &[Felt252], @@ -1576,13 +1581,13 @@ fn deploy_syscall_test() { let _deployee_nonce = Felt252::zero(); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, deployer_class_hash, deployer_contract_class, ); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, deployee_class_hash, deployee_contract_class, ); @@ -1683,13 +1688,13 @@ fn deploy_syscall_address_unavailable_test() { let deployee_address = expected_deployed_contract_address; insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, deployer_class_hash, deployer_contract_class, ); insert_sierra_class_into_cache( - &mut contract_class_cache, + &contract_class_cache, deployee_class_hash, deployee_contract_class, ); @@ -1754,7 +1759,7 @@ fn get_execution_info_test() { let selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = HashMap::new(); + let mut contract_class_cache = PermanentContractClassCache::default(); // Contract data let address = Address(1111.into()); @@ -1774,7 +1779,7 @@ fn get_execution_info_test() { .insert(address.clone(), nonce); // Create state from the state_reader and contract cache. - let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache); + let mut state = CachedState::new(Arc::new(state_reader), Arc::new(contract_class_cache)); let calldata = [].to_vec(); diff --git a/tests/internals.rs b/tests/internals.rs index 96b90d306..87e5e5047 100644 --- a/tests/internals.rs +++ b/tests/internals.rs @@ -16,9 +16,6 @@ use lazy_static::lazy_static; use num_bigint::BigUint; use num_traits::{Num, One, Zero}; use pretty_assertions_sorted::{assert_eq, assert_eq_sorted}; -use starknet_in_rust::core::contract_address::{ - compute_casm_class_hash, compute_sierra_class_hash, -}; use starknet_in_rust::core::errors::state_errors::StateError; use starknet_in_rust::definitions::constants::{ DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS, VALIDATE_ENTRY_POINT_SELECTOR, @@ -33,41 +30,31 @@ use starknet_in_rust::transaction::{DeclareV2, Deploy}; use starknet_in_rust::CasmContractClass; use starknet_in_rust::EntryPointType; use starknet_in_rust::{ - core::{ - contract_address::{compute_casm_class_hash, compute_sierra_class_hash}, - errors::state_errors::StateError, + core::contract_address::{compute_casm_class_hash, compute_sierra_class_hash}, + definitions::constants::{ + CONSTRUCTOR_ENTRY_POINT_SELECTOR, EXECUTE_ENTRY_POINT_SELECTOR, TRANSACTION_VERSION, + TRANSFER_ENTRY_POINT_SELECTOR, TRANSFER_EVENT_SELECTOR, + VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR, }, +}; +use starknet_in_rust::{ definitions::{ block_context::{BlockContext, StarknetChainId, StarknetOsConfig}, - constants::{ - CONSTRUCTOR_ENTRY_POINT_SELECTOR, DEFAULT_CAIRO_RESOURCE_FEE_WEIGHTS, - EXECUTE_ENTRY_POINT_SELECTOR, TRANSACTION_VERSION, TRANSFER_ENTRY_POINT_SELECTOR, - TRANSFER_EVENT_SELECTOR, VALIDATE_DECLARE_ENTRY_POINT_SELECTOR, - VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR, VALIDATE_ENTRY_POINT_SELECTOR, - }, transaction_type::TransactionType, }, - execution::{ - execution_entry_point::ExecutionEntryPoint, CallInfo, CallType, OrderedEvent, - TransactionExecutionContext, TransactionExecutionInfo, - }, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, + execution::{CallInfo, CallType, OrderedEvent, TransactionExecutionInfo}, state::{ cached_state::CachedState, contract_class_cache::{ContractClassCache, PermanentContractClassCache}, in_memory_state_reader::InMemoryStateReader, state_api::{State, StateReader}, state_cache::{StateCache, StorageEntry}, - BlockInfo, ExecutionResourcesManager, + BlockInfo, }, transaction::{ - error::TransactionError, fee::calculate_tx_fee, invoke_function::InvokeFunction, Declare, - DeclareV2, Deploy, DeployAccount, + error::TransactionError, invoke_function::InvokeFunction, Declare, DeployAccount, }, utils::{calculate_sn_keccak, felt_to_hash, Address, ClassHash}, - CasmContractClass, EntryPointType, }; use std::{ collections::{HashMap, HashSet}, @@ -223,8 +210,13 @@ fn create_account_tx_test_state() -> Result< Ok((block_context, cached_state)) } -fn create_account_tx_test_state_revert_test( -) -> Result<(BlockContext, CachedState), Box> { +fn create_account_tx_test_state_revert_test() -> Result< + ( + BlockContext, + CachedState, + ), + Box, +> { let block_context = new_starknet_block_context_for_testing(); let test_contract_class_hash = felt_to_hash(&TEST_CLASS_HASH.clone()); @@ -302,13 +294,13 @@ fn create_account_tx_test_state_revert_test( } Arc::new(state_reader) }, - HashMap::new(), + Arc::new(PermanentContractClassCache::default()), ); Ok((block_context, cached_state)) } -fn expected_state_before_tx() -> CachedState { +fn expected_state_before_tx() -> CachedState { let in_memory_state_reader = initial_in_memory_state_reader(); CachedState::new( From d3e333926d0c2fa371791895909ffd90d36432a9 Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 14 Nov 2023 13:21:00 -0300 Subject: [PATCH 51/56] clippy --- bench/native_bench.rs | 8 ++++---- tests/cairo_native.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bench/native_bench.rs b/bench/native_bench.rs index e923c50df..16db801e7 100644 --- a/bench/native_bench.rs +++ b/bench/native_bench.rs @@ -40,7 +40,7 @@ use starknet_in_rust::{ utils::{Address, ClassHash}, }; use std::cell::RefCell; -use std::collections::HashMap; + use std::rc::Rc; use std::sync::Arc; @@ -70,7 +70,7 @@ pub fn main() { fn bench_fibo(executions: usize, native: bool) { // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); static CASM_CLASS_HASH: ClassHash = [2; 32]; let (contract_class, constructor_selector) = match native { @@ -144,7 +144,7 @@ fn bench_fibo(executions: usize, native: bool) { fn bench_fact(executions: usize, native: bool) { // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); static CASM_CLASS_HASH: ClassHash = [2; 32]; let (contract_class, constructor_selector) = match native { @@ -221,7 +221,7 @@ fn bench_fact(executions: usize, native: bool) { fn bench_erc20(executions: usize, native: bool) { // 1. setup ERC20 contract and state. // Create state reader and preload the contract classes. - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); lazy_static! { static ref ERC20_CLASS_HASH: ClassHash = felt_str!("2").to_be_bytes(); diff --git a/tests/cairo_native.rs b/tests/cairo_native.rs index 4a3b5586e..4b335e1a7 100644 --- a/tests/cairo_native.rs +++ b/tests/cairo_native.rs @@ -28,7 +28,7 @@ use starknet_in_rust::{ state::{in_memory_state_reader::InMemoryStateReader, ExecutionResourcesManager}, utils::{Address, ClassHash}, }; -use std::collections::HashMap; + use std::collections::HashSet; use std::sync::Arc; @@ -70,7 +70,7 @@ fn get_block_hash_test() { let casm_external_selector = &casm_entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let native_class_hash: ClassHash = [1; 32]; let casm_class_hash: ClassHash = [2; 32]; @@ -1066,7 +1066,7 @@ fn replace_class_contract_call() { .unwrap(); // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let mut native_contract_class_cache = PermanentContractClassCache::default(); let address = Address(Felt252::one()); @@ -1268,7 +1268,7 @@ fn keccak_syscall_test() { let native_class_hash: ClassHash = [1; 32]; let caller_address = Address(123456789.into()); - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); insert_sierra_class_into_cache( &contract_class_cache, @@ -1364,7 +1364,7 @@ fn library_call() { let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector; // Create state reader with class hash data - let mut contract_class_cache = PermanentContractClassCache::default(); + let contract_class_cache = PermanentContractClassCache::default(); let address = Address(1111.into()); let class_hash: ClassHash = [1; 32]; From 9cf7d7c052a071b7eb90765cf038a4a901c456a7 Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 14 Nov 2023 14:12:55 -0300 Subject: [PATCH 52/56] Remove old file --- examples/contract_execution/main.rs | 177 ---------------------------- 1 file changed, 177 deletions(-) delete mode 100644 examples/contract_execution/main.rs diff --git a/examples/contract_execution/main.rs b/examples/contract_execution/main.rs deleted file mode 100644 index 0bea3e760..000000000 --- a/examples/contract_execution/main.rs +++ /dev/null @@ -1,177 +0,0 @@ -#![deny(warnings)] - -//! A simple example of starknet-rs use. -//! -//! In [`test_contract`] we have all the interaction with the crate's API. -//! In [`main`] we use it to run a compiled contract's entrypoint and print -//! the returned data. -//! -//! It also includes some small tests that assert the data returned by -//! running some pre-compiled contracts is as expected. - -use cairo_vm::felt::Felt252; -use starknet_in_rust::{ - definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION}, - services::api::contract_classes::{ - compiled_class::CompiledClass, deprecated_contract_class::ContractClass, - }, - state::{ - cached_state::CachedState, contract_class_cache::PermanentContractClassCache, - in_memory_state_reader::InMemoryStateReader, state_api::State, - }, - transaction::{Declare, Deploy, InvokeFunction, Transaction}, - utils::{calculate_sn_keccak, Address}, -}; -use std::{path::Path, sync::Arc}; - -use tracing_subscriber::EnvFilter; - -fn main() { - tracing::subscriber::set_global_default( - tracing_subscriber::FmtSubscriber::builder() - .with_env_filter(EnvFilter::from_default_env()) - .finish(), - ) - .unwrap(); - - // replace this with the path to your compiled contract - let contract_path = "starknet_programs/fibonacci.json"; - - // replace this with the name of your entrypoint - let entry_point: &str = "fib"; - - // replace this with the arguments for the entrypoint - let calldata: Vec = [10.into()].to_vec(); - - let retdata = test_contract(contract_path, entry_point, calldata); - - let result_strs: Vec = retdata.iter().map(Felt252::to_string).collect(); - let joined_str = result_strs.join(", "); - - println!("The returned values were: {joined_str}"); -} - -/// This function: -/// - declares a new contract class -/// - deploys a new contract -/// - executes the given entry point in the deployed contract -fn test_contract( - contract_path: impl AsRef, - entry_point: &str, - call_data: Vec, -) -> Vec { - //* -------------------------------------------- - //* Initialize needed variables - //* -------------------------------------------- - let block_context = BlockContext::default(); - let chain_id = block_context.starknet_os_config().chain_id().clone(); - let sender_address = Address(1.into()); - let signature = vec![]; - - //* -------------------------------------------- - //* Initialize state - //* -------------------------------------------- - let state_reader = Arc::new(InMemoryStateReader::default()); - let mut state = CachedState::new( - state_reader, - Arc::new(PermanentContractClassCache::default()), - ); - - //* -------------------------------------------- - //* Read contract from file - //* -------------------------------------------- - let contract_class = - ContractClass::from_path(contract_path).expect("Could not load contract from JSON"); - - //* -------------------------------------------- - //* Declare new contract class - //* -------------------------------------------- - let declare_tx = Declare::new( - contract_class.clone(), - chain_id.clone(), - sender_address, - 0, // max fee - 0.into(), - signature.clone(), - 0.into(), // nonce - ) - .expect("couldn't create declare transaction"); - - declare_tx - .execute(&mut state, &block_context) - .expect("could not declare the contract class"); - - //* -------------------------------------------- - //* Deploy new contract class instance - //* -------------------------------------------- - - let deploy = Deploy::new( - Default::default(), // salt - contract_class.clone(), - vec![], // call data - block_context.starknet_os_config().chain_id().clone(), - TRANSACTION_VERSION.clone(), - ) - .unwrap(); - - state - .set_contract_class( - &deploy.contract_hash, - &CompiledClass::Deprecated(Arc::new(contract_class)), - ) - .unwrap(); - let contract_address = deploy.contract_address.clone(); - - let tx = Transaction::Deploy(deploy); - - tx.execute(&mut state, &block_context, 0) - .expect("could not deploy contract"); - - //* -------------------------------------------- - //* Execute contract entrypoint - //* -------------------------------------------- - let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(entry_point.as_bytes())); - - let invoke_tx = InvokeFunction::new( - contract_address, - entry_point_selector, - 0, - TRANSACTION_VERSION.clone(), - call_data, - signature, - chain_id, - Some(0.into()), - ) - .unwrap(); - - let tx = Transaction::InvokeFunction(invoke_tx); - let tx_exec_info = tx.execute(&mut state, &block_context, 0).unwrap(); - - //* -------------------------------------------- - //* Extract return values - //* -------------------------------------------- - tx_exec_info - .call_info - .expect("call info should exist") - .retdata -} - -#[test] -fn test_fibonacci() { - let retdata = test_contract( - "starknet_programs/fibonacci.json", - "fib", - [1.into(), 1.into(), 10.into()].to_vec(), - ); - assert_eq!(retdata, vec![144.into()]); -} - -#[test] -fn test_factorial() { - let retdata = test_contract( - "starknet_programs/factorial.json", - "factorial", - [10.into()].to_vec(), - ); - assert_eq!(retdata, vec![3628800.into()]); -} From 1502671aff128fb4677803be40a8a6bb886092ce Mon Sep 17 00:00:00 2001 From: Federica Date: Tue, 14 Nov 2023 14:22:27 -0300 Subject: [PATCH 53/56] Remove old file --- src/transaction/verify_version.rs | 141 ------------------------------ 1 file changed, 141 deletions(-) delete mode 100644 src/transaction/verify_version.rs diff --git a/src/transaction/verify_version.rs b/src/transaction/verify_version.rs deleted file mode 100644 index 2f9abecdb..000000000 --- a/src/transaction/verify_version.rs +++ /dev/null @@ -1,141 +0,0 @@ -use cairo_vm::felt::Felt252; - -use crate::definitions::constants::{QUERY_VERSION_BASE, SUPPORTED_VERSIONS}; - -use super::error::TransactionError; - -pub fn verify_version( - version: &Felt252, - max_fee: u128, - nonce: &Felt252, - signature: &Vec, -) -> Result<(), TransactionError> { - if !SUPPORTED_VERSIONS.contains(version) { - return Err(TransactionError::UnsupportedVersion(version.to_string())); - } - - if *version == 0.into() || *version == *QUERY_VERSION_BASE { - if max_fee != 0 { - return Err(TransactionError::InvalidMaxFee); - } - if nonce != &0.into() { - return Err(TransactionError::InvalidNonce); - } - if !signature.is_empty() { - return Err(TransactionError::InvalidSignature); - } - } - - Ok(()) -} - -#[cfg(test)] -mod test { - use cairo_vm::felt::Felt252; - - // TODO: fixture tests would be better here - use crate::{definitions::constants::QUERY_VERSION_BASE, transaction::error::TransactionError}; - - use super::verify_version; - - #[test] - fn version_0_with_max_fee_0_nonce_0_and_empty_signature_should_return_ok() { - let version = 0.into(); - let max_fee = 0; - let nonce = 0.into(); - let signature = vec![]; - let result = verify_version(&version, max_fee, &nonce, &signature); - assert!(result.is_ok()); - } - - #[test] - fn version_1_should_return_ok() { - let version = 1.into(); - let max_fee = 2; - let nonce = 3.into(); - let signature = vec![5.into()]; - let result = verify_version(&version, max_fee, &nonce, &signature); - assert!(result.is_ok()); - } - - #[test] - fn version_2_should_return_ok() { - let version = 2.into(); - let max_fee = 43; - let nonce = 4.into(); - let signature = vec![6.into()]; - let result = verify_version(&version, max_fee, &nonce, &signature); - assert!(result.is_ok()); - } - - #[test] - fn version_3_should_fail() { - let version = 3.into(); - let max_fee = 0; - let nonce = 0.into(); - let signature = vec![]; - let result = verify_version(&version, max_fee, &nonce, &signature).unwrap_err(); - assert_matches!(result, TransactionError::UnsupportedVersion(_)); - } - - #[test] - fn version_0_with_max_fee_greater_than_0_should_fail() { - let version = 0.into(); - let max_fee = 1; - let nonce = 0.into(); - let signature = vec![]; - let result = verify_version(&version, max_fee, &nonce, &signature).unwrap_err(); - assert_matches!(result, TransactionError::InvalidMaxFee); - } - - #[test] - fn version_0_with_nonce_greater_than_0_should_fail() { - let version = 0.into(); - let max_fee = 0; - let nonce = 1.into(); - let signature = vec![]; - let result = verify_version(&version, max_fee, &nonce, &signature).unwrap_err(); - assert_matches!(result, TransactionError::InvalidNonce); - } - - #[test] - fn version_0_with_non_empty_signature_should_fail() { - let version = 0.into(); - let max_fee = 0; - let nonce = 0.into(); - let signature = vec![2.into()]; - let result = verify_version(&version, max_fee, &nonce, &signature).unwrap_err(); - assert_matches!(result, TransactionError::InvalidSignature); - } - - #[test] - fn version_0_with_max_fee_0_nonce_0_and_empty_signature_and_query_version_set_should_return_ok() - { - let version = &Into::::into(0) | &QUERY_VERSION_BASE.clone(); - let max_fee = 0; - let nonce = 0.into(); - let signature = vec![]; - let result = verify_version(&version, max_fee, &nonce, &signature); - assert!(result.is_ok()); - } - - #[test] - fn version_1_with_query_version_set_should_return_ok() { - let version = &Into::::into(1) | &QUERY_VERSION_BASE.clone(); - let max_fee = 2; - let nonce = 3.into(); - let signature = vec![5.into()]; - let result = verify_version(&version, max_fee, &nonce, &signature); - assert!(result.is_ok()); - } - - #[test] - fn version_2_with_query_version_set_should_return_ok() { - let version = &Into::::into(2) | &QUERY_VERSION_BASE.clone(); - let max_fee = 43; - let nonce = 4.into(); - let signature = vec![6.into()]; - let result = verify_version(&version, max_fee, &nonce, &signature); - assert!(result.is_ok()); - } -} From 38720085c911495b05f148cab75444b5f79dcd83 Mon Sep 17 00:00:00 2001 From: Federica Date: Thu, 16 Nov 2023 11:11:25 -0300 Subject: [PATCH 54/56] Avoid cloning private cache --- src/state/cached_state.rs | 50 +++++++++++++++------------------------ 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 1f8394bbb..9866667b3 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -32,7 +32,7 @@ pub struct CachedState { #[getset(get = "pub", get_mut = "pub")] pub(crate) contract_class_cache: Arc, - pub(crate) contract_class_cache_private: RwLock>, + pub(crate) contract_class_cache_private: Arc>>, #[cfg(feature = "metrics")] cache_hits: usize, @@ -73,7 +73,7 @@ impl CachedState { cache: StateCache::default(), state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RwLock::new(HashMap::new()), + contract_class_cache_private: Arc::new(RwLock::new(HashMap::new())), #[cfg(feature = "metrics")] cache_hits: 0, @@ -92,7 +92,7 @@ impl CachedState { cache, state_reader, contract_class_cache: contract_classes, - contract_class_cache_private: RwLock::new(HashMap::new()), + contract_class_cache_private: Arc::new(RwLock::new(HashMap::new())), #[cfg(feature = "metrics")] cache_hits: 0, @@ -107,9 +107,7 @@ impl CachedState { state_reader: self.state_reader.clone(), cache: self.cache.clone(), contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RwLock::new( - self.contract_class_cache_private.read().unwrap().clone(), - ), + contract_class_cache_private: self.contract_class_cache_private.clone(), #[cfg(feature = "metrics")] cache_hits: self.cache_hits, #[cfg(feature = "metrics")] @@ -135,12 +133,7 @@ impl CachedState { state_reader: self.state_reader.clone(), cache: self.cache.clone(), contract_class_cache: self.contract_class_cache.clone(), - contract_class_cache_private: RwLock::new( - self.contract_class_cache_private - .read() - .map_err(|_| StateError::FailedToReadContractClassCache)? - .clone(), - ), + contract_class_cache_private: self.contract_class_cache_private.clone(), #[cfg(feature = "metrics")] cache_hits: 0, #[cfg(feature = "metrics")] @@ -243,10 +236,8 @@ impl State for CachedState { class_hash: &ClassHash, contract_class: &CompiledClass, ) -> Result<(), StateError> { - // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when we - // have a mutable reference to the `RefCell` available. self.contract_class_cache_private - .get_mut() + .write() .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, contract_class.clone()); @@ -480,23 +471,21 @@ impl State for CachedState { // I: FETCHING FROM CACHE // deprecated contract classes dont have compiled class hashes, so we only have one case - // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when we - // have a mutable reference to the `RefCell` available. if let Some(compiled_class) = self .contract_class_cache_private - .get_mut() + .read() .map_err(|_| StateError::FailedToReadContractClassCache)? .get(class_hash) .cloned() { - self.add_hit(); + //self.add_hit(); return Ok(compiled_class); } else if let Some(compiled_class) = self.contract_class_cache().get_contract_class(*class_hash) { - self.add_hit(); + //self.add_hit(); self.contract_class_cache_private - .get_mut() + .write() .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, compiled_class.clone()); return Ok(compiled_class); @@ -506,23 +495,22 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - let write_guard = self + if let Some(casm_class) = self .contract_class_cache_private - .get_mut() - .map_err(|_| StateError::FailedToReadContractClassCache)?; - - // `RefCell::get_mut()` provides a mutable reference without the borrowing overhead when - // we have a mutable reference to the `RefCell` available. - if let Some(casm_class) = write_guard.get(compiled_class_hash).cloned() { - self.add_hit(); + .read() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .get(compiled_class_hash) + .cloned() + { + //self.add_hit(); return Ok(casm_class); } else if let Some(casm_class) = self .contract_class_cache() .get_contract_class(*compiled_class_hash) { - self.add_hit(); + //self.add_hit(); self.contract_class_cache_private - .get_mut() + .write() .map_err(|_| StateError::FailedToReadContractClassCache)? .insert(*class_hash, casm_class.clone()); return Ok(casm_class); From 5b17da03335830c144a59322d2f9c489894268cb Mon Sep 17 00:00:00 2001 From: Federica Date: Thu, 16 Nov 2023 12:22:40 -0300 Subject: [PATCH 55/56] Fix locks --- src/state/cached_state.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 9866667b3..0687902b4 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -471,13 +471,13 @@ impl State for CachedState { // I: FETCHING FROM CACHE // deprecated contract classes dont have compiled class hashes, so we only have one case - if let Some(compiled_class) = self + let compiled_class_op = self .contract_class_cache_private .read() .map_err(|_| StateError::FailedToReadContractClassCache)? .get(class_hash) - .cloned() - { + .cloned(); + if let Some(compiled_class) = compiled_class_op { //self.add_hit(); return Ok(compiled_class); } else if let Some(compiled_class) = @@ -495,13 +495,12 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - if let Some(casm_class) = self + let mut write_guard = self .contract_class_cache_private - .read() - .map_err(|_| StateError::FailedToReadContractClassCache)? - .get(compiled_class_hash) - .cloned() - { + .write() + .map_err(|_| StateError::FailedToReadContractClassCache)?; + + if let Some(casm_class) = write_guard.get(compiled_class_hash).cloned() { //self.add_hit(); return Ok(casm_class); } else if let Some(casm_class) = self @@ -509,10 +508,7 @@ impl State for CachedState { .get_contract_class(*compiled_class_hash) { //self.add_hit(); - self.contract_class_cache_private - .write() - .map_err(|_| StateError::FailedToReadContractClassCache)? - .insert(*class_hash, casm_class.clone()); + write_guard.insert(*class_hash, casm_class.clone()); return Ok(casm_class); } } From 849699b6d605823e16006ce6987adafee0ad4cf7 Mon Sep 17 00:00:00 2001 From: Federica Date: Thu, 16 Nov 2023 12:39:37 -0300 Subject: [PATCH 56/56] Uncomment metrics --- src/state/cached_state.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/state/cached_state.rs b/src/state/cached_state.rs index 0687902b4..216a27b4f 100644 --- a/src/state/cached_state.rs +++ b/src/state/cached_state.rs @@ -478,12 +478,12 @@ impl State for CachedState { .get(class_hash) .cloned(); if let Some(compiled_class) = compiled_class_op { - //self.add_hit(); + self.add_hit(); return Ok(compiled_class); } else if let Some(compiled_class) = self.contract_class_cache().get_contract_class(*class_hash) { - //self.add_hit(); + self.add_hit(); self.contract_class_cache_private .write() .map_err(|_| StateError::FailedToReadContractClassCache)? @@ -495,20 +495,24 @@ impl State for CachedState { if let Some(compiled_class_hash) = self.cache.class_hash_to_compiled_class_hash.get(class_hash) { - let mut write_guard = self + let casm_class_op = self .contract_class_cache_private - .write() - .map_err(|_| StateError::FailedToReadContractClassCache)?; - - if let Some(casm_class) = write_guard.get(compiled_class_hash).cloned() { - //self.add_hit(); + .read() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .get(compiled_class_hash) + .cloned(); + if let Some(casm_class) = casm_class_op { + self.add_hit(); return Ok(casm_class); } else if let Some(casm_class) = self .contract_class_cache() .get_contract_class(*compiled_class_hash) { - //self.add_hit(); - write_guard.insert(*class_hash, casm_class.clone()); + self.add_hit(); + self.contract_class_cache_private + .write() + .map_err(|_| StateError::FailedToReadContractClassCache)? + .insert(*class_hash, casm_class.clone()); return Ok(casm_class); } }