Skip to content

Commit

Permalink
fix(tracer): Add error to flat tracer (#3306)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] 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 <[email protected]>
  • Loading branch information
Deniallugo authored Nov 19, 2024
1 parent 8b62434 commit 7c93c47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/lib/types/src/debug_flat_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct DebugCallFlat {
pub action: Action,
pub result: Option<CallResult>,
pub subtraces: usize,
pub error: Option<String>,
pub trace_address: Vec<usize>,
pub transaction_position: usize,
pub transaction_hash: H256,
Expand Down
16 changes: 10 additions & 6 deletions core/node/api_server/src/web3/namespaces/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit 7c93c47

Please sign in to comment.