From 0099e5e2b8d5c2bfefd81d8872a3ba4ea9f57ad1 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Wed, 6 Nov 2024 10:33:58 +0800 Subject: [PATCH] tracers/callflat: fix the nil receipt crash Signed-off-by: jsvisa --- eth/tracers/native/call_flat.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/eth/tracers/native/call_flat.go b/eth/tracers/native/call_flat.go index 4f1e6e5e0a..36decb0cf7 100644 --- a/eth/tracers/native/call_flat.go +++ b/eth/tracers/native/call_flat.go @@ -224,12 +224,17 @@ func (t *flatCallTracer) OnTxEnd(receipt *types.Receipt, err error) { if t.interrupt.Load() { return } - // Always set context with receipt data. - t.ctx = &tracers.Context{ - BlockHash: receipt.BlockHash, - BlockNumber: receipt.BlockNumber, - TxHash: receipt.TxHash, - TxIndex: int(receipt.TransactionIndex), + if receipt != nil { + // Reset context with receipt data. + t.ctx = &tracers.Context{ + BlockHash: receipt.BlockHash, + BlockNumber: receipt.BlockNumber, + TxHash: receipt.TxHash, + TxIndex: int(receipt.TransactionIndex), + } + } else { + // Set to nil if receipt is nil. + t.ctx = nil } t.tracer.OnTxEnd(receipt, err) }