From c8592a42a8f2f5e99c0befca8e0f82cf129503e9 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Fri, 25 Apr 2025 11:49:58 +0200 Subject: [PATCH] fix negative evm --- eth/tracers/live/perf.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eth/tracers/live/perf.go b/eth/tracers/live/perf.go index 7535e890bc..51c6861987 100644 --- a/eth/tracers/live/perf.go +++ b/eth/tracers/live/perf.go @@ -120,6 +120,13 @@ func (t *perfTracer) OnBlockStart(event tracing.BlockEvent) { func (t *perfTracer) OnTxStart(vm *tracing.VMContext, tx *types.Transaction, from common.Address) { t.txStartTime = time.Now() t.statedb = vm.StateDB + + // The accumulated measurements include IO performed before any txs were executed. + if t.txIndex == 0 { + initialIO := t.statedb.GetAccumulatedIOMeasurements() + t.prevAccountReads = initialIO.AccountReads + t.prevStorageReads = initialIO.StorageReads + } } func (t *perfTracer) OnTxEnd(receipt *types.Receipt, err error) { @@ -131,7 +138,7 @@ func (t *perfTracer) OnTxEnd(receipt *types.Receipt, err error) { evmTime time.Duration ) if ioTime > totalTime { - log.Error("PerfTracer: IO time exceeds total time", "ioTime", ioTime, "totalTime", totalTime) + log.Error("PerfTracer: IO time exceeds total time", "ioTime", ioTime, "totalTime", totalTime, "txIdx", t.txIndex) } else { evmTime = totalTime - ioTime }