diff --git a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs index 90e6a0082d4..50d8c560ae2 100644 --- a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs +++ b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs @@ -215,13 +215,15 @@ pub fn run_entry_point( let verify_secure = true; let program_segment_size = None; // Infer size from program. let args: Vec<&CairoArg> = args.iter().collect(); - let result = runner.run_from_entrypoint( - entry_point_pc, - &args, - verify_secure, - program_segment_size, - hint_processor, - ); + let result = runner + .run_from_entrypoint( + entry_point_pc, + &args, + verify_secure, + program_segment_size, + hint_processor, + ) + .map_err(Box::new); Ok(result?) } diff --git a/crates/blockifier/src/execution/entry_point_execution.rs b/crates/blockifier/src/execution/entry_point_execution.rs index 2424d0ac2a2..ad7da50afe8 100644 --- a/crates/blockifier/src/execution/entry_point_execution.rs +++ b/crates/blockifier/src/execution/entry_point_execution.rs @@ -305,18 +305,20 @@ pub fn run_entry_point( // Note that we run `verify_secure_runner` manually after filling the holes in the rc96 segment. let verify_secure = false; let args: Vec<&CairoArg> = args.iter().collect(); - runner.run_from_entrypoint( - entry_point.pc(), - &args, - verify_secure, - Some(program_segment_size), - hint_processor, - )?; + runner + .run_from_entrypoint( + entry_point.pc(), + &args, + verify_secure, + Some(program_segment_size), + hint_processor, + ) + .map_err(Box::new)?; maybe_fill_holes(entry_point, runner)?; verify_secure_runner(runner, false, Some(program_segment_size)) - .map_err(CairoRunError::VirtualMachine)?; + .map_err(|error| Box::new(CairoRunError::VirtualMachine(error)))?; Ok(()) } @@ -349,14 +351,16 @@ fn maybe_fill_holes( // So the last implicit is at offset 5 + 1. const IMPLICITS_OFFSET: usize = 6; let rc_96_stop_ptr = (runner.vm.get_ap() - (IMPLICITS_OFFSET + rc96_offset)) - .map_err(|err| CairoRunError::VirtualMachine(VirtualMachineError::Math(err)))?; + .map_err(|err| Box::new(CairoRunError::VirtualMachine(VirtualMachineError::Math(err))))?; let rc96_base = rc96_builtin_runner.base(); let rc96_segment: isize = rc96_base.try_into().expect("Builtin segment index must fit in isize."); - let Relocatable { segment_index: rc96_stop_segment, offset: stop_offset } = - runner.vm.get_relocatable(rc_96_stop_ptr).map_err(CairoRunError::MemoryError)?; + let Relocatable { segment_index: rc96_stop_segment, offset: stop_offset } = runner + .vm + .get_relocatable(rc_96_stop_ptr) + .map_err(|error| Box::new(CairoRunError::MemoryError(error)))?; assert_eq!(rc96_stop_segment, rc96_segment); // Update `segment_used_sizes` to include the holes. diff --git a/crates/blockifier/src/execution/errors.rs b/crates/blockifier/src/execution/errors.rs index 8345db57ccd..d3d00f4eefc 100644 --- a/crates/blockifier/src/execution/errors.rs +++ b/crates/blockifier/src/execution/errors.rs @@ -88,7 +88,7 @@ impl From for PostExecutionError { #[derive(Debug, Error)] pub enum EntryPointExecutionError { #[error(transparent)] - CairoRunError(#[from] CairoRunError), + CairoRunError(#[from] Box), #[error("{error_trace}")] ExecutionFailed { error_trace: Cairo1RevertSummary }, #[error("Internal error: {0}")] diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index 1e8ca2a40f2..3abc6fcd823 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -214,19 +214,22 @@ macro_rules! check_entry_point_execution_error { use cairo_vm::vm::errors::vm_exception::VmException; use $crate::execution::errors::EntryPointExecutionError; - if let EntryPointExecutionError::CairoRunError(CairoRunError::VmException(VmException { - inner_exc, - .. - })) = $error - { - match $expected_hint { - Some(expected_hint) => { - $crate::check_inner_exc_for_custom_hint!(inner_exc, expected_hint) + match $error { + EntryPointExecutionError::CairoRunError(boxed_error) => { + if let CairoRunError::VmException(VmException { inner_exc, .. }) = + &*(boxed_error.as_ref()) + { + match $expected_hint { + Some(expected_hint) => { + $crate::check_inner_exc_for_custom_hint!(inner_exc, expected_hint) + } + None => $crate::check_inner_exc_for_invalid_scenario!(inner_exc), + }; + } else { + panic!("Unexpected structure for error: {:?}", $error); } - None => $crate::check_inner_exc_for_invalid_scenario!(inner_exc), - }; - } else { - panic!("Unexpected structure for error: {:?}", $error); + } + _ => panic!("Unexpected structure for error: {:?}", $error), } }}; } @@ -250,14 +253,14 @@ macro_rules! check_tx_execution_error_inner { TransactionExecutionError::ContractConstructorExecutionFailed( ConstructorEntryPointExecutionError::ExecutionError { error, .. }, ) => { - $crate::check_entry_point_execution_error!(error, $expected_hint) + $crate::check_entry_point_execution_error!(&error, $expected_hint) } _ => panic!("Unexpected structure for error: {:?}", $error), } } else { match $error { TransactionExecutionError::ValidateTransactionError { error, .. } => { - $crate::check_entry_point_execution_error!(error, $expected_hint) + $crate::check_entry_point_execution_error!(&error, $expected_hint) } _ => panic!("Unexpected structure for error: {:?}", $error), }