Skip to content

Commit

Permalink
refactor(blockifier): rename SyscallError to Revert (#2761)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware authored Dec 19, 2024
1 parent 0f27697 commit b77abf4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/native/syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'state> NativeSyscallHandler<'state> {
}

match error {
SyscallExecutionError::SyscallError { error_data } => error_data,
SyscallExecutionError::Revert { error_data } => error_data,
error => {
assert!(
self.unrecoverable_error.is_none(),
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/execution/secp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where

if bounds.iter().any(|p| **p >= modulus) {
let error = match Felt::from_hex(INVALID_ARGUMENT) {
Ok(err) => SyscallExecutionError::SyscallError { error_data: vec![err] },
Ok(err) => SyscallExecutionError::Revert { error_data: vec![err] },
Err(err) => SyscallExecutionError::from(err),
};

Expand Down
6 changes: 3 additions & 3 deletions crates/blockifier/src/execution/syscalls/hint_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ pub enum SyscallExecutionError {
StateError(#[from] StateError),
#[error(transparent)]
VirtualMachineError(#[from] VirtualMachineError),
#[error("Syscall error.")]
SyscallError { error_data: Vec<Felt> },
#[error("Syscall revert.")]
Revert { error_data: Vec<Felt> },
}

#[derive(Debug, Error)]
Expand Down Expand Up @@ -480,7 +480,7 @@ impl<'a> SyscallHintProcessor<'a> {
Ok(response) => {
SyscallResponseWrapper::Success { gas_counter: remaining_gas, response }
}
Err(SyscallExecutionError::SyscallError { error_data: data }) => {
Err(SyscallExecutionError::Revert { error_data: data }) => {
SyscallResponseWrapper::Failure { gas_counter: remaining_gas, error_data: data }
}
Err(error) => return Err(error.into()),
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/execution/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub fn call_contract(

let retdata_segment = execute_inner_call(entry_point, vm, syscall_handler, remaining_gas)
.map_err(|error| match error {
SyscallExecutionError::SyscallError { .. } => error,
SyscallExecutionError::Revert { .. } => error,
_ => error.as_call_contract_execution_error(class_hash, storage_address, selector),
})?;

Expand Down Expand Up @@ -423,7 +423,7 @@ pub fn library_call(

let retdata_segment = execute_inner_call(entry_point, vm, syscall_handler, remaining_gas)
.map_err(|error| match error {
SyscallExecutionError::SyscallError { .. } => error,
SyscallExecutionError::Revert { .. } => error,
_ => error.as_lib_call_execution_error(
request.class_hash,
syscall_handler.storage_address(),
Expand Down
8 changes: 4 additions & 4 deletions crates/blockifier/src/execution/syscalls/syscall_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'state> SyscallHandlerBase<'state> {
.expect(
"Converting BLOCK_NUMBER_OUT_OF_RANGE_ERROR to Felt should not fail.",
);
return Err(SyscallExecutionError::SyscallError {
return Err(SyscallExecutionError::Revert {
error_data: vec![out_of_range_error],
});
}
Expand Down Expand Up @@ -266,7 +266,7 @@ impl<'state> SyscallHandlerBase<'state> {
raw_retdata.push(
Felt::from_hex(ENTRYPOINT_FAILED_ERROR).map_err(SyscallExecutionError::from)?,
);
return Err(SyscallExecutionError::SyscallError { error_data: raw_retdata });
return Err(SyscallExecutionError::Revert { error_data: raw_retdata });
}

Ok(raw_retdata)
Expand All @@ -282,7 +282,7 @@ impl<'state> SyscallHandlerBase<'state> {
let (n_rounds, remainder) = num_integer::div_rem(input_length, KECCAK_FULL_RATE_IN_WORDS);

if remainder != 0 {
return Err(SyscallExecutionError::SyscallError {
return Err(SyscallExecutionError::Revert {
error_data: vec![
Felt::from_hex(INVALID_INPUT_LENGTH_ERROR)
.expect("Failed to parse INVALID_INPUT_LENGTH_ERROR hex string"),
Expand All @@ -298,7 +298,7 @@ impl<'state> SyscallHandlerBase<'state> {
let out_of_gas_error = Felt::from_hex(OUT_OF_GAS_ERROR)
.expect("Failed to parse OUT_OF_GAS_ERROR hex string");

return Err(SyscallExecutionError::SyscallError { error_data: vec![out_of_gas_error] });
return Err(SyscallExecutionError::Revert { error_data: vec![out_of_gas_error] });
}
*remaining_gas -= gas_cost;

Expand Down

0 comments on commit b77abf4

Please sign in to comment.