From 2f1e9f94037d3511a62d50d178e7f85b7f0da304 Mon Sep 17 00:00:00 2001 From: Yonatan Iluz Date: Wed, 18 Dec 2024 15:26:23 +0200 Subject: [PATCH] refactor(blockifier): rename SyscallError to Revert --- crates/blockifier/src/execution/native/syscall_handler.rs | 2 +- crates/blockifier/src/execution/secp.rs | 2 +- .../blockifier/src/execution/syscalls/hint_processor.rs | 6 +++--- crates/blockifier/src/execution/syscalls/mod.rs | 4 ++-- crates/blockifier/src/execution/syscalls/syscall_base.rs | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/blockifier/src/execution/native/syscall_handler.rs b/crates/blockifier/src/execution/native/syscall_handler.rs index 5bd0640978..a23f7e58e8 100644 --- a/crates/blockifier/src/execution/native/syscall_handler.rs +++ b/crates/blockifier/src/execution/native/syscall_handler.rs @@ -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(), diff --git a/crates/blockifier/src/execution/secp.rs b/crates/blockifier/src/execution/secp.rs index f96bb11633..976bbfacb1 100644 --- a/crates/blockifier/src/execution/secp.rs +++ b/crates/blockifier/src/execution/secp.rs @@ -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), }; diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index 6bdfc8f905..85a9733f06 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -125,8 +125,8 @@ pub enum SyscallExecutionError { StateError(#[from] StateError), #[error(transparent)] VirtualMachineError(#[from] VirtualMachineError), - #[error("Syscall error.")] - SyscallError { error_data: Vec }, + #[error("Syscall revert.")] + Revert { error_data: Vec }, } #[derive(Debug, Error)] @@ -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()), diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index 9d6f412b72..965eb3efe4 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -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), })?; @@ -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(), diff --git a/crates/blockifier/src/execution/syscalls/syscall_base.rs b/crates/blockifier/src/execution/syscalls/syscall_base.rs index 75de00ae0d..4ffa977c15 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_base.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_base.rs @@ -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], }); } @@ -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) @@ -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"), @@ -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;