Skip to content

Commit

Permalink
refactor(blockifier): rename SyscallError to Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware committed Dec 18, 2024
1 parent 3fc110b commit cb8282f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 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
10 changes: 4 additions & 6 deletions crates/blockifier/src/execution/syscalls/syscall_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ impl<'state> SyscallHandlerBase<'state> {
{
let out_of_range_error = Felt::from_hex(BLOCK_NUMBER_OUT_OF_RANGE_ERROR)
.expect("Converting BLOCK_NUMBER_OUT_OF_RANGE_ERROR to Felt should not fail.");
return Err(SyscallExecutionError::SyscallError {
error_data: vec![out_of_range_error],
});
return Err(SyscallExecutionError::Revert { error_data: vec![out_of_range_error] });
}

let key = StorageKey::try_from(Felt::from(requested_block_number))?;
Expand Down Expand Up @@ -252,7 +250,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 @@ -268,7 +266,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 @@ -284,7 +282,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 cb8282f

Please sign in to comment.