Expose IO measurements from statedb

This commit is contained in:
Sina Mahmoodi 2025-04-25 11:29:45 +02:00
parent 4278dab145
commit 0fc0b407f7
4 changed files with 38 additions and 0 deletions

View file

@ -1434,3 +1434,17 @@ func (s *StateDB) Witness() *stateless.Witness {
func (s *StateDB) AccessEvents() *AccessEvents {
return s.accessEvents
}
func (s *StateDB) GetAccumulatedIOMeasurements() *tracing.IOMeasurements {
return &tracing.IOMeasurements{
AccountReads: s.AccountReads,
AccountHashes: s.AccountHashes,
AccountUpdates: s.AccountUpdates,
AccountCommits: s.AccountCommits,
StorageReads: s.StorageReads,
StorageUpdates: s.StorageUpdates,
StorageCommits: s.StorageCommits,
SnapshotCommits: s.SnapshotCommits,
TrieDBCommits: s.TrieDBCommits,
}
}

View file

@ -276,3 +276,7 @@ func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) {
}
}
}
func (s *hookedStateDB) GetAccumulatedIOMeasurements() *tracing.IOMeasurements {
return s.inner.GetAccumulatedIOMeasurements()
}

View file

@ -26,6 +26,7 @@ package tracing
import (
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@ -55,6 +56,21 @@ type StateDB interface {
GetTransientState(common.Address, common.Hash) common.Hash
Exist(common.Address) bool
GetRefund() uint64
GetAccumulatedIOMeasurements() *IOMeasurements
}
// IOMeasurements is a struct that contains the measurements of
// the I/O operations performed by the statedb.
type IOMeasurements struct {
AccountReads time.Duration
AccountHashes time.Duration
AccountUpdates time.Duration
AccountCommits time.Duration
StorageReads time.Duration
StorageUpdates time.Duration
StorageCommits time.Duration
SnapshotCommits time.Duration
TrieDBCommits time.Duration
}
// VMContext provides the context for the EVM execution.

View file

@ -101,4 +101,8 @@ type StateDB interface {
// Finalise must be invoked at the end of a transaction
Finalise(bool)
// GetAccumulatedGasMeasurements returns measurements of IO operations that have
// been accumulated since the execution of the block started.
GetAccumulatedIOMeasurements() *tracing.IOMeasurements
}