Skip to content

Commit 5fccb89

Browse files
Merge pull request #7780 from onflow/janez/integrate-cadence-metering-changes
Update to Cadence v1.7.0-preview.2
2 parents 0411850 + 0247f99 commit 5fccb89

File tree

29 files changed

+446
-483
lines changed

29 files changed

+446
-483
lines changed

cmd/execution_builder.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,13 @@ func (exeNode *ExecutionNode) LoadProviderEngine(
572572
node.FvmOptions...,
573573
)
574574

575-
opts = append(opts, computation.DefaultFVMOptions(
576-
node.RootChainID,
577-
exeNode.exeConf.computationConfig.CadenceTracing,
578-
exeNode.exeConf.computationConfig.ExtensiveTracing,
579-
exeNode.exeConf.scheduleCallbacksEnabled)...)
575+
opts = append(opts,
576+
computation.DefaultFVMOptions(
577+
node.RootChainID,
578+
exeNode.exeConf.computationConfig.ExtensiveTracing,
579+
exeNode.exeConf.scheduleCallbacksEnabled,
580+
)...,
581+
)
580582

581583
vmCtx := fvm.NewContext(opts...)
582584

cmd/execution_config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) {
9696
flags.UintVar(&exeConf.computationConfig.DerivedDataCacheSize, "cadence-execution-cache", derived.DefaultDerivedDataCacheSize,
9797
"cache size for Cadence execution")
9898
flags.BoolVar(&exeConf.computationConfig.ExtensiveTracing, "extensive-tracing", false, "adds high-overhead tracing to execution")
99-
flags.BoolVar(&exeConf.computationConfig.CadenceTracing, "cadence-tracing", false, "enables cadence runtime level tracing")
10099
flags.IntVar(&exeConf.computationConfig.MaxConcurrency, "computer-max-concurrency", 1, "set to greater than 1 to enable concurrent transaction execution")
101100
flags.StringVar(&exeConf.chunkDataPackDir, "chunk-data-pack-dir", filepath.Join(datadir, "chunk_data_packs"), "directory to use for storing chunk data packs")
102101
flags.StringVar(&exeConf.chunkDataPackCheckpointsDir, "chunk-data-pack-checkpoints-dir", filepath.Join(datadir, "chunk_data_packs_checkpoints_dir"), "directory to use storing chunk data packs pebble database checkpoints for querying while the node is running")

cmd/util/cmd/run-script/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func run(*cobra.Command, []string) {
139139
registersByAccount.AccountCount(),
140140
)
141141

142-
options := computation.DefaultFVMOptions(chainID, false, false, false)
142+
options := computation.DefaultFVMOptions(chainID, false, false)
143143
options = append(
144144
options,
145145
fvm.WithContractDeploymentRestricted(false),

cmd/util/ledger/migrations/migrator_runtime.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ func NewInterpreterMigrationRuntime(
182182
runtime.NewCodesAndPrograms(),
183183
basicMigrationRuntime.Storage,
184184
nil,
185+
nil,
186+
nil,
185187
)
186188

187189
inter, err := interpreter.NewInterpreter(

cmd/util/ledger/migrations/transaction_migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func NewTransactionBasedMigration(
1919
) RegistersMigration {
2020
return func(registersByAccount *registers.ByAccount) error {
2121

22-
options := computation.DefaultFVMOptions(chainID, false, false, false)
22+
options := computation.DefaultFVMOptions(chainID, false, false)
2323
options = append(options,
2424
fvm.WithContractDeploymentRestricted(false),
2525
fvm.WithContractRemovalRestricted(false),

cmd/verification_builder.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,14 @@ func (v *VerificationNodeBuilder) LoadComponentsAndModules() {
213213
)
214214

215215
// TODO(JanezP): cleanup creation of fvm context github.com/onflow/flow-go/issues/5249
216-
fvmOptions = append(fvmOptions, computation.DefaultFVMOptions(node.RootChainID, false, false, v.verConf.scheduleCallbacksEnabled)...)
216+
fvmOptions = append(
217+
fvmOptions,
218+
computation.DefaultFVMOptions(
219+
node.RootChainID,
220+
false,
221+
v.verConf.scheduleCallbacksEnabled,
222+
)...,
223+
)
217224
vmCtx := fvm.NewContext(fvmOptions...)
218225

219226
chunkVerifier := chunks.NewChunkVerifier(vm, vmCtx, node.Logger)

engine/execution/computation/manager.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ type ComputationManager interface {
6262

6363
type ComputationConfig struct {
6464
query.QueryConfig
65-
CadenceTracing bool
6665
ExtensiveTracing bool
6766
DerivedDataCacheSize uint
6867
MaxConcurrency int
@@ -107,7 +106,7 @@ func New(
107106
}
108107

109108
chainID := vmCtx.Chain.ChainID()
110-
options := DefaultFVMOptions(chainID, params.CadenceTracing, params.ExtensiveTracing, vmCtx.ScheduleCallbacksEnabled)
109+
options := DefaultFVMOptions(chainID, params.ExtensiveTracing, vmCtx.ScheduleCallbacksEnabled)
111110
vmCtx = fvm.NewContextFromParent(vmCtx, options...)
112111

113112
blockComputer, err := computer.NewBlockComputer(
@@ -224,16 +223,15 @@ func (e *Manager) QueryExecutor() query.Executor {
224223
return e.queryExecutor
225224
}
226225

227-
func DefaultFVMOptions(chainID flow.ChainID, cadenceTracing bool, extensiveTracing bool, scheduleCallbacksEnabled bool) []fvm.Option {
226+
func DefaultFVMOptions(chainID flow.ChainID, extensiveTracing bool, scheduleCallbacksEnabled bool) []fvm.Option {
228227
options := []fvm.Option{
229228
fvm.WithChain(chainID.Chain()),
230229
fvm.WithReusableCadenceRuntimePool(
231230
reusableRuntime.NewReusableCadenceRuntimePool(
232231
ReusableCadenceRuntimePoolSize,
233-
runtime.Config{
234-
TracingEnabled: cadenceTracing,
235-
},
236-
)),
232+
runtime.Config{},
233+
),
234+
),
237235
fvm.WithEVMEnabled(true),
238236
fvm.WithScheduleCallbacksEnabled(scheduleCallbacksEnabled),
239237
}

engine/verification/verifier/verifiers.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,14 @@ func makeVerifier(
333333
)
334334

335335
// TODO(JanezP): cleanup creation of fvm context github.com/onflow/flow-go/issues/5249
336-
fvmOptions = append(fvmOptions, computation.DefaultFVMOptions(chainID, false, false, true)...)
336+
fvmOptions = append(
337+
fvmOptions,
338+
computation.DefaultFVMOptions(
339+
chainID,
340+
false,
341+
true,
342+
)...,
343+
)
337344
vmCtx := fvm.NewContext(fvmOptions...)
338345

339346
chunkVerifier := chunks.NewChunkVerifier(vm, vmCtx, logger)

fvm/environment/meter.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/onflow/cadence/common"
7-
"github.com/onflow/cadence/runtime"
87

98
"github.com/onflow/flow-go/fvm/errors"
109
"github.com/onflow/flow-go/fvm/meter"
@@ -71,7 +70,10 @@ var MainnetExecutionEffortWeights = meter.ExecutionEffortWeights{
7170
}
7271

7372
type Meter interface {
74-
runtime.MeterInterface
73+
common.Gauge
74+
75+
ComputationUsed() (uint64, error)
76+
MemoryUsed() (uint64, error)
7577

7678
ComputationIntensities() meter.MeteredComputationIntensities
7779
ComputationAvailable(common.ComputationUsage) bool

fvm/environment/mock/environment.go

Lines changed: 0 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)