Merge pull request #16 from primevprotocol/capture-run-time

feat: add runtime metric the vm interpreter's Run method
This commit is contained in:
mrekucci 2024-01-10 01:50:12 +04:00 committed by GitHub
commit 8d1650917d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -17,10 +17,20 @@
package vm
import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
)
const (
// vmInterpreterRunExecutionTime is the name of a metric to capture the
// elapsed execution time (in nanoseconds) of the vm interpreter's Run
// method.
vmInterpreterRunExecutionTime = "vm/interpreter_run_execution_time"
)
// Config are the configuration options for the Interpreter
@ -105,6 +115,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
// considered a revert-and-consume-all-gas operation except for
// ErrExecutionReverted which means revert-and-keep-gas-left.
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
if metrics.Enabled {
defer func(start time.Time) {
metrics.GetOrRegisterTimer(vmInterpreterRunExecutionTime, nil).UpdateSince(start)
}(time.Now())
}
// Increment the call depth which is restricted to 1024
in.evm.depth++
defer func() { in.evm.depth-- }()

View file

@ -79,6 +79,7 @@ services:
"eth*",
"chain*",
"clique*"
"vm*"
]
}
]
@ -120,6 +121,7 @@ services:
"eth*",
"chain*",
"clique*"
"vm*"
]
}
]
@ -158,6 +160,7 @@ services:
"eth*",
"chain*",
"clique*"
"vm*"
]
}
]