From 5d77727cd3ba5f4d84643fee1873f03656310b4d Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 11 Dec 2024 10:14:56 -0600 Subject: [PATCH] fix(tracer): adds vm error to flatCallTracer error field if exists (#3374) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ - Updates `flatCallTracer` error to include vm error if it exists ## Why ❔ - MM has requested that if an error exists we should populate within `flatCallTracer` as this is what others do, prior to this PR it was only revert_reason introduced here: https://github.com/matter-labs/zksync-era/pull/3306. However, if we have a vm error the error field is not populated as seen in this tx: `0x6c85bf34666dcdaa885f2bc6e95186029d2b25f2a3bbdff21c36878e2d4a19ed` which failed due to a vm panic. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --- .../node/api_server/src/web3/namespaces/debug.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/node/api_server/src/web3/namespaces/debug.rs b/core/node/api_server/src/web3/namespaces/debug.rs index d96c1e659541..8e72f5b45991 100644 --- a/core/node/api_server/src/web3/namespaces/debug.rs +++ b/core/node/api_server/src/web3/namespaces/debug.rs @@ -96,16 +96,22 @@ impl DebugNamespace { CallType::NearCall => unreachable!("We have to filter our near calls before"), }; - let (result, error) = if let Some(error) = call.revert_reason { - (None, Some(error)) - } else { - ( + let (result, error) = match (call.revert_reason, call.error) { + (Some(revert_reason), _) => { + // If revert_reason exists, it takes priority over VM error + (None, Some(revert_reason)) + } + (None, Some(vm_error)) => { + // If no revert_reason but VM error exists + (None, Some(vm_error)) + } + (None, None) => ( Some(CallResult { output: web3::Bytes::from(call.output), gas_used: U256::from(call.gas_used), }), None, - ) + ), }; calls.push(DebugCallFlat {