Skip to content

Commit

Permalink
Merge branch 'master' into bastian/evm-setup-heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Jul 24, 2024
2 parents 094d4fc + bb0874e commit 9ad5f9c
Show file tree
Hide file tree
Showing 4 changed files with 1,048 additions and 1 deletion.
37 changes: 37 additions & 0 deletions cmd/access/node_builder/access_node_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
stateSyncCommands "github.com/onflow/flow-go/admin/commands/state_synchronization"
storageCommands "github.com/onflow/flow-go/admin/commands/storage"
"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/build"
"github.com/onflow/flow-go/consensus"
"github.com/onflow/flow-go/consensus/hotstuff"
"github.com/onflow/flow-go/consensus/hotstuff/committees"
Expand All @@ -52,6 +53,7 @@ import (
followereng "github.com/onflow/flow-go/engine/common/follower"
"github.com/onflow/flow-go/engine/common/requester"
synceng "github.com/onflow/flow-go/engine/common/synchronization"
"github.com/onflow/flow-go/engine/common/version"
"github.com/onflow/flow-go/engine/execution/computation/query"
"github.com/onflow/flow-go/fvm/storage/derived"
"github.com/onflow/flow-go/ledger"
Expand Down Expand Up @@ -164,6 +166,7 @@ type AccessNodeConfig struct {
registerCacheSize uint
programCacheSize uint
checkPayerBalance bool
versionControlEnabled bool
}

type PublicNetworkConfig struct {
Expand Down Expand Up @@ -264,6 +267,7 @@ func DefaultAccessNodeConfig() *AccessNodeConfig {
registerCacheSize: 0,
programCacheSize: 0,
checkPayerBalance: false,
versionControlEnabled: true,
}
}

Expand Down Expand Up @@ -311,6 +315,7 @@ type FlowAccessNodeBuilder struct {
ExecutionDataPruner *pruner.Pruner
ExecutionDataDatastore *badger.Datastore
ExecutionDataTracker tracker.Storage
versionControl *version.VersionControl

// The sync engine participants provider is the libp2p peer store for the access node
// which is not available until after the network has started.
Expand Down Expand Up @@ -1226,6 +1231,10 @@ func (builder *FlowAccessNodeBuilder) extraFlags() {
"circuit-breaker-max-requests",
defaultConfig.rpcConf.BackendConfig.CircuitBreakerConfig.MaxRequests,
"maximum number of requests to check if connection restored after timeout. Default value is 1")
flags.BoolVar(&builder.versionControlEnabled,
"version-control-enabled",
defaultConfig.versionControlEnabled,
"whether to enable the version control feature. Default value is true")
// ExecutionDataRequester config
flags.BoolVar(&builder.executionDataSyncEnabled,
"execution-data-sync-enabled",
Expand Down Expand Up @@ -1937,6 +1946,34 @@ func (builder *FlowAccessNodeBuilder) Build() (cmd.Node, error) {
return builder.RequestEng, nil
})

if builder.versionControlEnabled {
builder.Component("version control", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
nodeVersion, err := build.Semver()
if err != nil {
return nil, fmt.Errorf("could not load node version for version control. "+
"version (%s) is not semver compliant: %w. Make sure a valid semantic version is provided in the VERSION environment variable", build.Version(), err)
}

versionControl, err := version.NewVersionControl(
builder.Logger,
node.Storage.VersionBeacons,
nodeVersion,
builder.SealedRootBlock.Header.Height,
builder.LastFinalizedHeader.Height,
)
if err != nil {
return nil, fmt.Errorf("could not create version control: %w", err)
}

// VersionControl needs to consume BlockFinalized events.
node.ProtocolEvents.AddConsumer(versionControl)

builder.versionControl = versionControl

return versionControl, nil
})
}

if builder.supportsObserver {
builder.Component("public sync request handler", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
syncRequestHandler, err := synceng.NewRequestHandlerEngine(
Expand Down
37 changes: 36 additions & 1 deletion cmd/observer/node_builder/observer_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/onflow/flow-go/admin/commands"
stateSyncCommands "github.com/onflow/flow-go/admin/commands/state_synchronization"
"github.com/onflow/flow-go/cmd"
"github.com/onflow/flow-go/cmd/build"
"github.com/onflow/flow-go/consensus"
"github.com/onflow/flow-go/consensus/hotstuff"
"github.com/onflow/flow-go/consensus/hotstuff/committees"
Expand All @@ -51,6 +52,7 @@ import (
"github.com/onflow/flow-go/engine/access/subscription"
"github.com/onflow/flow-go/engine/common/follower"
synceng "github.com/onflow/flow-go/engine/common/synchronization"
"github.com/onflow/flow-go/engine/common/version"
"github.com/onflow/flow-go/engine/execution/computation/query"
"github.com/onflow/flow-go/fvm/storage/derived"
"github.com/onflow/flow-go/ledger"
Expand Down Expand Up @@ -155,6 +157,7 @@ type ObserverServiceConfig struct {
executionDataPrunerHeightRangeTarget uint64
executionDataPrunerThreshold uint64
localServiceAPIEnabled bool
versionControlEnabled bool
executionDataDir string
executionDataStartHeight uint64
executionDataConfig edrequester.ExecutionDataConfig
Expand Down Expand Up @@ -227,6 +230,7 @@ func DefaultObserverServiceConfig() *ObserverServiceConfig {
executionDataPrunerHeightRangeTarget: 0,
executionDataPrunerThreshold: 100_000,
localServiceAPIEnabled: false,
versionControlEnabled: true,
executionDataDir: filepath.Join(homedir, ".flow", "execution_data"),
executionDataStartHeight: 0,
executionDataConfig: edrequester.ExecutionDataConfig{
Expand Down Expand Up @@ -267,6 +271,7 @@ type ObserverServiceBuilder struct {
ExecutionIndexerCore *indexer.IndexerCore
TxResultsIndex *index.TransactionResultsIndex
IndexerDependencies *cmd.DependencyList
versionControl *version.VersionControl

ExecutionDataDownloader execution_data.Downloader
ExecutionDataRequester state_synchronization.ExecutionDataRequester
Expand Down Expand Up @@ -664,6 +669,10 @@ func (builder *ObserverServiceBuilder) extraFlags() {
"execution-data-indexing-enabled",
defaultConfig.executionDataIndexingEnabled,
"whether to enable the execution data indexing")
flags.BoolVar(&builder.versionControlEnabled,
"version-control-enabled",
defaultConfig.versionControlEnabled,
"whether to enable the version control feature. Default value is true")
flags.BoolVar(&builder.localServiceAPIEnabled, "local-service-api-enabled", defaultConfig.localServiceAPIEnabled, "whether to use local indexed data for api queries")
flags.StringVar(&builder.registersDBPath, "execution-state-dir", defaultConfig.registersDBPath, "directory to use for execution-state database")
flags.StringVar(&builder.checkpointFile, "execution-state-checkpoint", defaultConfig.checkpointFile, "execution-state checkpoint file")
Expand Down Expand Up @@ -1685,7 +1694,6 @@ func (builder *ObserverServiceBuilder) enqueueConnectWithStakedAN() {
}

func (builder *ObserverServiceBuilder) enqueueRPCServer() {

builder.Module("transaction metrics", func(node *cmd.NodeConfig) error {
var err error
builder.TransactionTimings, err = stdmap.NewTransactionTimings(1500 * 300) // assume 1500 TPS * 300 seconds
Expand Down Expand Up @@ -1783,6 +1791,33 @@ func (builder *ObserverServiceBuilder) enqueueRPCServer() {
builder.ScriptExecutor = backend.NewScriptExecutor(builder.Logger, builder.scriptExecMinBlock, builder.scriptExecMaxBlock)
return nil
})
if builder.versionControlEnabled {
builder.Component("version control", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
nodeVersion, err := build.Semver()
if err != nil {
return nil, fmt.Errorf("could not load node version for version control. "+
"version (%s) is not semver compliant: %w. Make sure a valid semantic version is provided in the VERSION environment variable", build.Version(), err)
}

versionControl, err := version.NewVersionControl(
builder.Logger,
node.Storage.VersionBeacons,
nodeVersion,
builder.SealedRootBlock.Header.Height,
builder.LastFinalizedHeader.Height,
)
if err != nil {
return nil, fmt.Errorf("could not create version control: %w", err)
}

// VersionControl needs to consume BlockFinalized events.
node.ProtocolEvents.AddConsumer(versionControl)

builder.versionControl = versionControl

return versionControl, nil
})
}
builder.Component("RPC engine", func(node *cmd.NodeConfig) (module.ReadyDoneAware, error) {
accessMetrics := builder.AccessMetrics
config := builder.rpcConf
Expand Down
Loading

0 comments on commit 9ad5f9c

Please sign in to comment.