Skip to content

Commit 5d77727

Browse files
authored
fix(tracer): adds vm error to flatCallTracer error field if exists (#3374)
## 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) --> - Updates `flatCallTracer` error to include vm error if it exists ## 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. --> - 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: #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 <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [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`.
1 parent 51958f6 commit 5d77727

File tree

1 file changed

+11
-5
lines changed
  • core/node/api_server/src/web3/namespaces

1 file changed

+11
-5
lines changed

core/node/api_server/src/web3/namespaces/debug.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,22 @@ impl DebugNamespace {
9696
CallType::NearCall => unreachable!("We have to filter our near calls before"),
9797
};
9898

99-
let (result, error) = if let Some(error) = call.revert_reason {
100-
(None, Some(error))
101-
} else {
102-
(
99+
let (result, error) = match (call.revert_reason, call.error) {
100+
(Some(revert_reason), _) => {
101+
// If revert_reason exists, it takes priority over VM error
102+
(None, Some(revert_reason))
103+
}
104+
(None, Some(vm_error)) => {
105+
// If no revert_reason but VM error exists
106+
(None, Some(vm_error))
107+
}
108+
(None, None) => (
103109
Some(CallResult {
104110
output: web3::Bytes::from(call.output),
105111
gas_used: U256::from(call.gas_used),
106112
}),
107113
None,
108-
)
114+
),
109115
};
110116

111117
calls.push(DebugCallFlat {

0 commit comments

Comments
 (0)