-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathflags.go
More file actions
542 lines (478 loc) · 19.7 KB
/
flags.go
File metadata and controls
542 lines (478 loc) · 19.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
// Copyright 2024 The Erigon Authors
// This file is part of Erigon.
//
// Erigon is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Erigon is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Erigon. If not, see <http://www.gnu.org/licenses/>.
package cli
import (
"fmt"
"math"
"time"
"github.com/c2h5oh/datasize"
"github.com/spf13/pflag"
"github.com/urfave/cli/v2"
"github.com/erigontech/erigon/cmd/rpcdaemon/cli/httpcfg"
"github.com/erigontech/erigon/cmd/utils"
"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/hexutil"
"github.com/erigontech/erigon/common/log/v3"
"github.com/erigontech/erigon/db/etl"
"github.com/erigontech/erigon/db/kv"
"github.com/erigontech/erigon/db/kv/kvcache"
"github.com/erigontech/erigon/db/kv/prune"
"github.com/erigontech/erigon/node/ethconfig"
"github.com/erigontech/erigon/node/nodecfg"
"github.com/erigontech/erigon/rpc/rpccfg"
"github.com/erigontech/erigon/rpc/rpchelper"
)
var (
DatabaseVerbosityFlag = cli.IntFlag{
Name: "database.verbosity",
Usage: "Enabling internal db logs. Very high verbosity levels may require recompile db. Default: 2, means warning.",
Value: 2,
}
BatchSizeFlag = cli.StringFlag{
Name: "batchSize",
Usage: "Batch size for the execution stage",
Value: "512M",
}
EtlBufferSizeFlag = cli.StringFlag{
Name: "etl.bufferSize",
Usage: "Buffer size for ETL operations.",
Value: etl.BufferOptimalSize.String(),
}
BodyCacheLimitFlag = cli.StringFlag{
Name: "bodies.cache",
Usage: "Limit on the cache for block bodies",
Value: fmt.Sprintf("%d", ethconfig.Defaults.Sync.BodyCacheLimit),
}
PrivateApiAddr = cli.StringFlag{
Name: "private.api.addr",
Usage: "Erigon's components (txpool, rpcdaemon, sentry, downloader, ...) can be deployed as independent Processes on same/another server. Then components will connect to erigon by this internal grpc API. example: 127.0.0.1:9090, empty string means not to start the listener. do not expose to public network. serves remote database interface",
Value: "127.0.0.1:9090",
}
PrivateApiRateLimit = cli.IntFlag{
Name: "private.api.ratelimit",
Usage: "Amount of requests server handle simultaneously - requests over this limit will wait. Increase it - if clients see 'request timeout' while server load is low - it means your 'hot data' is small or have much RAM. ",
Value: kv.ReadersLimit - 128,
}
PruneModeFlag = cli.StringFlag{
Name: "prune.mode",
Usage: `Choose a pruning preset to run onto. Available values: "full", "archive", "minimal", "blocks".
full: Keep only necessary blocks and latest state,
blocks: Keep all blocks but not the state history,
archive: Keep the entire state history and all blocks,
minimal: Keep only latest state`,
Value: "full",
}
PruneDistanceFlag = cli.Uint64Flag{
Name: "prune.distance",
Usage: `Keep state history for the latest N blocks (default: everything)`,
}
PruneBlocksDistanceFlag = cli.Uint64Flag{
Name: "prune.distance.blocks",
Usage: `Keep block history for the latest N blocks (default: everything)`,
}
// mTLS flags
TLSFlag = cli.BoolFlag{
Name: "tls",
Usage: "Enable TLS handshake",
}
TLSCertFlag = cli.StringFlag{
Name: "tls.cert",
Usage: "Specify certificate",
Value: "",
}
TLSKeyFlag = cli.StringFlag{
Name: "tls.key",
Usage: "Specify key file",
Value: "",
}
TLSCACertFlag = cli.StringFlag{
Name: "tls.cacert",
Usage: "Specify certificate authority",
Value: "",
}
StateStreamDisableFlag = cli.BoolFlag{
Name: "state.stream.disable",
Usage: "Disable streaming of state changes from core to RPC daemon",
}
ExperimentalBALFlag = cli.BoolFlag{
Name: "experimental.bal",
Usage: "generate block access list",
}
// Throttling Flags
SyncLoopThrottleFlag = cli.StringFlag{
Name: "sync.loop.throttle",
Usage: "Sets the minimum time between sync loop starts (e.g. 1h30m, default is none)",
Value: "",
}
SyncLoopBreakAfterFlag = cli.StringFlag{
Name: "sync.loop.break.after",
Usage: "Sets the last stage of the sync loop to run",
Value: "",
}
SyncLoopBlockLimitFlag = cli.UintFlag{
Name: "sync.loop.block.limit",
Usage: "Sets the maximum number of blocks to process per loop iteration",
Value: 5_000,
}
SyncParallelStateFlushing = cli.BoolFlag{
Name: "sync.parallel-state-flushing",
Usage: "Enables parallel state flushing",
Value: true,
}
BadBlockFlag = cli.StringFlag{
Name: "bad.block",
Usage: "Marks block with given hex string as bad and forces initial reorg before normal staged sync",
Value: "",
}
HealthCheckFlag = cli.BoolFlag{
Name: "healthcheck",
Usage: "Enable grpc health check",
}
HTTPReadTimeoutFlag = cli.DurationFlag{
Name: "http.timeouts.read",
Usage: "Maximum duration for reading the entire request, including the body.",
Value: rpccfg.DefaultHTTPTimeouts.ReadTimeout,
}
HTTPWriteTimeoutFlag = cli.DurationFlag{
Name: "http.timeouts.write",
Usage: "Maximum duration before timing out writes of the response. It is reset whenever a new request's header is read.",
Value: rpccfg.DefaultHTTPTimeouts.WriteTimeout,
}
HTTPIdleTimeoutFlag = cli.DurationFlag{
Name: "http.timeouts.idle",
Usage: "Maximum amount of time to wait for the next request when keep-alive connections are enabled. If http.timeouts.idle is zero, the value of http.timeouts.read is used.",
Value: rpccfg.DefaultHTTPTimeouts.IdleTimeout,
}
AuthRpcReadTimeoutFlag = cli.DurationFlag{
Name: "authrpc.timeouts.read",
Usage: "Maximum duration for reading the entire request, including the body.",
Value: rpccfg.DefaultHTTPTimeouts.ReadTimeout,
}
AuthRpcWriteTimeoutFlag = cli.DurationFlag{
Name: "authrpc.timeouts.write",
Usage: "Maximum duration before timing out writes of the response. It is reset whenever a new request's header is read.",
Value: rpccfg.DefaultHTTPTimeouts.WriteTimeout,
}
AuthRpcIdleTimeoutFlag = cli.DurationFlag{
Name: "authrpc.timeouts.idle",
Usage: "Maximum amount of time to wait for the next request when keep-alive connections are enabled. If authrpc.timeouts.idle is zero, the value of authrpc.timeouts.read is used.",
Value: rpccfg.DefaultHTTPTimeouts.IdleTimeout,
}
EvmCallTimeoutFlag = cli.DurationFlag{
Name: "rpc.evmtimeout",
Usage: "Maximum amount of time to wait for the answer from EVM call.",
Value: rpccfg.DefaultEvmCallTimeout,
}
OverlayGetLogsFlag = cli.DurationFlag{
Name: "rpc.overlay.getlogstimeout",
Usage: "Maximum amount of time to wait for the answer from the overlay_getLogs call.",
Value: rpccfg.DefaultOverlayGetLogsTimeout,
}
OverlayReplayBlockFlag = cli.DurationFlag{
Name: "rpc.overlay.replayblocktimeout",
Usage: "Maximum amount of time to wait for the answer to replay a single block when called from an overlay_getLogs call.",
Value: rpccfg.DefaultOverlayReplayBlockTimeout,
}
RpcSubscriptionFiltersMaxLogsFlag = cli.IntFlag{
Name: "rpc.subscription.filters.maxlogs",
Usage: "Maximum number of logs to store per subscription.",
Value: rpchelper.DefaultFiltersConfig.RpcSubscriptionFiltersMaxLogs,
}
RpcSubscriptionFiltersMaxHeadersFlag = cli.IntFlag{
Name: "rpc.subscription.filters.maxheaders",
Usage: "Maximum number of block headers to store per subscription.",
Value: rpchelper.DefaultFiltersConfig.RpcSubscriptionFiltersMaxHeaders,
}
RpcSubscriptionFiltersMaxTxsFlag = cli.IntFlag{
Name: "rpc.subscription.filters.maxtxs",
Usage: "Maximum number of transactions to store per subscription.",
Value: rpchelper.DefaultFiltersConfig.RpcSubscriptionFiltersMaxTxs,
}
RpcSubscriptionFiltersMaxAddressesFlag = cli.IntFlag{
Name: "rpc.subscription.filters.maxaddresses",
Usage: "Maximum number of addresses per subscription to filter logs by.",
Value: rpchelper.DefaultFiltersConfig.RpcSubscriptionFiltersMaxAddresses,
}
RpcSubscriptionFiltersMaxTopicsFlag = cli.IntFlag{
Name: "rpc.subscription.filters.maxtopics",
Usage: "Maximum number of topics per subscription to filter logs by.",
Value: rpchelper.DefaultFiltersConfig.RpcSubscriptionFiltersMaxTopics,
}
RpcSubscriptionFiltersTimeoutFlag = cli.DurationFlag{
Name: "rpc.subscription.filters.timeout",
Usage: "Timeout before idle filters are evicted. Set to 0 to disable eviction.",
Value: rpchelper.DefaultFiltersConfig.RpcSubscriptionFiltersTimeout,
}
)
func ApplyFlagsForEthConfig(ctx *cli.Context, cfg *ethconfig.Config, logger log.Logger) {
chainId := cfg.NetworkID
if cfg.Genesis != nil {
chainId = cfg.Genesis.Config.ChainID.Uint64()
}
_ = chainId
blockDistance := ctx.Uint64(PruneBlocksDistanceFlag.Name)
distance := ctx.Uint64(PruneDistanceFlag.Name)
// check if the prune.mode flag is not set to archive
persistenceReceiptsV2 := ctx.String(PruneModeFlag.Name) != prune.ArchiveMode.String()
// overwrite receipts persistence if the flag is set
if ctx.IsSet(utils.PersistReceiptsV2Flag.Name) {
persistenceReceiptsV2 = ctx.Bool(utils.PersistReceiptsV2Flag.Name)
}
if persistenceReceiptsV2 {
cfg.PersistReceiptsCacheV2 = true
}
mode, err := prune.FromCli(ctx.String(PruneModeFlag.Name), distance, blockDistance)
if err != nil {
utils.Fatalf(fmt.Sprintf("error while parsing mode: %v", err))
}
cfg.Prune = mode
if batchSize := ctx.String(BatchSizeFlag.Name); batchSize != "" {
if err := cfg.BatchSize.UnmarshalText([]byte(batchSize)); err != nil {
utils.Fatalf("Invalid batchSize provided: %v", err)
}
}
if bufsize := ctx.String(EtlBufferSizeFlag.Name); bufsize != "" {
sizeVal := datasize.ByteSize(0)
if err := (&sizeVal).UnmarshalText([]byte(bufsize)); err != nil {
utils.Fatalf("Invalid batchSize provided: %v", err)
}
etl.BufferOptimalSize = sizeVal
}
cfg.StateStream = !ctx.Bool(StateStreamDisableFlag.Name)
cfg.ExperimentalBAL = ctx.Bool(ExperimentalBALFlag.Name)
if bodyCacheLim := ctx.String(BodyCacheLimitFlag.Name); bodyCacheLim != "" {
if err := cfg.Sync.BodyCacheLimit.UnmarshalText([]byte(bodyCacheLim)); err != nil {
utils.Fatalf("Invalid bodyCacheLimit provided: %v", err)
}
}
if loopThrottle := ctx.String(SyncLoopThrottleFlag.Name); loopThrottle != "" {
syncLoopThrottle, err := time.ParseDuration(loopThrottle)
if err != nil {
utils.Fatalf("Invalid time duration provided in %s: %v", SyncLoopThrottleFlag.Name, err)
}
cfg.Sync.LoopThrottle = syncLoopThrottle
}
if ctx.IsSet(utils.SnapDownloadToBlockFlag.Name) {
cfg.Sync.SnapshotDownloadToBlock = ctx.Uint64(utils.SnapDownloadToBlockFlag.Name)
}
if stage := ctx.String(SyncLoopBreakAfterFlag.Name); len(stage) > 0 {
cfg.Sync.BreakAfterStage = stage
}
if limit := ctx.Uint(SyncLoopBlockLimitFlag.Name); limit > 0 {
cfg.Sync.LoopBlockLimit = limit
}
cfg.Sync.ParallelStateFlushing = ctx.Bool(SyncParallelStateFlushing.Name)
if ctx.String(BadBlockFlag.Name) != "" {
bytes, err := hexutil.Decode(ctx.String(BadBlockFlag.Name))
if err != nil {
logger.Warn("Error decoding block hash", "hash", ctx.String(BadBlockFlag.Name), "err", err)
} else {
cfg.BadBlockHash = common.BytesToHash(bytes)
}
}
if ctx.Bool(utils.DisableIPV6.Name) {
cfg.Downloader.ClientConfig.DisableIPv6 = true
}
if ctx.Bool(utils.DisableIPV4.Name) {
cfg.Downloader.ClientConfig.DisableIPv4 = true
}
if ctx.Bool(utils.ChaosMonkeyFlag.Name) {
cfg.ChaosMonkey = true
}
}
func ApplyFlagsForEthConfigCobra(f *pflag.FlagSet, cfg *ethconfig.Config) {
pruneMode := f.String(PruneModeFlag.Name, PruneModeFlag.DefaultText, PruneModeFlag.Usage)
pruneBlockDistance := f.Uint64(PruneBlocksDistanceFlag.Name, PruneBlocksDistanceFlag.Value, PruneBlocksDistanceFlag.Usage)
pruneDistance := f.Uint64(PruneDistanceFlag.Name, PruneDistanceFlag.Value, PruneDistanceFlag.Usage)
var distance, blockDistance uint64 = math.MaxUint64, math.MaxUint64
if pruneBlockDistance != nil {
blockDistance = *pruneBlockDistance
}
if pruneDistance != nil {
distance = *pruneDistance
}
mode, err := prune.FromCli(*pruneMode, distance, blockDistance)
if err != nil {
utils.Fatalf(fmt.Sprintf("error while parsing mode: %v", err))
}
cfg.Prune = mode
if v := f.String(BatchSizeFlag.Name, BatchSizeFlag.Value, BatchSizeFlag.Usage); v != nil {
err := cfg.BatchSize.UnmarshalText([]byte(*v))
if err != nil {
utils.Fatalf("Invalid batchSize provided: %v", err)
}
}
if v := f.String(EtlBufferSizeFlag.Name, EtlBufferSizeFlag.Value, EtlBufferSizeFlag.Usage); v != nil {
sizeVal := datasize.ByteSize(0)
size := &sizeVal
err := size.UnmarshalText([]byte(*v))
if err != nil {
utils.Fatalf("Invalid batchSize provided: %v", err)
}
etl.BufferOptimalSize = *size
}
cfg.StateStream = true
if v := f.Bool(StateStreamDisableFlag.Name, false, StateStreamDisableFlag.Usage); v != nil {
cfg.StateStream = false
}
if v := f.Bool(ExperimentalBALFlag.Name, false, ExperimentalBALFlag.Usage); v != nil {
cfg.ExperimentalBAL = *v
}
if v, _ := f.GetBool(utils.ChaosMonkeyFlag.Name); v {
cfg.ChaosMonkey = true
}
}
func ApplyFlagsForNodeConfig(ctx *cli.Context, cfg *nodecfg.Config, logger log.Logger) {
setPrivateApi(ctx, cfg)
setEmbeddedRpcDaemon(ctx, cfg, logger)
cfg.DatabaseVerbosity = kv.DBVerbosityLvl(ctx.Int(DatabaseVerbosityFlag.Name))
}
func setEmbeddedRpcDaemon(ctx *cli.Context, cfg *nodecfg.Config, logger log.Logger) {
jwtSecretPath := ctx.String(utils.JWTSecretPath.Name)
if jwtSecretPath == "" {
jwtSecretPath = cfg.Dirs.DataDir + "/jwt.hex"
}
apis := ctx.String(utils.HTTPApiFlag.Name)
c := &httpcfg.HttpCfg{
Enabled: func() bool {
if ctx.IsSet(utils.HTTPEnabledFlag.Name) {
return ctx.Bool(utils.HTTPEnabledFlag.Name)
}
return true
}(),
HttpServerEnabled: ctx.Bool(utils.HTTPServerEnabledFlag.Name),
Dirs: cfg.Dirs,
TLSKeyFile: cfg.TLSKeyFile,
TLSCACert: cfg.TLSCACert,
TLSCertfile: cfg.TLSCertFile,
GraphQLEnabled: ctx.Bool(utils.GraphQLEnabledFlag.Name),
HttpListenAddress: ctx.String(utils.HTTPListenAddrFlag.Name),
HttpPort: ctx.Int(utils.HTTPPortFlag.Name),
AuthRpcHTTPListenAddress: ctx.String(utils.AuthRpcAddr.Name),
AuthRpcPort: ctx.Int(utils.AuthRpcPort.Name),
JWTSecretPath: jwtSecretPath,
TraceRequests: ctx.Bool(utils.HTTPTraceFlag.Name),
DebugSingleRequest: ctx.Bool(utils.HTTPDebugSingleFlag.Name),
HttpCORSDomain: common.CliString2Array(ctx.String(utils.HTTPCORSDomainFlag.Name)),
HttpVirtualHost: common.CliString2Array(ctx.String(utils.HTTPVirtualHostsFlag.Name)),
AuthRpcVirtualHost: common.CliString2Array(ctx.String(utils.AuthRpcVirtualHostsFlag.Name)),
API: common.CliString2Array(apis),
HTTPTimeouts: rpccfg.HTTPTimeouts{
ReadTimeout: ctx.Duration(HTTPReadTimeoutFlag.Name),
WriteTimeout: ctx.Duration(HTTPWriteTimeoutFlag.Name),
IdleTimeout: ctx.Duration(HTTPIdleTimeoutFlag.Name),
},
AuthRpcTimeouts: rpccfg.HTTPTimeouts{
ReadTimeout: ctx.Duration(AuthRpcReadTimeoutFlag.Name),
WriteTimeout: ctx.Duration(AuthRpcWriteTimeoutFlag.Name),
IdleTimeout: ctx.Duration(AuthRpcIdleTimeoutFlag.Name),
},
EvmCallTimeout: ctx.Duration(EvmCallTimeoutFlag.Name),
OverlayGetLogsTimeout: ctx.Duration(OverlayGetLogsFlag.Name),
OverlayReplayBlockTimeout: ctx.Duration(OverlayReplayBlockFlag.Name),
WebsocketPort: ctx.Int(utils.WSPortFlag.Name),
WebsocketEnabled: ctx.IsSet(utils.WSEnabledFlag.Name),
RpcBatchConcurrency: ctx.Uint(utils.RpcBatchConcurrencyFlag.Name),
RpcStreamingDisable: ctx.Bool(utils.RpcStreamingDisableFlag.Name),
DBReadConcurrency: ctx.Int(utils.DBReadConcurrencyFlag.Name),
RpcAllowListFilePath: ctx.String(utils.RpcAccessListFlag.Name),
RpcFiltersConfig: rpchelper.FiltersConfig{
RpcSubscriptionFiltersMaxLogs: ctx.Int(RpcSubscriptionFiltersMaxLogsFlag.Name),
RpcSubscriptionFiltersMaxHeaders: ctx.Int(RpcSubscriptionFiltersMaxHeadersFlag.Name),
RpcSubscriptionFiltersMaxTxs: ctx.Int(RpcSubscriptionFiltersMaxTxsFlag.Name),
RpcSubscriptionFiltersMaxAddresses: ctx.Int(RpcSubscriptionFiltersMaxAddressesFlag.Name),
RpcSubscriptionFiltersMaxTopics: ctx.Int(RpcSubscriptionFiltersMaxTopicsFlag.Name),
RpcSubscriptionFiltersTimeout: ctx.Duration(RpcSubscriptionFiltersTimeoutFlag.Name),
},
Gascap: ctx.Uint64(utils.RpcGasCapFlag.Name),
Feecap: ctx.Float64(utils.RPCGlobalTxFeeCapFlag.Name),
MaxTraces: ctx.Uint64(utils.TraceMaxtracesFlag.Name),
TraceCompatibility: ctx.Bool(utils.RpcTraceCompatFlag.Name),
BatchLimit: ctx.Int(utils.RpcBatchLimit.Name),
ReturnDataLimit: ctx.Int(utils.RpcReturnDataLimit.Name),
AllowUnprotectedTxs: ctx.Bool(utils.AllowUnprotectedTxs.Name),
OtsMaxPageSize: ctx.Uint64(utils.OtsSearchMaxCapFlag.Name),
TxPoolApiAddr: ctx.String(utils.TxpoolApiAddrFlag.Name),
StateCache: kvcache.DefaultCoherentConfig,
RPCSlowLogThreshold: ctx.Duration(utils.RPCSlowFlag.Name),
}
if ctx.IsSet(utils.WSSubscribeLogsChannelSize.Name) {
c.WebsocketSubscribeLogsChannelSize = ctx.Int(utils.WSSubscribeLogsChannelSize.Name)
} else {
c.WebsocketSubscribeLogsChannelSize = 8192
}
if c.Enabled {
if ctx.IsSet(utils.HttpCompressionFlag.Name) {
c.HttpCompression = ctx.Bool(utils.HttpCompressionFlag.Name)
} else {
c.HttpCompression = true
}
logger.Info("starting HTTP APIs", "port", c.HttpPort, "APIs", apis, "http.compression", c.HttpCompression)
} else {
c.HttpCompression = false
}
if c.WebsocketEnabled {
if ctx.IsSet(utils.WsCompressionFlag.Name) {
c.WebsocketCompression = ctx.Bool(utils.WsCompressionFlag.Name)
} else {
c.WebsocketCompression = true
}
} else {
c.WebsocketCompression = false
}
err := c.StateCache.CacheSize.UnmarshalText([]byte(ctx.String(utils.StateCacheFlag.Name)))
if err != nil {
utils.Fatalf("Invalid state.cache value provided")
}
err = c.StateCache.CodeCacheSize.UnmarshalText([]byte(ctx.String(utils.StateCacheFlag.Name)))
if err != nil {
utils.Fatalf("Invalid state.cache value provided")
}
/*
rootCmd.PersistentFlags().BoolVar(&cfg.GRPCServerEnabled, "grpc", false, "Enable GRPC server")
rootCmd.PersistentFlags().StringVar(&cfg.GRPCListenAddress, "grpc.addr", node.DefaultGRPCHost, "GRPC server listening interface")
rootCmd.PersistentFlags().IntVar(&cfg.GRPCPort, "grpc.port", node.DefaultGRPCPort, "GRPC server listening port")
rootCmd.PersistentFlags().BoolVar(&cfg.GRPCHealthCheckEnabled, "grpc.healthcheck", false, "Enable GRPC health check")
*/
cfg.Http = *c
}
// setPrivateApi populates configuration fields related to the remote
// read-only interface to the database
func setPrivateApi(ctx *cli.Context, cfg *nodecfg.Config) {
cfg.PrivateApiAddr = ctx.String(PrivateApiAddr.Name)
cfg.PrivateApiRateLimit = uint32(ctx.Uint64(PrivateApiRateLimit.Name))
maxRateLimit := uint32(kv.ReadersLimit - 128) // leave some readers for P2P
if cfg.PrivateApiRateLimit > maxRateLimit {
log.Warn("private.api.ratelimit is too big", "force", maxRateLimit)
cfg.PrivateApiRateLimit = maxRateLimit
}
if ctx.Bool(TLSFlag.Name) {
certFile := ctx.String(TLSCertFlag.Name)
keyFile := ctx.String(TLSKeyFlag.Name)
if certFile == "" {
log.Warn("Could not establish TLS grpc: missing certificate")
return
} else if keyFile == "" {
log.Warn("Could not establish TLS grpc: missing key file")
return
}
cfg.TLSConnection = true
cfg.TLSCertFile = certFile
cfg.TLSKeyFile = keyFile
cfg.TLSCACert = ctx.String(TLSCACertFlag.Name)
}
cfg.HealthCheck = ctx.Bool(HealthCheckFlag.Name)
}