github.com/shrimpyuk/bor@v0.2.15-0.20220224151350-fb4ec6020bae/internal/cli/server/flags.go (about)

     1  package server
     2  
     3  import (
     4  	"github.com/ethereum/go-ethereum/internal/cli/flagset"
     5  )
     6  
     7  func (c *Command) Flags() *flagset.Flagset {
     8  	c.cliConfig = DefaultConfig()
     9  
    10  	f := flagset.NewFlagSet("server")
    11  
    12  	f.StringFlag(&flagset.StringFlag{
    13  		Name:  "chain",
    14  		Usage: "Name of the chain to sync",
    15  		Value: &c.cliConfig.Chain,
    16  	})
    17  	f.StringFlag(&flagset.StringFlag{
    18  		Name:  "name",
    19  		Usage: "Name/Identity of the node",
    20  		Value: &c.cliConfig.Name,
    21  	})
    22  	f.StringFlag(&flagset.StringFlag{
    23  		Name:  "log-level",
    24  		Usage: "Set log level for the server",
    25  		Value: &c.cliConfig.LogLevel,
    26  	})
    27  	f.StringFlag(&flagset.StringFlag{
    28  		Name:  "datadir",
    29  		Usage: "Path of the data directory to store information",
    30  		Value: &c.cliConfig.DataDir,
    31  	})
    32  	f.SliceStringFlag(&flagset.SliceStringFlag{
    33  		Name:  "config",
    34  		Usage: "File for the config file",
    35  		Value: &c.configFile,
    36  	})
    37  	f.StringFlag(&flagset.StringFlag{
    38  		Name:  "syncmode",
    39  		Usage: `Blockchain sync mode ("fast", "full", "snap" or "light")`,
    40  		Value: &c.cliConfig.SyncMode,
    41  	})
    42  	f.StringFlag(&flagset.StringFlag{
    43  		Name:  "gcmode",
    44  		Usage: `Blockchain garbage collection mode ("full", "archive")`,
    45  		Value: &c.cliConfig.GcMode,
    46  	})
    47  	f.MapStringFlag(&flagset.MapStringFlag{
    48  		Name:  "whitelist",
    49  		Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
    50  		Value: &c.cliConfig.Whitelist,
    51  	})
    52  	f.BoolFlag(&flagset.BoolFlag{
    53  		Name:  "snapshot",
    54  		Usage: `Enables snapshot-database mode (default = enable)`,
    55  		Value: &c.cliConfig.Snapshot,
    56  	})
    57  
    58  	// heimdall
    59  	f.StringFlag(&flagset.StringFlag{
    60  		Name:  "bor.heimdall",
    61  		Usage: "URL of Heimdall service",
    62  		Value: &c.cliConfig.Heimdall.URL,
    63  	})
    64  	f.BoolFlag(&flagset.BoolFlag{
    65  		Name:  "bor.withoutheimdall",
    66  		Usage: "Run without Heimdall service (for testing purpose)",
    67  		Value: &c.cliConfig.Heimdall.Without,
    68  	})
    69  
    70  	// txpool options
    71  	f.SliceStringFlag(&flagset.SliceStringFlag{
    72  		Name:  "txpool.locals",
    73  		Usage: "Comma separated accounts to treat as locals (no flush, priority inclusion)",
    74  		Value: &c.cliConfig.TxPool.Locals,
    75  	})
    76  	f.BoolFlag(&flagset.BoolFlag{
    77  		Name:  "txpool.nolocals",
    78  		Usage: "Disables price exemptions for locally submitted transactions",
    79  		Value: &c.cliConfig.TxPool.NoLocals,
    80  	})
    81  	f.StringFlag(&flagset.StringFlag{
    82  		Name:  "txpool.journal",
    83  		Usage: "Disk journal for local transaction to survive node restarts",
    84  		Value: &c.cliConfig.TxPool.Journal,
    85  	})
    86  	f.DurationFlag(&flagset.DurationFlag{
    87  		Name:  "txpool.rejournal",
    88  		Usage: "Time interval to regenerate the local transaction journal",
    89  		Value: &c.cliConfig.TxPool.Rejournal,
    90  	})
    91  	f.Uint64Flag(&flagset.Uint64Flag{
    92  		Name:  "txpool.pricelimit",
    93  		Usage: "Minimum gas price limit to enforce for acceptance into the pool",
    94  		Value: &c.cliConfig.TxPool.PriceLimit,
    95  	})
    96  	f.Uint64Flag(&flagset.Uint64Flag{
    97  		Name:  "txpool.pricebump",
    98  		Usage: "Price bump percentage to replace an already existing transaction",
    99  		Value: &c.cliConfig.TxPool.PriceBump,
   100  	})
   101  	f.Uint64Flag(&flagset.Uint64Flag{
   102  		Name:  "txpool.accountslots",
   103  		Usage: "Minimum number of executable transaction slots guaranteed per account",
   104  		Value: &c.cliConfig.TxPool.AccountSlots,
   105  	})
   106  	f.Uint64Flag(&flagset.Uint64Flag{
   107  		Name:  "txpool.globalslots",
   108  		Usage: "Maximum number of executable transaction slots for all accounts",
   109  		Value: &c.cliConfig.TxPool.GlobalSlots,
   110  	})
   111  	f.Uint64Flag(&flagset.Uint64Flag{
   112  		Name:  "txpool.accountqueue",
   113  		Usage: "Maximum number of non-executable transaction slots permitted per account",
   114  		Value: &c.cliConfig.TxPool.AccountQueue,
   115  	})
   116  	f.Uint64Flag(&flagset.Uint64Flag{
   117  		Name:  "txpool.globalqueue",
   118  		Usage: "Maximum number of non-executable transaction slots for all accounts",
   119  		Value: &c.cliConfig.TxPool.GlobalQueue,
   120  	})
   121  	f.DurationFlag(&flagset.DurationFlag{
   122  		Name:  "txpool.lifetime",
   123  		Usage: "Maximum amount of time non-executable transaction are queued",
   124  		Value: &c.cliConfig.TxPool.LifeTime,
   125  	})
   126  
   127  	// sealer options
   128  	f.BoolFlag(&flagset.BoolFlag{
   129  		Name:  "mine",
   130  		Usage: "Enable mining",
   131  		Value: &c.cliConfig.Sealer.Enabled,
   132  	})
   133  	f.StringFlag(&flagset.StringFlag{
   134  		Name:  "miner.etherbase",
   135  		Usage: "Public address for block mining rewards (default = first account)",
   136  		Value: &c.cliConfig.Sealer.Etherbase,
   137  	})
   138  	f.StringFlag(&flagset.StringFlag{
   139  		Name:  "miner.extradata",
   140  		Usage: "Block extra data set by the miner (default = client version)",
   141  		Value: &c.cliConfig.Sealer.ExtraData,
   142  	})
   143  	f.Uint64Flag(&flagset.Uint64Flag{
   144  		Name:  "miner.gaslimit",
   145  		Usage: "Target gas ceiling for mined blocks",
   146  		Value: &c.cliConfig.Sealer.GasCeil,
   147  	})
   148  	f.BigIntFlag(&flagset.BigIntFlag{
   149  		Name:  "miner.gasprice",
   150  		Usage: "Minimum gas price for mining a transaction",
   151  		Value: c.cliConfig.Sealer.GasPrice,
   152  	})
   153  
   154  	// ethstats
   155  	f.StringFlag(&flagset.StringFlag{
   156  		Name:  "ethstats",
   157  		Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)",
   158  		Value: &c.cliConfig.Ethstats,
   159  	})
   160  
   161  	// gas price oracle
   162  	f.Uint64Flag(&flagset.Uint64Flag{
   163  		Name:  "gpo.blocks",
   164  		Usage: "Number of recent blocks to check for gas prices",
   165  		Value: &c.cliConfig.Gpo.Blocks,
   166  	})
   167  	f.Uint64Flag(&flagset.Uint64Flag{
   168  		Name:  "gpo.percentile",
   169  		Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
   170  		Value: &c.cliConfig.Gpo.Percentile,
   171  	})
   172  	f.BigIntFlag(&flagset.BigIntFlag{
   173  		Name:  "gpo.maxprice",
   174  		Usage: "Maximum gas price will be recommended by gpo",
   175  		Value: c.cliConfig.Gpo.MaxPrice,
   176  	})
   177  	f.BigIntFlag(&flagset.BigIntFlag{
   178  		Name:  "gpo.ignoreprice",
   179  		Usage: "Gas price below which gpo will ignore transactions",
   180  		Value: c.cliConfig.Gpo.IgnorePrice,
   181  	})
   182  
   183  	// cache options
   184  	f.Uint64Flag(&flagset.Uint64Flag{
   185  		Name:  "cache",
   186  		Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)",
   187  		Value: &c.cliConfig.Cache.Cache,
   188  	})
   189  	f.Uint64Flag(&flagset.Uint64Flag{
   190  		Name:  "cache.database",
   191  		Usage: "Percentage of cache memory allowance to use for database io",
   192  		Value: &c.cliConfig.Cache.PercDatabase,
   193  	})
   194  	f.Uint64Flag(&flagset.Uint64Flag{
   195  		Name:  "cache.trie",
   196  		Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)",
   197  		Value: &c.cliConfig.Cache.PercTrie,
   198  	})
   199  	f.StringFlag(&flagset.StringFlag{
   200  		Name:  "cache.trie.journal",
   201  		Usage: "Disk journal directory for trie cache to survive node restarts",
   202  		Value: &c.cliConfig.Cache.Journal,
   203  	})
   204  	f.DurationFlag(&flagset.DurationFlag{
   205  		Name:  "cache.trie.rejournal",
   206  		Usage: "Time interval to regenerate the trie cache journal",
   207  		Value: &c.cliConfig.Cache.Rejournal,
   208  	})
   209  	f.Uint64Flag(&flagset.Uint64Flag{
   210  		Name:  "cache.gc",
   211  		Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)",
   212  		Value: &c.cliConfig.Cache.PercGc,
   213  	})
   214  	f.Uint64Flag(&flagset.Uint64Flag{
   215  		Name:  "cache.snapshot",
   216  		Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)",
   217  		Value: &c.cliConfig.Cache.PercSnapshot,
   218  	})
   219  	f.BoolFlag(&flagset.BoolFlag{
   220  		Name:  "cache.noprefetch",
   221  		Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)",
   222  		Value: &c.cliConfig.Cache.NoPrefetch,
   223  	})
   224  	f.BoolFlag(&flagset.BoolFlag{
   225  		Name:  "cache.preimages",
   226  		Usage: "Enable recording the SHA3/keccak preimages of trie keys",
   227  		Value: &c.cliConfig.Cache.Preimages,
   228  	})
   229  	f.Uint64Flag(&flagset.Uint64Flag{
   230  		Name:  "txlookuplimit",
   231  		Usage: "Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain)",
   232  		Value: &c.cliConfig.Cache.TxLookupLimit,
   233  	})
   234  
   235  	// rpc options
   236  	f.Uint64Flag(&flagset.Uint64Flag{
   237  		Name:  "rpc.gascap",
   238  		Usage: "Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)",
   239  		Value: &c.cliConfig.JsonRPC.GasCap,
   240  	})
   241  	f.Float64Flag(&flagset.Float64Flag{
   242  		Name:  "rpc.txfeecap",
   243  		Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)",
   244  		Value: &c.cliConfig.JsonRPC.TxFeeCap,
   245  	})
   246  	f.BoolFlag(&flagset.BoolFlag{
   247  		Name:  "ipcdisable",
   248  		Usage: "Disable the IPC-RPC server",
   249  		Value: &c.cliConfig.JsonRPC.IPCDisable,
   250  	})
   251  	f.StringFlag(&flagset.StringFlag{
   252  		Name:  "ipcpath",
   253  		Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
   254  		Value: &c.cliConfig.JsonRPC.IPCPath,
   255  	})
   256  	f.SliceStringFlag(&flagset.SliceStringFlag{
   257  		Name:  "jsonrpc.corsdomain",
   258  		Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
   259  		Value: &c.cliConfig.JsonRPC.Cors,
   260  	})
   261  	f.SliceStringFlag(&flagset.SliceStringFlag{
   262  		Name:  "jsonrpc.vhosts",
   263  		Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
   264  		Value: &c.cliConfig.JsonRPC.VHost,
   265  	})
   266  
   267  	// http options
   268  	f.BoolFlag(&flagset.BoolFlag{
   269  		Name:  "http",
   270  		Usage: "Enable the HTTP-RPC server",
   271  		Value: &c.cliConfig.JsonRPC.Http.Enabled,
   272  	})
   273  	f.StringFlag(&flagset.StringFlag{
   274  		Name:  "http.addr",
   275  		Usage: "HTTP-RPC server listening interface",
   276  		Value: &c.cliConfig.JsonRPC.Http.Host,
   277  	})
   278  	f.Uint64Flag(&flagset.Uint64Flag{
   279  		Name:  "http.port",
   280  		Usage: "HTTP-RPC server listening port",
   281  		Value: &c.cliConfig.JsonRPC.Http.Port,
   282  	})
   283  	f.StringFlag(&flagset.StringFlag{
   284  		Name:  "http.rpcprefix",
   285  		Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
   286  		Value: &c.cliConfig.JsonRPC.Http.Prefix,
   287  	})
   288  	f.SliceStringFlag(&flagset.SliceStringFlag{
   289  		Name:  "http.modules",
   290  		Usage: "API's offered over the HTTP-RPC interface",
   291  		Value: &c.cliConfig.JsonRPC.Http.Modules,
   292  	})
   293  
   294  	// ws options
   295  	f.BoolFlag(&flagset.BoolFlag{
   296  		Name:  "ws",
   297  		Usage: "Enable the WS-RPC server",
   298  		Value: &c.cliConfig.JsonRPC.Ws.Enabled,
   299  	})
   300  	f.StringFlag(&flagset.StringFlag{
   301  		Name:  "ws.addr",
   302  		Usage: "WS-RPC server listening interface",
   303  		Value: &c.cliConfig.JsonRPC.Ws.Host,
   304  	})
   305  	f.Uint64Flag(&flagset.Uint64Flag{
   306  		Name:  "ws.port",
   307  		Usage: "WS-RPC server listening port",
   308  		Value: &c.cliConfig.JsonRPC.Ws.Port,
   309  	})
   310  	f.StringFlag(&flagset.StringFlag{
   311  		Name:  "ws.rpcprefix",
   312  		Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
   313  		Value: &c.cliConfig.JsonRPC.Ws.Prefix,
   314  	})
   315  	f.SliceStringFlag(&flagset.SliceStringFlag{
   316  		Name:  "ws.modules",
   317  		Usage: "API's offered over the WS-RPC interface",
   318  		Value: &c.cliConfig.JsonRPC.Ws.Modules,
   319  	})
   320  
   321  	// graphql options
   322  	f.BoolFlag(&flagset.BoolFlag{
   323  		Name:  "graphql",
   324  		Usage: "Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.",
   325  		Value: &c.cliConfig.JsonRPC.Graphql.Enabled,
   326  	})
   327  
   328  	// p2p options
   329  	f.StringFlag(&flagset.StringFlag{
   330  		Name:  "bind",
   331  		Usage: "Network binding address",
   332  		Value: &c.cliConfig.P2P.Bind,
   333  	})
   334  	f.Uint64Flag(&flagset.Uint64Flag{
   335  		Name:  "port",
   336  		Usage: "Network listening port",
   337  		Value: &c.cliConfig.P2P.Port,
   338  	})
   339  	f.SliceStringFlag(&flagset.SliceStringFlag{
   340  		Name:  "bootnodes",
   341  		Usage: "Comma separated enode URLs for P2P discovery bootstrap",
   342  		Value: &c.cliConfig.P2P.Discovery.Bootnodes,
   343  	})
   344  	f.Uint64Flag(&flagset.Uint64Flag{
   345  		Name:  "maxpeers",
   346  		Usage: "Maximum number of network peers (network disabled if set to 0)",
   347  		Value: &c.cliConfig.P2P.MaxPeers,
   348  	})
   349  	f.Uint64Flag(&flagset.Uint64Flag{
   350  		Name:  "maxpendpeers",
   351  		Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
   352  		Value: &c.cliConfig.P2P.MaxPendPeers,
   353  	})
   354  	f.StringFlag(&flagset.StringFlag{
   355  		Name:  "nat",
   356  		Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
   357  		Value: &c.cliConfig.P2P.NAT,
   358  	})
   359  	f.BoolFlag(&flagset.BoolFlag{
   360  		Name:  "nodiscover",
   361  		Usage: "Disables the peer discovery mechanism (manual peer addition)",
   362  		Value: &c.cliConfig.P2P.NoDiscover,
   363  	})
   364  	f.BoolFlag(&flagset.BoolFlag{
   365  		Name:  "v5disc",
   366  		Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism",
   367  		Value: &c.cliConfig.P2P.Discovery.V5Enabled,
   368  	})
   369  
   370  	// metrics
   371  	f.BoolFlag(&flagset.BoolFlag{
   372  		Name:  "metrics",
   373  		Usage: "Enable metrics collection and reporting",
   374  		Value: &c.cliConfig.Telemetry.Enabled,
   375  	})
   376  	f.BoolFlag(&flagset.BoolFlag{
   377  		Name:  "metrics.expensive",
   378  		Usage: "Enable expensive metrics collection and reporting",
   379  		Value: &c.cliConfig.Telemetry.Expensive,
   380  	})
   381  	f.BoolFlag(&flagset.BoolFlag{
   382  		Name:  "metrics.influxdb",
   383  		Usage: "Enable metrics export/push to an external InfluxDB database (v1)",
   384  		Value: &c.cliConfig.Telemetry.InfluxDB.V1Enabled,
   385  	})
   386  	f.StringFlag(&flagset.StringFlag{
   387  		Name:  "metrics.influxdb.endpoint",
   388  		Usage: "InfluxDB API endpoint to report metrics to",
   389  		Value: &c.cliConfig.Telemetry.InfluxDB.Endpoint,
   390  	})
   391  	f.StringFlag(&flagset.StringFlag{
   392  		Name:  "metrics.influxdb.database",
   393  		Usage: "InfluxDB database name to push reported metrics to",
   394  		Value: &c.cliConfig.Telemetry.InfluxDB.Database,
   395  	})
   396  	f.StringFlag(&flagset.StringFlag{
   397  		Name:  "metrics.influxdb.username",
   398  		Usage: "Username to authorize access to the database",
   399  		Value: &c.cliConfig.Telemetry.InfluxDB.Username,
   400  	})
   401  	f.StringFlag(&flagset.StringFlag{
   402  		Name:  "metrics.influxdb.password",
   403  		Usage: "Password to authorize access to the database",
   404  		Value: &c.cliConfig.Telemetry.InfluxDB.Password,
   405  	})
   406  	f.MapStringFlag(&flagset.MapStringFlag{
   407  		Name:  "metrics.influxdb.tags",
   408  		Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
   409  		Value: &c.cliConfig.Telemetry.InfluxDB.Tags,
   410  	})
   411  	f.StringFlag(&flagset.StringFlag{
   412  		Name:  "metrics.prometheus-addr",
   413  		Usage: "Address for Prometheus Server",
   414  		Value: &c.cliConfig.Telemetry.PrometheusAddr,
   415  	})
   416  	f.StringFlag(&flagset.StringFlag{
   417  		Name:  "metrics.opencollector-endpoint",
   418  		Usage: "OpenCollector Endpoint (host:port)",
   419  		Value: &c.cliConfig.Telemetry.OpenCollectorEndpoint,
   420  	})
   421  	// influx db v2
   422  	f.BoolFlag(&flagset.BoolFlag{
   423  		Name:  "metrics.influxdbv2",
   424  		Usage: "Enable metrics export/push to an external InfluxDB v2 database",
   425  		Value: &c.cliConfig.Telemetry.InfluxDB.V2Enabled,
   426  	})
   427  	f.StringFlag(&flagset.StringFlag{
   428  		Name:  "metrics.influxdb.token",
   429  		Usage: "Token to authorize access to the database (v2 only)",
   430  		Value: &c.cliConfig.Telemetry.InfluxDB.Token,
   431  	})
   432  	f.StringFlag(&flagset.StringFlag{
   433  		Name:  "metrics.influxdb.bucket",
   434  		Usage: "InfluxDB bucket name to push reported metrics to (v2 only)",
   435  		Value: &c.cliConfig.Telemetry.InfluxDB.Bucket,
   436  	})
   437  	f.StringFlag(&flagset.StringFlag{
   438  		Name:  "metrics.influxdb.organization",
   439  		Usage: "InfluxDB organization name (v2 only)",
   440  		Value: &c.cliConfig.Telemetry.InfluxDB.Organization,
   441  	})
   442  
   443  	// account
   444  	f.SliceStringFlag(&flagset.SliceStringFlag{
   445  		Name:  "unlock",
   446  		Usage: "Comma separated list of accounts to unlock",
   447  		Value: &c.cliConfig.Accounts.Unlock,
   448  	})
   449  	f.StringFlag(&flagset.StringFlag{
   450  		Name:  "password",
   451  		Usage: "Password file to use for non-interactive password input",
   452  		Value: &c.cliConfig.Accounts.PasswordFile,
   453  	})
   454  	f.BoolFlag(&flagset.BoolFlag{
   455  		Name:  "allow-insecure-unlock",
   456  		Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http",
   457  		Value: &c.cliConfig.Accounts.AllowInsecureUnlock,
   458  	})
   459  	f.BoolFlag(&flagset.BoolFlag{
   460  		Name:  "lightkdf",
   461  		Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
   462  		Value: &c.cliConfig.Accounts.UseLightweightKDF,
   463  	})
   464  
   465  	// grpc
   466  	f.StringFlag(&flagset.StringFlag{
   467  		Name:  "grpc.addr",
   468  		Usage: "Address and port to bind the GRPC server",
   469  		Value: &c.cliConfig.GRPC.Addr,
   470  	})
   471  
   472  	// developer
   473  	f.BoolFlag(&flagset.BoolFlag{
   474  		Name:  "dev",
   475  		Usage: "Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled",
   476  		Value: &c.cliConfig.Developer.Enabled,
   477  	})
   478  	f.Uint64Flag(&flagset.Uint64Flag{
   479  		Name:  "dev.period",
   480  		Usage: "Block period to use in developer mode (0 = mine only if transaction pending)",
   481  		Value: &c.cliConfig.Developer.Period,
   482  	})
   483  	return f
   484  }