diff --git a/src/hints/hints_raw.rs b/src/hints/hints_raw.rs index 7d057500..bb040fb7 100644 --- a/src/hints/hints_raw.rs +++ b/src/hints/hints_raw.rs @@ -1,4 +1,5 @@ -pub const STARKNET_OS_INPUT: &str = "from starkware.starknet.core.os.os_input import StarknetOsInput\n\nos_input = \ +pub const STARKNET_OS_INPUT: &str = + "from starkware.starknet.core.os.os_input import StarknetOsInput\n\nos_input = \ StarknetOsInput.load(data=program_input)\n\nids.initial_carried_outputs.messages_to_l1 = \ segments.add_temp_segment()\nids.initial_carried_outputs.messages_to_l2 = segments.add_temp_segment()"; @@ -67,12 +68,13 @@ pub const LOAD_CONTRACT_ADDRESS: &str = "from starkware.starknet.business_logic. InternalL1Handler\nids.contract_address = (\ntx.contract_address if \ isinstance(tx, InternalL1Handler) else tx.sender_address\n)"; -pub const PREPARE_CONSTRUCTOR_EXECUTION: &str = "ids.contract_address_salt = tx.contract_address_salt\nids.class_hash = \ - tx.class_hash\nids.constructor_calldata_size = len(tx.constructor_calldata)\nids.constructor_calldata \ - = segments.gen_arg(arg=tx.constructor_calldata)"; +pub const PREPARE_CONSTRUCTOR_EXECUTION: &str = "ids.contract_address_salt = tx.contract_address_salt\nids.class_hash \ + = tx.class_hash\nids.constructor_calldata_size = \ + len(tx.constructor_calldata)\nids.constructor_calldata = \ + segments.gen_arg(arg=tx.constructor_calldata)"; pub const TRANSACTION_VERSION: &str = "memory[ap] = to_felt_or_relocatable(tx.version)"; -pub const ASSERT_TRANSACTION_HASH: &str = "assert ids.transaction_hash == tx.hash_value, (\n \"Computed transaction_hash \ - is inconsistent with the hash in the transaction. \"\n f\"Computed hash = {ids.transaction_hash}, \ - Expected hash = {tx.hash_value}.\")"; +pub const ASSERT_TRANSACTION_HASH: &str = + "assert ids.transaction_hash == tx.hash_value, (\n \"Computed transaction_hash is inconsistent with the hash \ + in the transaction. \"\n f\"Computed hash = {ids.transaction_hash}, Expected hash = {tx.hash_value}.\")"; diff --git a/src/hints/mod.rs b/src/hints/mod.rs index 502491ae..eac3e15f 100644 --- a/src/hints/mod.rs +++ b/src/hints/mod.rs @@ -353,6 +353,11 @@ pub fn assert_transaction_hash( let tx = exec_scopes.get::("tx")?; let transaction_hash = get_integer_from_var_name("transaction_hash", vm, ids_data, ap_tracking)?.into_owned(); - assert_eq!(tx.hash_value, transaction_hash, "Computed transaction_hash is inconsistent with the hash in the transaction. Computed hash = {}, Expected hash = {}.", transaction_hash, tx.hash_value); + assert_eq!( + tx.hash_value, transaction_hash, + "Computed transaction_hash is inconsistent with the hash in the transaction. Computed hash = {}, Expected \ + hash = {}.", + transaction_hash, tx.hash_value + ); Ok(()) } diff --git a/src/state/mod.rs b/src/state/mod.rs index 5f0278c1..6f326015 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -116,7 +116,7 @@ impl SharedState { let mut contract_trie: MerkleTrie = MerkleTrie::empty(); for update in updates.clone() { - contract_trie.set(&self.contract_storage, felt_to_bits_api(*update.0 .0.key()), update.1).unwrap(); + contract_trie.set(&self.contract_storage, felt_to_bits_api(*update.0.0.key()), update.1).unwrap(); } self.contract_storage.commit_and_persist(contract_trie, *addr.0.key()); diff --git a/src/state/trie.rs b/src/state/trie.rs index 2bd85c12..5143c513 100644 --- a/src/state/trie.rs +++ b/src/state/trie.rs @@ -368,11 +368,7 @@ impl MerkleTrie { }; if *node.borrow() == InternalNode::Leaf { - if let Some(value) = self.leaves.get(&key) { - Ok(Some(*value)) - } else { - storage.leaf(&key) - } + if let Some(value) = self.leaves.get(&key) { Ok(Some(*value)) } else { storage.leaf(&key) } } else { Ok(None) }