github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/cmd/execution_config.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "path/filepath" 6 "strings" 7 "time" 8 9 "github.com/spf13/pflag" 10 11 "github.com/onflow/flow-go/engine/common/provider" 12 "github.com/onflow/flow-go/engine/execution/computation/query" 13 exeprovider "github.com/onflow/flow-go/engine/execution/provider" 14 "github.com/onflow/flow-go/fvm" 15 "github.com/onflow/flow-go/model/flow" 16 "github.com/onflow/flow-go/module/mempool" 17 "github.com/onflow/flow-go/utils/grpcutils" 18 19 "github.com/onflow/flow-go/engine/execution/computation" 20 "github.com/onflow/flow-go/engine/execution/ingestion/stop" 21 "github.com/onflow/flow-go/engine/execution/rpc" 22 "github.com/onflow/flow-go/fvm/storage/derived" 23 storage "github.com/onflow/flow-go/storage/badger" 24 ) 25 26 // ExecutionConfig contains the configs for starting up execution nodes 27 type ExecutionConfig struct { 28 rpcConf rpc.Config 29 triedir string 30 executionDataDir string 31 registerDir string 32 mTrieCacheSize uint32 33 transactionResultsCacheSize uint 34 checkpointDistance uint 35 checkpointsToKeep uint 36 chunkDataPackDir string 37 chunkDataPackCacheSize uint 38 chunkDataPackRequestsCacheSize uint32 39 requestInterval time.Duration 40 extensiveLog bool 41 pauseExecution bool 42 chunkDataPackQueryTimeout time.Duration 43 chunkDataPackDeliveryTimeout time.Duration 44 enableBlockDataUpload bool 45 gcpBucketName string 46 s3BucketName string 47 apiRatelimits map[string]int 48 apiBurstlimits map[string]int 49 executionDataAllowedPeers string 50 executionDataPrunerHeightRangeTarget uint64 51 executionDataPrunerThreshold uint64 52 blobstoreRateLimit int 53 blobstoreBurstLimit int 54 chunkDataPackRequestWorkers uint 55 maxGracefulStopDuration time.Duration 56 importCheckpointWorkerCount int 57 58 computationConfig computation.ComputationConfig 59 receiptRequestWorkers uint // common provider engine workers 60 receiptRequestsCacheSize uint32 // common provider engine cache size 61 62 // This is included to temporarily work around an issue observed on a small number of ENs. 63 // It works around an issue where some collection nodes are not configured with enough 64 // this works around an issue where some collection nodes are not configured with enough 65 // file descriptors causing connection failures. 66 onflowOnlyLNs bool 67 enableStorehouse bool 68 enableChecker bool 69 enableNewIngestionEngine bool 70 } 71 72 func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) { 73 datadir := "/data" 74 75 flags.StringVarP(&exeConf.rpcConf.ListenAddr, "rpc-addr", "i", "localhost:9000", "the address the gRPC server listens on") 76 flags.UintVar(&exeConf.rpcConf.MaxMsgSize, "rpc-max-message-size", grpcutils.DefaultMaxMsgSize, "the maximum message size in bytes for messages sent or received over grpc") 77 flags.BoolVar(&exeConf.rpcConf.RpcMetricsEnabled, "rpc-metrics-enabled", false, "whether to enable the rpc metrics") 78 flags.StringVar(&exeConf.triedir, "triedir", filepath.Join(datadir, "trie"), "directory to store the execution State") 79 flags.StringVar(&exeConf.executionDataDir, "execution-data-dir", filepath.Join(datadir, "execution_data"), "directory to use for storing Execution Data") 80 flags.StringVar(&exeConf.registerDir, "register-dir", filepath.Join(datadir, "register"), "directory to use for storing registers Data") 81 flags.Uint32Var(&exeConf.mTrieCacheSize, "mtrie-cache-size", 500, "cache size for MTrie") 82 flags.UintVar(&exeConf.checkpointDistance, "checkpoint-distance", 20, "number of WAL segments between checkpoints") 83 flags.UintVar(&exeConf.checkpointsToKeep, "checkpoints-to-keep", 5, "number of recent checkpoints to keep (0 to keep all)") 84 flags.UintVar(&exeConf.computationConfig.DerivedDataCacheSize, "cadence-execution-cache", derived.DefaultDerivedDataCacheSize, 85 "cache size for Cadence execution") 86 flags.BoolVar(&exeConf.computationConfig.ExtensiveTracing, "extensive-tracing", false, "adds high-overhead tracing to execution") 87 flags.BoolVar(&exeConf.computationConfig.CadenceTracing, "cadence-tracing", false, "enables cadence runtime level tracing") 88 flags.IntVar(&exeConf.computationConfig.MaxConcurrency, "computer-max-concurrency", 1, "set to greater than 1 to enable concurrent transaction execution") 89 flags.StringVar(&exeConf.chunkDataPackDir, "chunk-data-pack-dir", filepath.Join(datadir, "chunk_data_packs"), "directory to use for storing chunk data packs") 90 flags.UintVar(&exeConf.chunkDataPackCacheSize, "chdp-cache", storage.DefaultCacheSize, "cache size for chunk data packs") 91 flags.Uint32Var(&exeConf.chunkDataPackRequestsCacheSize, "chdp-request-queue", mempool.DefaultChunkDataPackRequestQueueSize, "queue size for chunk data pack requests") 92 flags.DurationVar(&exeConf.requestInterval, "request-interval", 60*time.Second, "the interval between requests for the requester engine") 93 flags.Uint32Var(&exeConf.receiptRequestsCacheSize, "receipt-request-cache", provider.DefaultEntityRequestCacheSize, "queue size for entity requests at common provider engine") 94 flags.UintVar(&exeConf.receiptRequestWorkers, "receipt-request-workers", provider.DefaultRequestProviderWorkers, "number of workers for entity requests at common provider engine") 95 flags.DurationVar(&exeConf.computationConfig.QueryConfig.LogTimeThreshold, "script-log-threshold", query.DefaultLogTimeThreshold, 96 "threshold for logging script execution") 97 flags.DurationVar(&exeConf.computationConfig.QueryConfig.ExecutionTimeLimit, "script-execution-time-limit", query.DefaultExecutionTimeLimit, 98 "script execution time limit") 99 flags.Uint64Var(&exeConf.computationConfig.QueryConfig.ComputationLimit, "script-execution-computation-limit", fvm.DefaultComputationLimit, 100 "script execution computation limit") 101 flags.UintVar(&exeConf.transactionResultsCacheSize, "transaction-results-cache-size", 10000, "number of transaction results to be cached") 102 flags.BoolVar(&exeConf.extensiveLog, "extensive-logging", false, "extensive logging logs tx contents and block headers") 103 flags.DurationVar(&exeConf.chunkDataPackQueryTimeout, "chunk-data-pack-query-timeout", exeprovider.DefaultChunkDataPackQueryTimeout, "timeout duration to determine a chunk data pack query being slow") 104 flags.DurationVar(&exeConf.chunkDataPackDeliveryTimeout, "chunk-data-pack-delivery-timeout", exeprovider.DefaultChunkDataPackDeliveryTimeout, "timeout duration to determine a chunk data pack response delivery being slow") 105 flags.UintVar(&exeConf.chunkDataPackRequestWorkers, "chunk-data-pack-workers", exeprovider.DefaultChunkDataPackRequestWorker, "number of workers to process chunk data pack requests") 106 flags.BoolVar(&exeConf.pauseExecution, "pause-execution", false, "pause the execution. when set to true, no block will be executed, "+ 107 "but still be able to serve queries") 108 flags.BoolVar(&exeConf.enableBlockDataUpload, "enable-blockdata-upload", false, "enable uploading block data to Cloud Bucket") 109 flags.StringVar(&exeConf.gcpBucketName, "gcp-bucket-name", "", "GCP Bucket name for block data uploader") 110 flags.StringVar(&exeConf.s3BucketName, "s3-bucket-name", "", "S3 Bucket name for block data uploader") 111 flags.StringVar(&exeConf.executionDataAllowedPeers, "execution-data-allowed-requesters", "", "comma separated list of Access node IDs that are allowed to request Execution Data. an empty list allows all peers") 112 flags.Uint64Var(&exeConf.executionDataPrunerHeightRangeTarget, "execution-data-height-range-target", 0, "target height range size used to limit the amount of Execution Data kept on disk") 113 flags.Uint64Var(&exeConf.executionDataPrunerThreshold, "execution-data-height-range-threshold", 100_000, "height threshold used to trigger Execution Data pruning") 114 flags.StringToIntVar(&exeConf.apiRatelimits, "api-rate-limits", map[string]int{}, "per second rate limits for GRPC API methods e.g. Ping=300,ExecuteScriptAtBlockID=500 etc. note limits apply globally to all clients.") 115 flags.StringToIntVar(&exeConf.apiBurstlimits, "api-burst-limits", map[string]int{}, "burst limits for gRPC API methods e.g. Ping=100,ExecuteScriptAtBlockID=100 etc. note limits apply globally to all clients.") 116 flags.IntVar(&exeConf.blobstoreRateLimit, "blobstore-rate-limit", 0, "per second outgoing rate limit for Execution Data blobstore") 117 flags.IntVar(&exeConf.blobstoreBurstLimit, "blobstore-burst-limit", 0, "outgoing burst limit for Execution Data blobstore") 118 flags.DurationVar(&exeConf.maxGracefulStopDuration, "max-graceful-stop-duration", stop.DefaultMaxGracefulStopDuration, "the maximum amount of time stop control will wait for ingestion engine to gracefully shutdown before crashing") 119 flags.IntVar(&exeConf.importCheckpointWorkerCount, "import-checkpoint-worker-count", 10, "number of workers to import checkpoint file during bootstrap") 120 121 flags.BoolVar(&exeConf.onflowOnlyLNs, "temp-onflow-only-lns", false, "do not use unless required. forces node to only request collections from onflow collection nodes") 122 flags.BoolVar(&exeConf.enableStorehouse, "enable-storehouse", false, "enable storehouse to store registers on disk, default is false") 123 flags.BoolVar(&exeConf.enableChecker, "enable-checker", true, "enable checker to check the correctness of the execution result, default is true") 124 flags.BoolVar(&exeConf.enableNewIngestionEngine, "enable-new-ingestion-engine", false, "enable new ingestion engine, default is false") 125 126 } 127 128 func (exeConf *ExecutionConfig) ValidateFlags() error { 129 if exeConf.enableBlockDataUpload { 130 if exeConf.gcpBucketName == "" && exeConf.s3BucketName == "" { 131 return fmt.Errorf("invalid flag. gcp-bucket-name or s3-bucket-name required when blockdata-uploader is enabled") 132 } 133 } 134 if exeConf.executionDataAllowedPeers != "" { 135 ids := strings.Split(exeConf.executionDataAllowedPeers, ",") 136 for _, id := range ids { 137 if _, err := flow.HexStringToIdentifier(id); err != nil { 138 return fmt.Errorf("invalid node ID in execution-data-allowed-requesters %s: %w", id, err) 139 } 140 } 141 } 142 return nil 143 }