Skip to content

Commit

Permalink
Merge pull request #1529 from eqlabs/krisztian/exeuction-errors-shoul…
Browse files Browse the repository at this point in the history
…d-be-custom

fix(executor): map VM errors to custom errors
  • Loading branch information
kkovaacs committed Nov 15, 2023
2 parents 2d60c72 + 1016e34 commit 750c66b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- RPC v0.5 incorrectly has a status field in pending `starknet_getBlockWithXXX` responses.
- Error details for many execution-related issues were not properly sent back to the JSON client and were logged on WARN level instead.

## [0.9.5] - 2023-11-09

Expand Down
13 changes: 8 additions & 5 deletions crates/executor/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ impl From<TransactionExecutionError> for CallError {
EntryPointExecutionError::PreExecutionError(
PreExecutionError::UninitializedStorageAddress(_),
) => Self::ContractNotFound,
_ => Self::Internal(anyhow::anyhow!("Internal error: {}", e)),
_ => Self::Custom(anyhow::anyhow!("Execution error: {}", e)),
},
e => Self::Internal(anyhow::anyhow!("Internal error: {}", e)),
e => Self::Custom(anyhow::anyhow!("Execution error: {}", e)),
}
}
}
Expand All @@ -42,20 +42,23 @@ impl From<EntryPointExecutionError> for CallError {
EntryPointExecutionError::PreExecutionError(
PreExecutionError::UninitializedStorageAddress(_),
) => Self::ContractNotFound,
_ => Self::Internal(anyhow::anyhow!("Internal error: {}", e)),
_ => Self::Custom(anyhow::anyhow!("Execution error: {}", e)),
}
}
}

impl From<StateError> for CallError {
fn from(e: StateError) -> Self {
Self::Internal(anyhow::anyhow!("Internal state error: {}", e))
match e {
StateError::StateReadError(_) => Self::Internal(e.into()),
_ => Self::Custom(anyhow::anyhow!("State error: {}", e)),
}
}
}

impl From<starknet_api::StarknetApiError> for CallError {
fn from(value: starknet_api::StarknetApiError) -> Self {
Self::Internal(value.into())
Self::Custom(value.into())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/executor/src/simulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn simulate(
match tx_info {
Ok(tx_info) => {
if let Some(revert_error) = tx_info.revert_error {
tracing::info!(%revert_error, "Transaction reverted");
tracing::trace!(%revert_error, "Transaction reverted");
return Err(CallError::Reverted(revert_error));
}

Expand Down

0 comments on commit 750c66b

Please sign in to comment.