From 9473d65e4ef33f069cbe04b9eecc4be3b6a32922 Mon Sep 17 00:00:00 2001 From: Krisztian Kovacs Date: Wed, 15 Nov 2023 09:48:04 +0100 Subject: [PATCH 1/3] fix(executor): map VM errors to custom errors Otherwise we don't properly return those to the JSON-RPC client and log them on WARN log level instead. None of these errors (apart from the anyhow::Error mapping) are internal issues but instead errors that were encountered during contract execution. --- crates/executor/src/error.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/executor/src/error.rs b/crates/executor/src/error.rs index bef95aea50..973a500c9c 100644 --- a/crates/executor/src/error.rs +++ b/crates/executor/src/error.rs @@ -26,9 +26,9 @@ impl From 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)), } } } @@ -42,20 +42,23 @@ impl From for CallError { EntryPointExecutionError::PreExecutionError( PreExecutionError::UninitializedStorageAddress(_), ) => Self::ContractNotFound, - _ => Self::Internal(anyhow::anyhow!("Internal error: {}", e)), + _ => Self::Custom(anyhow::anyhow!("Execution error: {}", e)), } } } impl From 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 for CallError { fn from(value: starknet_api::StarknetApiError) -> Self { - Self::Internal(value.into()) + Self::Custom(value.into()) } } From 932c270c8cad616b7b0a16c6b98ab10b591ecc86 Mon Sep 17 00:00:00 2001 From: Krisztian Kovacs Date: Wed, 15 Nov 2023 09:51:41 +0100 Subject: [PATCH 2/3] chore: update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7f62859d3..e1ae851ec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 1016e348ec0b6df5354bd8e67b94d8ba9a27775d Mon Sep 17 00:00:00 2001 From: Krisztian Kovacs Date: Wed, 15 Nov 2023 12:29:40 +0100 Subject: [PATCH 3/3] fix(executor): log reverted simulated transactions on TRACE level So that we don't litter logs with these errors. --- crates/executor/src/simulate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/executor/src/simulate.rs b/crates/executor/src/simulate.rs index 40fbb7cb6a..14190c460a 100644 --- a/crates/executor/src/simulate.rs +++ b/crates/executor/src/simulate.rs @@ -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)); }