Skip to content

Commit

Permalink
Merge pull request #6362 from onflow/ramtin/evm-expose-metrics-report…
Browse files Browse the repository at this point in the history
…er-to-system-transaction

[FVM] Let the system transaction report metrics
  • Loading branch information
ramtinms authored Aug 19, 2024
2 parents 440ebff + ea3076d commit 6701e9e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions engine/execution/computation/computer/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type blockComputer struct {
maxConcurrency int
}

func SystemChunkContext(vmCtx fvm.Context) fvm.Context {
func SystemChunkContext(vmCtx fvm.Context, metrics module.ExecutionMetrics) fvm.Context {
return fvm.NewContextFromParent(
vmCtx,
fvm.WithContractDeploymentRestricted(false),
Expand All @@ -131,6 +131,7 @@ func SystemChunkContext(vmCtx fvm.Context) fvm.Context {
fvm.WithMemoryAndInteractionLimitsDisabled(),
// only the system transaction is allowed to call the block entropy provider
fvm.WithRandomSourceHistoryCallAllowed(true),
fvm.WithMetricsReporter(metrics),
)
}

Expand Down Expand Up @@ -158,7 +159,7 @@ func NewBlockComputer(
return nil, fmt.Errorf("program cache writes are not allowed in scripts on Execution nodes")
}

systemChunkCtx := SystemChunkContext(vmCtx)
systemChunkCtx := SystemChunkContext(vmCtx, metrics)
vmCtx = fvm.NewContextFromParent(
vmCtx,
fvm.WithMetricsReporter(metrics),
Expand Down
12 changes: 12 additions & 0 deletions engine/execution/computation/computer/computer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,18 @@ func Test_ExecutingSystemCollection(t *testing.T) {
mock.Anything).
Return(nil)

metrics.On("RuntimeTransactionParsed", mock.Anything)
metrics.On("RuntimeTransactionProgramsCacheMiss")
metrics.On("RuntimeTransactionProgramsCacheHit")
metrics.On("RuntimeTransactionChecked", mock.Anything)
metrics.On("RuntimeTransactionInterpreted", mock.Anything)

metrics.On("EVMBlockExecuted",
mock.Anything,
mock.Anything,
mock.Anything,
)

bservice := requesterunit.MockBlobService(blockstore.NewBlockstore(dssync.MutexWrap(datastore.NewMapDatastore())))
trackerStorage := mocktracker.NewMockStorage()

Expand Down
3 changes: 2 additions & 1 deletion module/chunks/chunkVerifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/onflow/flow-go/model/verification"
"github.com/onflow/flow-go/module/executiondatasync/execution_data"
"github.com/onflow/flow-go/module/executiondatasync/provider"
"github.com/onflow/flow-go/module/metrics"
)

// ChunkVerifier is a verifier based on the current definitions of the flow network
Expand All @@ -36,7 +37,7 @@ func NewChunkVerifier(vm fvm.VM, vmCtx fvm.Context, logger zerolog.Logger) *Chun
return &ChunkVerifier{
vm: vm,
vmCtx: vmCtx,
systemChunkCtx: computer.SystemChunkContext(vmCtx),
systemChunkCtx: computer.SystemChunkContext(vmCtx, metrics.NewNoopCollector()),
logger: logger.With().Str("component", "chunk_verifier").Logger(),
}
}
Expand Down

0 comments on commit 6701e9e

Please sign in to comment.