Skip to content

Commit 950c08d

Browse files
committed
fix setting execution effort weights for computation profiling
1 parent 1310af4 commit 950c08d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

emulator/blockchain.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,13 @@ func (conf config) GetServiceKey() ServiceKey {
446446
return serviceKey
447447
}
448448

449+
func (conf config) EffectiveExecutionEffortWeights() meter.ExecutionEffortWeights {
450+
if conf.ExecutionEffortWeights != nil {
451+
return conf.ExecutionEffortWeights
452+
}
453+
return environment.MainnetExecutionEffortWeights
454+
}
455+
449456
const defaultGenesisTokenSupply = "1000000000.0"
450457

451458
const defaultScriptGasLimit = 100000
@@ -641,11 +648,9 @@ func configureFVM(blockchain *Blockchain, conf config, blocks *blocks) (*fvm.Vir
641648
}).
642649
Level(zerolog.DebugLevel)
643650

644-
if conf.ExecutionEffortWeights != nil &&
645-
conf.ComputationProfile != nil {
646-
647-
conf.ComputationProfile.
648-
WithComputationWeights(conf.ExecutionEffortWeights)
651+
if conf.ComputationProfile != nil {
652+
executionEffortWeights := conf.EffectiveExecutionEffortWeights()
653+
conf.ComputationProfile.WithComputationWeights(executionEffortWeights)
649654
}
650655

651656
runtimeConfig := runtime.Config{
@@ -849,16 +854,11 @@ func configureBootstrapProcedure(
849854
fvm.WithTransactionFee(fvm.DefaultTransactionFees),
850855
fvm.WithExecutionMemoryLimit(math.MaxUint32),
851856
fvm.WithExecutionMemoryWeights(meter.DefaultMemoryWeights),
852-
fvm.WithExecutionEffortWeights(environment.MainnetExecutionEffortWeights),
857+
fvm.WithExecutionEffortWeights(conf.EffectiveExecutionEffortWeights()),
853858
fvm.WithSetupVMBridgeEnabled(cadence.NewBool(conf.SetupVMBridgeEnabled)),
854859
fvm.WithSetupEVMEnabled(cadence.NewBool(conf.SetupEVMEnabled)),
855860
)
856861

857-
if conf.ExecutionEffortWeights != nil {
858-
options = append(options,
859-
fvm.WithExecutionEffortWeights(conf.ExecutionEffortWeights),
860-
)
861-
}
862862
if conf.StorageLimitEnabled {
863863
options = append(options,
864864
fvm.WithAccountCreationFee(conf.MinimumStorageReservation),

0 commit comments

Comments
 (0)