diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index 103903b2c3..4cb8d872d5 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -359,9 +359,7 @@ impl<'a> DeprecatedSyscallHintProcessor<'a> { &mut self, vm: &mut VirtualMachine, ) -> DeprecatedSyscallResult { - let selector = felt_from_ptr(vm, &mut self.syscall_ptr)?; - - Ok(selector) + Ok(felt_from_ptr(vm, &mut self.syscall_ptr)?) } fn increment_syscall_count(&mut self, selector: &DeprecatedSyscallSelector) { @@ -466,9 +464,9 @@ impl HintProcessorLogic for DeprecatedSyscallHintProcessor<'_> { } pub fn felt_to_bool(felt: Felt) -> DeprecatedSyscallResult { - if felt == Felt::from(0_u8) { + if felt == Felt::ZERO { Ok(false) - } else if felt == Felt::from(1_u8) { + } else if felt == Felt::ONE { Ok(true) } else { Err(DeprecatedSyscallExecutionError::InvalidSyscallInput { diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index f977658fa4..3d8cbf2127 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -236,10 +236,11 @@ pub struct SyscallHintProcessor<'a> { pub sha256_segment_end_ptr: Option, + // Execution info, for get_execution_info syscall; allocated on-demand. + execution_info_ptr: Option, + // Additional fields. hints: &'a HashMap, - // Transaction info. and signature segments; allocated on-demand. - execution_info_ptr: Option, } impl<'a> SyscallHintProcessor<'a> { @@ -535,9 +536,7 @@ impl<'a> SyscallHintProcessor<'a> { } fn read_next_syscall_selector(&mut self, vm: &mut VirtualMachine) -> SyscallResult { - let selector = felt_from_ptr(vm, &mut self.syscall_ptr)?; - - Ok(selector) + Ok(felt_from_ptr(vm, &mut self.syscall_ptr)?) } pub fn increment_syscall_count_by(&mut self, selector: &SyscallSelector, n: usize) { @@ -761,9 +760,9 @@ impl HintProcessorLogic for SyscallHintProcessor<'_> { } pub fn felt_to_bool(felt: Felt, error_info: &str) -> SyscallResult { - if felt == Felt::from(0_u8) { + if felt == Felt::ZERO { Ok(false) - } else if felt == Felt::from(1_u8) { + } else if felt == Felt::ONE { Ok(true) } else { Err(SyscallExecutionError::InvalidSyscallInput { input: felt, info: error_info.into() }) diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index fc201b254a..9727840ae3 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -96,13 +96,13 @@ impl SyscallResponse for SyscallResponseWrapper { Self::Success { gas_counter, response } => { write_felt(vm, ptr, Felt::from(gas_counter))?; // 0 to indicate success. - write_felt(vm, ptr, Felt::from(0_u8))?; + write_felt(vm, ptr, Felt::ZERO)?; response.write(vm, ptr) } Self::Failure { gas_counter, error_data } => { write_felt(vm, ptr, Felt::from(gas_counter))?; // 1 to indicate failure. - write_felt(vm, ptr, Felt::from(1_u8))?; + write_felt(vm, ptr, Felt::ONE)?; // Write the error data to a new memory segment. let revert_reason_start = vm.add_memory_segment(); @@ -579,7 +579,7 @@ pub struct StorageReadRequest { impl SyscallRequest for StorageReadRequest { fn read(vm: &VirtualMachine, ptr: &mut Relocatable) -> SyscallResult { let address_domain = felt_from_ptr(vm, ptr)?; - if address_domain != Felt::from(0_u8) { + if address_domain != Felt::ZERO { return Err(SyscallExecutionError::InvalidAddressDomain { address_domain }); } let address = StorageKey::try_from(felt_from_ptr(vm, ptr)?)?; @@ -620,7 +620,7 @@ pub struct StorageWriteRequest { impl SyscallRequest for StorageWriteRequest { fn read(vm: &VirtualMachine, ptr: &mut Relocatable) -> SyscallResult { let address_domain = felt_from_ptr(vm, ptr)?; - if address_domain != Felt::from(0_u8) { + if address_domain != Felt::ZERO { return Err(SyscallExecutionError::InvalidAddressDomain { address_domain }); } let address = StorageKey::try_from(felt_from_ptr(vm, ptr)?)?; diff --git a/crates/blockifier/src/fee/fee_utils.rs b/crates/blockifier/src/fee/fee_utils.rs index 37cb1cb4e6..7e7d5496d7 100644 --- a/crates/blockifier/src/fee/fee_utils.rs +++ b/crates/blockifier/src/fee/fee_utils.rs @@ -97,7 +97,7 @@ pub fn get_balance_and_if_covers_fee( balance_high, // TODO(Dori,1/10/2023): If/when fees can be more than 128 bit integers, this should be // updated. - balance_high > Felt::from(0_u8) || balance_low >= Felt::from(fee.0), + balance_high > Felt::ZERO || balance_low >= Felt::from(fee.0), )) } diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 58c48bf084..f07ac385ca 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -487,7 +487,7 @@ impl AccountTransaction { // The least significant 128 bits of the amount transferred. let lsb_amount = Felt::from(actual_fee.0); // The most significant 128 bits of the amount transferred. - let msb_amount = Felt::from(0_u8); + let msb_amount = Felt::ZERO; let TransactionContext { block_context, tx_info } = tx_context.as_ref(); let storage_address = tx_context.fee_token_address(); diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index f3197f2bf1..1e16dffe9a 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -1901,7 +1901,7 @@ fn test_validate_accounts_tx( additional_data: Some(vec![ Felt::from(CURRENT_BLOCK_NUMBER_FOR_VALIDATE), Felt::from(CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE), - Felt::from(0_u64), // Sequencer address for validate. + Felt::ZERO, // Sequencer address for validate. ]), declared_contract: Some(FeatureContract::Empty(declared_contract_cairo_version)), resource_bounds: ValidResourceBounds::create_for_testing(), diff --git a/crates/papyrus_storage/src/state/state_test.rs b/crates/papyrus_storage/src/state/state_test.rs index 09cd1e787e..8cf25c39b6 100644 --- a/crates/papyrus_storage/src/state/state_test.rs +++ b/crates/papyrus_storage/src/state/state_test.rs @@ -545,7 +545,7 @@ fn revert_state() { assert!(state_reader.get_nonce_at(state_number, &contract1).unwrap().is_none()); assert_eq!( state_reader.get_storage_at(state_number, contract0, &updated_storage_key).unwrap(), - Felt::from(0_u8) + Felt::ZERO ); assert!(txn.get_casm(&class2).unwrap().is_none()); } diff --git a/crates/starknet_committer/src/forest/skeleton_forest_test.rs b/crates/starknet_committer/src/forest/skeleton_forest_test.rs index f6c2fefa7b..e6707f41bd 100644 --- a/crates/starknet_committer/src/forest/skeleton_forest_test.rs +++ b/crates/starknet_committer/src/forest/skeleton_forest_test.rs @@ -222,7 +222,7 @@ pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, Storag }, storage_tries: HashMap::from([ ( - ContractAddress(Felt::from(0_u128)), + ContractAddress(Felt::ZERO), OriginalSkeletonTreeImpl { nodes: create_expected_skeleton_nodes( vec![ diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs b/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs index 4f655400cc..5958d330ef 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/external_test_utils.rs @@ -208,7 +208,7 @@ pub fn create_root_edge_entry( Felt::from(old_root) .to_bytes_be() .into_iter() - .chain(Felt::from(0_u128).to_bytes_be()) + .chain(Felt::ZERO.to_bytes_be()) .chain([length]) .collect(), );