Skip to content

Commit

Permalink
Properly restoring contract addresses on revert. (#3534)
Browse files Browse the repository at this point in the history
  • Loading branch information
orizi authored Jun 28, 2023
1 parent 1003d5d commit f814b2b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/cairo-lang-runner/src/casm_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,9 @@ impl HintProcessor for CairoHintProcessor<'_> {
// Call the function.
let Some(entry_point) = contract_info.externals.get(&selector) else
{
// Restore the contract addresses in the context.
self.starknet_state.exec_info.caller_address = old_caller_address;
self.starknet_state.exec_info.contract_address = old_contract_address;
fail_syscall!(b"ENTRYPOINT_NOT_FOUND");
};
let function = runner
Expand All @@ -636,6 +639,10 @@ impl HintProcessor for CairoHintProcessor<'_> {
read_array_result_as_vec(&res.memory, &value)
}
RunResultValue::Panic(mut panic_data) => {
// Restore the contract addresses in the context.
self.starknet_state.exec_info.caller_address = old_caller_address;
self.starknet_state.exec_info.contract_address =
old_contract_address;
fail_syscall!(panic_data, b"ENTRYPOINT_FAILED");
}
};
Expand Down

0 comments on commit f814b2b

Please sign in to comment.