Skip to content

Commit

Permalink
expose query executor and remove default config
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Gololicic committed Aug 31, 2023
1 parent 45aa47a commit 6e11157
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 44 deletions.
23 changes: 1 addition & 22 deletions cmd/execution_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
"github.com/onflow/flow-go/engine/execution/checker"
"github.com/onflow/flow-go/engine/execution/computation"
"github.com/onflow/flow-go/engine/execution/computation/committer"
"github.com/onflow/flow-go/engine/execution/computation/query"
"github.com/onflow/flow-go/engine/execution/ingestion"
"github.com/onflow/flow-go/engine/execution/ingestion/stop"
"github.com/onflow/flow-go/engine/execution/ingestion/uploader"
Expand All @@ -57,7 +56,6 @@ import (
"github.com/onflow/flow-go/engine/execution/state"
"github.com/onflow/flow-go/engine/execution/state/bootstrap"
"github.com/onflow/flow-go/fvm"
"github.com/onflow/flow-go/fvm/storage/derived"
"github.com/onflow/flow-go/fvm/storage/snapshot"
"github.com/onflow/flow-go/fvm/systemcontracts"
"github.com/onflow/flow-go/ledger/common/pathfinder"
Expand Down Expand Up @@ -903,30 +901,11 @@ func (exeNode *ExecutionNode) LoadIngestionEngine(

// create scripts engine for handling script execution
func (exeNode *ExecutionNode) LoadScriptsEngine(node *NodeConfig) (module.ReadyDoneAware, error) {
// for RPC to load it
vm := fvm.NewVirtualMachine()

options := computation.DefaultFVMOptions(node.RootChainID, false, false)
vmCtx := fvm.NewContext(options...)

derivedChainData, err := derived.NewDerivedChainData(derived.DefaultDerivedDataCacheSize)
if err != nil {
return nil, err
}

queryExecutor := query.NewQueryExecutor(
exeNode.exeConf.computationConfig.QueryConfig,
node.Logger,
metrics.NewExecutionCollector(node.Tracer),
vm,
vmCtx,
derivedChainData,
)

exeNode.scriptsEng = scripts.New(
node.Logger,
node.State,
queryExecutor,
exeNode.computationManager.QueryExecutor(),
exeNode.executionState,
)

Expand Down
43 changes: 21 additions & 22 deletions engine/execution/computation/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,25 @@ func New(
}

chainID := vmCtx.Chain.ChainID()
options := DefaultFVMOptions(chainID, params.CadenceTracing, params.ExtensiveTracing)
options := []fvm.Option{
fvm.WithReusableCadenceRuntimePool(
reusableRuntime.NewReusableCadenceRuntimePool(
ReusableCadenceRuntimePoolSize,
runtime.Config{
TracingEnabled: params.CadenceTracing,
AccountLinkingEnabled: true,
// Attachments are enabled everywhere except for Mainnet
AttachmentsEnabled: chainID != flow.Mainnet,
// Capability Controllers are enabled everywhere except for Mainnet
CapabilityControllersEnabled: chainID != flow.Mainnet,
},
)),
}

if params.ExtensiveTracing {
options = append(options, fvm.WithExtensiveTracing())
}

vmCtx = fvm.NewContextFromParent(vmCtx, options...)

blockComputer, err := computer.NewBlockComputer(
Expand Down Expand Up @@ -222,25 +240,6 @@ func (e *Manager) GetAccount(
snapshot)
}

func DefaultFVMOptions(chainID flow.ChainID, cadenceTracing bool, extensiveTracing bool) []fvm.Option {
options := []fvm.Option{
fvm.WithReusableCadenceRuntimePool(
reusableRuntime.NewReusableCadenceRuntimePool(
ReusableCadenceRuntimePoolSize,
runtime.Config{
TracingEnabled: cadenceTracing,
AccountLinkingEnabled: true,
// Attachments are enabled everywhere except for Mainnet
AttachmentsEnabled: chainID != flow.Mainnet,
// Capability Controllers are enabled everywhere except for Mainnet
CapabilityControllersEnabled: chainID != flow.Mainnet,
},
)),
}

if extensiveTracing {
options = append(options, fvm.WithExtensiveTracing())
}

return options
func (e *Manager) QueryExecutor() query.Executor {
return e.queryExecutor
}

0 comments on commit 6e11157

Please sign in to comment.