From 295caaf5a529d9220b5b3113867d709dd2ec8461 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Mon, 23 Sep 2024 18:11:05 +0300 Subject: [PATCH] Run tracing hooks OnTxStart, OnTxEnd for DryRunTransaction --- fvm/evm/emulator/emulator.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fvm/evm/emulator/emulator.go b/fvm/evm/emulator/emulator.go index 16f45e500ad..53b247a1fa4 100644 --- a/fvm/evm/emulator/emulator.go +++ b/fvm/evm/emulator/emulator.go @@ -283,6 +283,11 @@ func (bl *BlockView) DryRunTransaction( // we need to skip nonce check for dry run msg.SkipAccountChecks = true + // 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) + } + // return without committing the state txResult, err = proc.run(msg, tx.Hash(), tx.Type()) if txResult.Successful() { @@ -306,6 +311,13 @@ func (bl *BlockView) DryRunTransaction( txResult.GasConsumed += txResult.GasRefund } + // call tracer on tx end + if proc.evm.Config.Tracer != nil && + proc.evm.Config.Tracer.OnTxEnd != nil && + txResult != nil { + proc.evm.Config.Tracer.OnTxEnd(txResult.Receipt(), txResult.ValidationError) + } + return txResult, err }