Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
}
Expand Down
26 changes: 15 additions & 11 deletions crates/blockifier/src/execution/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl From<RunnerError> for PostExecutionError {
#[derive(Debug, Error)]
pub enum EntryPointExecutionError {
#[error(transparent)]
CairoRunError(#[from] CairoRunError),
CairoRunError(#[from] Box<CairoRunError>),
#[error("{error_trace}")]
ExecutionFailed { error_trace: Cairo1RevertSummary },
#[error("Internal error: {0}")]
Expand Down
31 changes: 17 additions & 14 deletions crates/blockifier/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}};
}
Expand All @@ -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),
}
Expand Down
Loading