Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana committed Oct 25, 2023
1 parent fbac4c1 commit 13f050c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
16 changes: 9 additions & 7 deletions src/hints/hints_raw.rs
Original file line number Diff line number Diff line change
@@ -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()";

Expand Down Expand Up @@ -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}.\")";
7 changes: 6 additions & 1 deletion src/hints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ pub fn assert_transaction_hash(
let tx = exec_scopes.get::<InternalTransaction>("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(())
}
2 changes: 1 addition & 1 deletion src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<S: StateReader> SharedState<S> {
let mut contract_trie: MerkleTrie<PedersenHash, DEFAULT_STORAGE_TREE_HEIGHT> = 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());

Expand Down
6 changes: 1 addition & 5 deletions src/state/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,7 @@ impl<H: StarkHasher, const HEIGHT: usize> MerkleTrie<H, HEIGHT> {
};

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)
}
Expand Down

0 comments on commit 13f050c

Please sign in to comment.