diff --git a/fvm/evm/emulator/emulator.go b/fvm/evm/emulator/emulator.go index a34a5c86c4e..097b88d667e 100644 --- a/fvm/evm/emulator/emulator.go +++ b/fvm/evm/emulator/emulator.go @@ -121,11 +121,16 @@ func (bl *BlockView) DirectCall(call *types.DirectCall) (res *types.Result, err // Call tx tracer if proc.evm.Config.Tracer != nil && proc.evm.Config.Tracer.OnTxStart != nil { proc.evm.Config.Tracer.OnTxStart(proc.evm.GetVMContext(), call.Transaction(), call.From.ToCommon()) - if proc.evm.Config.Tracer.OnTxEnd != nil { - defer func() { - proc.evm.Config.Tracer.OnTxEnd(res.Receipt(), err) - }() - } + defer func() { + if proc.evm.Config.Tracer.OnTxEnd != nil { + receipt := &gethTypes.Receipt{} + if res != nil { + receipt = res.Receipt() + } + proc.evm.Config.Tracer.OnTxEnd(receipt, err) + } + }() + } // re-route based on the sub type @@ -168,11 +173,16 @@ func (bl *BlockView) RunTransaction( // call tracer if proc.evm.Config.Tracer != nil && proc.evm.Config.Tracer.OnTxStart != nil { proc.evm.Config.Tracer.OnTxStart(proc.evm.GetVMContext(), tx, msg.From) - if proc.evm.Config.Tracer.OnTxEnd != nil { - defer func() { - proc.evm.Config.Tracer.OnTxEnd(result.Receipt(), err) - }() - } + defer func() { + if proc.evm.Config.Tracer.OnTxEnd != nil { + receipt := &gethTypes.Receipt{} + if result != nil { + receipt = result.Receipt() + } + proc.evm.Config.Tracer.OnTxEnd(receipt, err) + } + }() + } // run msg @@ -211,14 +221,19 @@ func (bl *BlockView) BatchRunTransactions(txs []*gethTypes.Transaction) ([]*type // call tracer if proc.evm.Config.Tracer != nil && proc.evm.Config.Tracer.OnTxStart != nil { proc.evm.Config.Tracer.OnTxStart(proc.evm.GetVMContext(), tx, msg.From) - if proc.evm.Config.Tracer.OnTxEnd != nil { - defer func() { + defer func() { + if proc.evm.Config.Tracer.OnTxEnd != nil { + receipt := &gethTypes.Receipt{} + if batchResults[i] != nil { + receipt = batchResults[i].Receipt() + } proc.evm.Config.Tracer.OnTxEnd( - batchResults[i].Receipt(), + receipt, err, ) - }() - } + } + }() + } // run msg