From a489d7f3fdb72561d9fd2596bc4734a7f63da2a2 Mon Sep 17 00:00:00 2001 From: Ori Friedlender Date: Tue, 16 Jan 2024 12:05:45 +0200 Subject: [PATCH] Change additional as to try_from and try_to --- crates/blockifier/src/execution/entry_point.rs | 8 +++++--- .../blockifier/src/execution/syscalls/hint_processor.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/blockifier/src/execution/entry_point.rs b/crates/blockifier/src/execution/entry_point.rs index 4596aa5994..6a30fdb1e3 100644 --- a/crates/blockifier/src/execution/entry_point.rs +++ b/crates/blockifier/src/execution/entry_point.rs @@ -235,11 +235,13 @@ impl EntryPointExecutionContext { // transactions derive this value from the `max_fee`. let tx_gas_upper_bound = match account_tx_context { AccountTransactionContext::Deprecated(context) => { - (context.max_fee.0 + let max_cairo_steps = context.max_fee.0 / block_context .gas_prices - .get_gas_price_by_fee_type(&account_tx_context.fee_type())) - as usize + .get_gas_price_by_fee_type(&account_tx_context.fee_type()); + // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the + // conversion works. + usize::try_from(max_cairo_steps).expect("Failed to convert u128 to usize") } AccountTransactionContext::Current(context) => { context.l1_resource_bounds()?.max_amount as usize diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index 15e0bcdbe2..d5c90d2834 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -564,7 +564,7 @@ fn get_ptr_from_res_operand_unchecked(vm: &mut VirtualMachine, res: &ResOperand) Register::AP => vm.get_ap(), Register::FP => vm.get_fp(), }; - let cell_reloc = (base + (cell.offset as i32)).unwrap(); + let cell_reloc = (base + (i32::from(cell.offset))).unwrap(); (vm.get_relocatable(cell_reloc).unwrap() + &base_offset).unwrap() }