From 7d351600b6f345ab90aaa0bf0abbce721cd1c682 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Thu, 22 Aug 2024 15:19:39 +0000 Subject: [PATCH] fix call flat receipt Signed-off-by: jsvisa --- eth/tracers/native/call_flat.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/eth/tracers/native/call_flat.go b/eth/tracers/native/call_flat.go index 9d7d2d96c8..43860f0af5 100644 --- a/eth/tracers/native/call_flat.go +++ b/eth/tracers/native/call_flat.go @@ -211,15 +211,18 @@ func (t *flatCallTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction } func (t *flatCallTracer) OnTxEnd(receipt *types.Receipt, err error) { - t.ctx = &tracers.Context{ - BlockHash: receipt.BlockHash, - BlockNumber: receipt.BlockNumber, - TxIndex: int(receipt.TransactionIndex), - TxHash: receipt.TxHash, - } if t.interrupt.Load() { return } + // Set the context for the tracer only if receipt is available and no error occured + if err == nil && receipt != nil { + t.ctx = &tracers.Context{ + BlockHash: receipt.BlockHash, + BlockNumber: receipt.BlockNumber, + TxIndex: int(receipt.TransactionIndex), + TxHash: receipt.TxHash, + } + } t.tracer.OnTxEnd(receipt, err) }