Skip to content

Commit

Permalink
Merge branch 'master' into ramtin/evm-refactor-precompiled-call-tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
ramtinms authored Jul 22, 2024
2 parents 13ba5c9 + 8658ed9 commit 4612727
Show file tree
Hide file tree
Showing 25 changed files with 1,027 additions and 29 deletions.
2 changes: 2 additions & 0 deletions fvm/environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Environment interface {

Meter

MetricsReporter

// Runtime
BorrowCadenceRuntime() *reusableRuntime.ReusableCadenceRuntime
ReturnCadenceRuntime(*reusableRuntime.ReusableCadenceRuntime)
Expand Down
45 changes: 45 additions & 0 deletions fvm/environment/mock/environment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions fvm/environment/mock/evm_metrics_reporter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions fvm/environment/mock/metrics_reporter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions fvm/environment/mock/runtime_metrics_reporter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions fvm/environment/program_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ import (
"github.com/onflow/flow-go/module/trace"
)

// MetricsReporter captures and reports metrics to back to the execution
// MetricsReporter captures and reports EVM metrics to back to the execution
type EVMMetricsReporter interface {
SetNumberOfDeployedCOAs(count uint64)
EVMTransactionExecuted(gasUsed uint64, isDirectCall bool, failed bool)
EVMBlockExecuted(txCount int, totalGasUsed uint64, totalSupplyInFlow float64)
}

// RuntimeMetricsReporter captures and reports runtime metrics to back to the execution
// environment it is a setup passed to the context.
type MetricsReporter interface {
type RuntimeMetricsReporter interface {
RuntimeTransactionParsed(time.Duration)
RuntimeTransactionChecked(time.Duration)
RuntimeTransactionInterpreted(time.Duration)
Expand All @@ -23,9 +30,18 @@ type MetricsReporter interface {
RuntimeTransactionProgramsCacheHit()
}

// MetricsReporter captures and reports metrics to back to the execution
// environment it is a setup passed to the context.
type MetricsReporter interface {
EVMMetricsReporter
RuntimeMetricsReporter
}

// NoopMetricsReporter is a MetricReporter that does nothing.
type NoopMetricsReporter struct{}

var _ MetricsReporter = &NoopMetricsReporter{}

// RuntimeTransactionParsed is a noop
func (NoopMetricsReporter) RuntimeTransactionParsed(time.Duration) {}

Expand All @@ -44,6 +60,15 @@ func (NoopMetricsReporter) RuntimeTransactionProgramsCacheMiss() {}
// RuntimeTransactionProgramsCacheHit is a noop
func (NoopMetricsReporter) RuntimeTransactionProgramsCacheHit() {}

// SetNumberOfDeployedCOAs is a noop
func (NoopMetricsReporter) SetNumberOfDeployedCOAs(_ uint64) {}

// EVMTransactionExecuted is a noop
func (NoopMetricsReporter) EVMTransactionExecuted(_ uint64, _ bool, _ bool) {}

// EVMBlockExecuted is a noop
func (NoopMetricsReporter) EVMBlockExecuted(_ int, _ uint64, _ float64) {}

type ProgramLoggerParams struct {
zerolog.Logger

Expand Down
6 changes: 6 additions & 0 deletions fvm/environment/programs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,12 @@ func (m *metricsReporter) RuntimeTransactionInterpreted(duration time.Duration)

func (m *metricsReporter) RuntimeSetNumberOfAccounts(count uint64) {}

func (m *metricsReporter) SetNumberOfDeployedCOAs(count uint64) {}

func (m *metricsReporter) EVMTransactionExecuted(_ uint64, _ bool, _ bool) {}

func (m *metricsReporter) EVMBlockExecuted(_ int, _ uint64, _ float64) {}

func (m *metricsReporter) RuntimeTransactionProgramsCacheMiss() {
m.CacheMisses++
}
Expand Down
20 changes: 20 additions & 0 deletions fvm/evm/backends/wrappedEnv.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,26 @@ func (we *WrappedEnvironment) StartChildSpan(
return we.env.StartChildSpan(name, options...)
}

func (we *WrappedEnvironment) SetNumberOfDeployedCOAs(count uint64) {
we.env.SetNumberOfDeployedCOAs(count)
}

func (we *WrappedEnvironment) EVMTransactionExecuted(
gasUsed uint64,
isDirectCall bool,
failed bool,
) {
we.env.EVMTransactionExecuted(gasUsed, isDirectCall, failed)
}

func (we *WrappedEnvironment) EVMBlockExecuted(
txCount int,
totalGasUsed uint64,
totalSupplyInFlow float64,
) {
we.env.EVMBlockExecuted(txCount, totalGasUsed, totalSupplyInFlow)
}

func handleEnvironmentError(err error) error {
if err == nil {
return nil
Expand Down
Loading

0 comments on commit 4612727

Please sign in to comment.