Skip to content

Commit f5e76ea

Browse files
gzliudanholimans1na
authored
eth/tracers: avoid panic in state test runner ethereum#30332 (#1485)
Make tracers more robust by handling `nil` receipt as input. Also pass in a receipt with gas used in the state test runner. Closes ethereum#30117. --------- Co-authored-by: Martin HS <[email protected]> Co-authored-by: Sina Mahmoodi <[email protected]>
1 parent 1597be6 commit f5e76ea

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

eth/tracers/js/goja.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ func (t *jsTracer) OnTxEnd(receipt *types.Receipt, err error) {
274274
}
275275
return
276276
}
277-
t.ctx["gasUsed"] = t.vm.ToValue(receipt.GasUsed)
277+
if receipt != nil {
278+
t.ctx["gasUsed"] = t.vm.ToValue(receipt.GasUsed)
279+
}
278280
}
279281

280282
// onStart implements the Tracer interface to initialize the tracing operation.

eth/tracers/logger/logger.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error) {
268268
}
269269
return
270270
}
271-
l.usedGas = receipt.GasUsed
271+
if receipt != nil {
272+
l.usedGas = receipt.GasUsed
273+
}
272274
}
273275

274276
// StructLogs returns the captured log entries.

eth/tracers/native/call.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ func (t *callTracer) OnTxEnd(receipt *types.Receipt, err error) {
225225
if err != nil {
226226
return
227227
}
228-
t.callstack[0].GasUsed = receipt.GasUsed
228+
if receipt != nil {
229+
t.callstack[0].GasUsed = receipt.GasUsed
230+
}
229231
if t.config.WithLog {
230232
// Logs are not emitted when the call fails
231233
clearFailedLogs(&t.callstack[0], false)

0 commit comments

Comments
 (0)