From 7c93c47916845a90fc5a092e1465567aae611307 Mon Sep 17 00:00:00 2001 From: Danil Date: Tue, 19 Nov 2024 13:00:41 +0100 Subject: [PATCH] fix(tracer): Add error to flat tracer (#3306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ ## Why ❔ ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --------- Signed-off-by: Danil --- core/lib/types/src/debug_flat_call.rs | 1 + .../node/api_server/src/web3/namespaces/debug.rs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/lib/types/src/debug_flat_call.rs b/core/lib/types/src/debug_flat_call.rs index 5809026e521c..3488b0e5b42c 100644 --- a/core/lib/types/src/debug_flat_call.rs +++ b/core/lib/types/src/debug_flat_call.rs @@ -16,6 +16,7 @@ pub struct DebugCallFlat { pub action: Action, pub result: Option, pub subtraces: usize, + pub error: Option, pub trace_address: Vec, pub transaction_position: usize, pub transaction_hash: H256, diff --git a/core/node/api_server/src/web3/namespaces/debug.rs b/core/node/api_server/src/web3/namespaces/debug.rs index 726f35ac29a9..4fd32c1b5223 100644 --- a/core/node/api_server/src/web3/namespaces/debug.rs +++ b/core/node/api_server/src/web3/namespaces/debug.rs @@ -96,13 +96,16 @@ impl DebugNamespace { CallType::NearCall => unreachable!("We have to filter our near calls before"), }; - let result = if call.error.is_none() { - Some(CallResult { - output: web3::Bytes::from(call.output), - gas_used: U256::from(call.gas_used), - }) + let (result, error) = if let Some(error) = call.revert_reason { + (None, Some(error)) } else { - None + ( + Some(CallResult { + output: web3::Bytes::from(call.output), + gas_used: U256::from(call.gas_used), + }), + None, + ) }; calls.push(DebugCallFlat { @@ -116,6 +119,7 @@ impl DebugNamespace { }, result, subtraces, + error, trace_address: trace_address.clone(), // Clone the current trace address transaction_position: meta.index_in_block, transaction_hash: meta.tx_hash,