Skip to content

Commit

Permalink
Fix returned error array.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyalesokhin-starkware committed Oct 1, 2024
1 parent 1c651aa commit f2f3dd8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/cairo-lang-runner/src/casm_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ macro_rules! fail_syscall {
$existing.push(Felt252::from_bytes_be_slice($reason));
return Ok(SyscallResult::Failure($existing))
};
($reason1:expr, $reason2:expr) => {
return Ok(SyscallResult::Failure(vec![
Felt252::from_bytes_be_slice($reason1),
Felt252::from_bytes_be_slice($reason2),
]))
};
}

/// Gas Costs for syscalls.
Expand Down Expand Up @@ -1035,7 +1041,7 @@ impl<'a> CairoHintProcessor<'a> {

// Get the class hash of the contract.
let Some(class_hash) = self.starknet_state.deployed_contracts.get(&contract_address) else {
fail_syscall!(b"CONTRACT_NOT_DEPLOYED");
fail_syscall!(b"CONTRACT_NOT_DEPLOYED", b"ENTRYPOINT_FAILED");
};

// Prepare runner for running the ctor.
Expand All @@ -1047,7 +1053,7 @@ impl<'a> CairoHintProcessor<'a> {

// Call the function.
let Some(entry_point) = contract_info.externals.get(&selector) else {
fail_syscall!(b"ENTRYPOINT_NOT_FOUND");
fail_syscall!(b"ENTRYPOINT_NOT_FOUND", b"ENTRYPOINT_FAILED");
};

let old_addrs = self.starknet_state.open_caller_context((
Expand Down Expand Up @@ -1085,7 +1091,7 @@ impl<'a> CairoHintProcessor<'a> {

// Call the function.
let Some(entry_point) = contract_info.externals.get(&selector) else {
fail_syscall!(b"ENTRYPOINT_NOT_FOUND");
fail_syscall!(b"ENTRYPOINT_NOT_FOUND", b"ENTRYPOINT_FAILED");
};
match self.call_entry_point(gas_counter, runner, entry_point, calldata, vm) {
Ok((res_data_start, res_data_end)) => {
Expand Down

0 comments on commit f2f3dd8

Please sign in to comment.