forked from cerc-io/plugeth
cmd/utils: renames flags related to http-rpc server (#20935)
* rpc flags related to starting http server renamed to http * old rpc flags aliased and still functional * pprof flags fixed * renames gpo related flags * linted * renamed rpc flags for consistency and clarity * added warn logs * added more warn logs for all deprecated flags for consistency * moves legacy flags to separate file, hides older flags under show-deprecated-flags command * legacy prefix and moved some more legacy flags to legacy file * fixed circular import * added docs * fixed imports lint error * added notes about when flags were deprecated * cmd/utils: group flags by deprecation date + reorder by date, * modified deprecated comments for consistency, added warn log for --rpc * making sure deprecated flags are still functional * show-deprecated-flags command cleaned up * fixed lint errors * corrected merge conflict * IsSet --> GlobalIsSet * uncategorized flags, if not deprecated, displayed under misc Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
parent
587656619d
commit
c989bca173
@ -222,11 +222,11 @@ func init() {
|
||||
utils.LightKDFFlag,
|
||||
utils.NoUSBFlag,
|
||||
utils.SmartCardDaemonPathFlag,
|
||||
utils.RPCListenAddrFlag,
|
||||
utils.RPCVirtualHostsFlag,
|
||||
utils.HTTPListenAddrFlag,
|
||||
utils.HTTPVirtualHostsFlag,
|
||||
utils.IPCDisabledFlag,
|
||||
utils.IPCPathFlag,
|
||||
utils.RPCEnabledFlag,
|
||||
utils.HTTPEnabledFlag,
|
||||
rpcPortFlag,
|
||||
signerSecretFlag,
|
||||
customDBFlag,
|
||||
@ -579,9 +579,9 @@ func signer(c *cli.Context) error {
|
||||
Service: api,
|
||||
Version: "1.0"},
|
||||
}
|
||||
if c.GlobalBool(utils.RPCEnabledFlag.Name) {
|
||||
vhosts := splitAndTrim(c.GlobalString(utils.RPCVirtualHostsFlag.Name))
|
||||
cors := splitAndTrim(c.GlobalString(utils.RPCCORSDomainFlag.Name))
|
||||
if c.GlobalBool(utils.HTTPEnabledFlag.Name) {
|
||||
vhosts := splitAndTrim(c.GlobalString(utils.HTTPVirtualHostsFlag.Name))
|
||||
cors := splitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
|
||||
|
||||
srv := rpc.NewServer()
|
||||
err := node.RegisterApisFromWhitelist(rpcAPI, []string{"account"}, srv, false)
|
||||
@ -591,7 +591,7 @@ func signer(c *cli.Context) error {
|
||||
handler := node.NewHTTPHandlerStack(srv, cors, vhosts)
|
||||
|
||||
// start http server
|
||||
httpEndpoint := fmt.Sprintf("%s:%d", c.GlobalString(utils.RPCListenAddrFlag.Name), c.Int(rpcPortFlag.Name))
|
||||
httpEndpoint := fmt.Sprintf("%s:%d", c.GlobalString(utils.HTTPListenAddrFlag.Name), c.Int(rpcPortFlag.Name))
|
||||
httpServer, addr, err := node.StartHTTPEndpoint(httpEndpoint, rpc.DefaultHTTPTimeouts, handler)
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not start RPC api: %v", err)
|
||||
|
@ -93,11 +93,11 @@ var (
|
||||
utils.GCModeFlag,
|
||||
utils.SnapshotFlag,
|
||||
utils.LightServeFlag,
|
||||
utils.LightLegacyServFlag,
|
||||
utils.LegacyLightServFlag,
|
||||
utils.LightIngressFlag,
|
||||
utils.LightEgressFlag,
|
||||
utils.LightMaxPeersFlag,
|
||||
utils.LightLegacyPeersFlag,
|
||||
utils.LegacyLightPeersFlag,
|
||||
utils.LightKDFFlag,
|
||||
utils.UltraLightServersFlag,
|
||||
utils.UltraLightFractionFlag,
|
||||
@ -114,17 +114,17 @@ var (
|
||||
utils.MaxPendingPeersFlag,
|
||||
utils.MiningEnabledFlag,
|
||||
utils.MinerThreadsFlag,
|
||||
utils.MinerLegacyThreadsFlag,
|
||||
utils.LegacyMinerThreadsFlag,
|
||||
utils.MinerNotifyFlag,
|
||||
utils.MinerGasTargetFlag,
|
||||
utils.MinerLegacyGasTargetFlag,
|
||||
utils.LegacyMinerGasTargetFlag,
|
||||
utils.MinerGasLimitFlag,
|
||||
utils.MinerGasPriceFlag,
|
||||
utils.MinerLegacyGasPriceFlag,
|
||||
utils.LegacyMinerGasPriceFlag,
|
||||
utils.MinerEtherbaseFlag,
|
||||
utils.MinerLegacyEtherbaseFlag,
|
||||
utils.LegacyMinerEtherbaseFlag,
|
||||
utils.MinerExtraDataFlag,
|
||||
utils.MinerLegacyExtraDataFlag,
|
||||
utils.LegacyMinerExtraDataFlag,
|
||||
utils.MinerRecommitIntervalFlag,
|
||||
utils.MinerNoVerfiyFlag,
|
||||
utils.NATFlag,
|
||||
@ -146,29 +146,41 @@ var (
|
||||
utils.FakePoWFlag,
|
||||
utils.NoCompactionFlag,
|
||||
utils.GpoBlocksFlag,
|
||||
utils.LegacyGpoBlocksFlag,
|
||||
utils.GpoPercentileFlag,
|
||||
utils.LegacyGpoPercentileFlag,
|
||||
utils.EWASMInterpreterFlag,
|
||||
utils.EVMInterpreterFlag,
|
||||
configFileFlag,
|
||||
}
|
||||
|
||||
rpcFlags = []cli.Flag{
|
||||
utils.RPCEnabledFlag,
|
||||
utils.RPCListenAddrFlag,
|
||||
utils.RPCPortFlag,
|
||||
utils.RPCCORSDomainFlag,
|
||||
utils.RPCVirtualHostsFlag,
|
||||
utils.HTTPEnabledFlag,
|
||||
utils.HTTPListenAddrFlag,
|
||||
utils.HTTPPortFlag,
|
||||
utils.HTTPCORSDomainFlag,
|
||||
utils.HTTPVirtualHostsFlag,
|
||||
utils.LegacyRPCEnabledFlag,
|
||||
utils.LegacyRPCListenAddrFlag,
|
||||
utils.LegacyRPCPortFlag,
|
||||
utils.LegacyRPCCORSDomainFlag,
|
||||
utils.LegacyRPCVirtualHostsFlag,
|
||||
utils.GraphQLEnabledFlag,
|
||||
utils.GraphQLListenAddrFlag,
|
||||
utils.GraphQLPortFlag,
|
||||
utils.GraphQLCORSDomainFlag,
|
||||
utils.GraphQLVirtualHostsFlag,
|
||||
utils.RPCApiFlag,
|
||||
utils.HTTPApiFlag,
|
||||
utils.LegacyRPCApiFlag,
|
||||
utils.WSEnabledFlag,
|
||||
utils.WSListenAddrFlag,
|
||||
utils.LegacyWSListenAddrFlag,
|
||||
utils.WSPortFlag,
|
||||
utils.LegacyWSPortFlag,
|
||||
utils.WSApiFlag,
|
||||
utils.LegacyWSApiFlag,
|
||||
utils.WSAllowedOriginsFlag,
|
||||
utils.LegacyWSAllowedOriginsFlag,
|
||||
utils.IPCDisabledFlag,
|
||||
utils.IPCPathFlag,
|
||||
utils.InsecureUnlockAllowedFlag,
|
||||
@ -227,6 +239,8 @@ func init() {
|
||||
dumpConfigCommand,
|
||||
// See retesteth.go
|
||||
retestethCommand,
|
||||
// See cmd/utils/flags_legacy.go
|
||||
utils.ShowDeprecated,
|
||||
}
|
||||
sort.Sort(cli.CommandsByName(app.Commands))
|
||||
|
||||
@ -234,6 +248,7 @@ func init() {
|
||||
app.Flags = append(app.Flags, rpcFlags...)
|
||||
app.Flags = append(app.Flags, consoleFlags...)
|
||||
app.Flags = append(app.Flags, debug.Flags...)
|
||||
app.Flags = append(app.Flags, debug.DeprecatedFlags...)
|
||||
app.Flags = append(app.Flags, whisperFlags...)
|
||||
app.Flags = append(app.Flags, metricsFlags...)
|
||||
|
||||
@ -360,7 +375,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
||||
|
||||
// Set contract backend for ethereum service if local node
|
||||
// is serving LES requests.
|
||||
if ctx.GlobalInt(utils.LightLegacyServFlag.Name) > 0 || ctx.GlobalInt(utils.LightServeFlag.Name) > 0 {
|
||||
if ctx.GlobalInt(utils.LegacyLightServFlag.Name) > 0 || ctx.GlobalInt(utils.LightServeFlag.Name) > 0 {
|
||||
var ethService *eth.Ethereum
|
||||
if err := stack.Service(ðService); err != nil {
|
||||
utils.Fatalf("Failed to retrieve ethereum service: %v", err)
|
||||
@ -445,16 +460,18 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
||||
utils.Fatalf("Ethereum service not running: %v", err)
|
||||
}
|
||||
// Set the gas price to the limits from the CLI and start mining
|
||||
gasprice := utils.GlobalBig(ctx, utils.MinerLegacyGasPriceFlag.Name)
|
||||
if ctx.IsSet(utils.MinerGasPriceFlag.Name) {
|
||||
gasprice = utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
|
||||
gasprice := utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
|
||||
if ctx.GlobalIsSet(utils.LegacyMinerGasPriceFlag.Name) && !ctx.GlobalIsSet(utils.MinerGasPriceFlag.Name) {
|
||||
gasprice = utils.GlobalBig(ctx, utils.LegacyMinerGasPriceFlag.Name)
|
||||
}
|
||||
ethereum.TxPool().SetGasPrice(gasprice)
|
||||
|
||||
threads := ctx.GlobalInt(utils.MinerLegacyThreadsFlag.Name)
|
||||
if ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) {
|
||||
threads = ctx.GlobalInt(utils.MinerThreadsFlag.Name)
|
||||
threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name)
|
||||
if ctx.GlobalIsSet(utils.LegacyMinerThreadsFlag.Name) && !ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) {
|
||||
threads = ctx.GlobalInt(utils.LegacyMinerThreadsFlag.Name)
|
||||
log.Warn("The flag --minerthreads is deprecated and will be removed in the future, please use --miner.threads")
|
||||
}
|
||||
|
||||
if err := ethereum.StartMining(threads); err != nil {
|
||||
utils.Fatalf("Failed to start mining: %v", err)
|
||||
}
|
||||
|
@ -887,8 +887,8 @@ func retesteth(ctx *cli.Context) error {
|
||||
Version: "1.0",
|
||||
},
|
||||
}
|
||||
vhosts := splitAndTrim(ctx.GlobalString(utils.RPCVirtualHostsFlag.Name))
|
||||
cors := splitAndTrim(ctx.GlobalString(utils.RPCCORSDomainFlag.Name))
|
||||
vhosts := splitAndTrim(ctx.GlobalString(utils.HTTPVirtualHostsFlag.Name))
|
||||
cors := splitAndTrim(ctx.GlobalString(utils.HTTPCORSDomainFlag.Name))
|
||||
|
||||
// register apis and create handler stack
|
||||
srv := rpc.NewServer()
|
||||
@ -904,7 +904,7 @@ func retesteth(ctx *cli.Context) error {
|
||||
WriteTimeout: 120 * time.Second,
|
||||
IdleTimeout: 120 * time.Second,
|
||||
}
|
||||
httpEndpoint := fmt.Sprintf("%s:%d", ctx.GlobalString(utils.RPCListenAddrFlag.Name), ctx.Int(rpcPortFlag.Name))
|
||||
httpEndpoint := fmt.Sprintf("%s:%d", ctx.GlobalString(utils.HTTPListenAddrFlag.Name), ctx.Int(rpcPortFlag.Name))
|
||||
httpServer, _, err := node.StartHTTPEndpoint(httpEndpoint, RetestethHTTPTimeouts, handler)
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not start RPC api: %v", err)
|
||||
|
@ -157,13 +157,12 @@ var AppHelpFlagGroups = []flagGroup{
|
||||
Flags: []cli.Flag{
|
||||
utils.IPCDisabledFlag,
|
||||
utils.IPCPathFlag,
|
||||
utils.RPCEnabledFlag,
|
||||
utils.RPCListenAddrFlag,
|
||||
utils.RPCPortFlag,
|
||||
utils.RPCApiFlag,
|
||||
utils.RPCGlobalGasCap,
|
||||
utils.RPCCORSDomainFlag,
|
||||
utils.RPCVirtualHostsFlag,
|
||||
utils.HTTPEnabledFlag,
|
||||
utils.HTTPListenAddrFlag,
|
||||
utils.HTTPPortFlag,
|
||||
utils.HTTPApiFlag,
|
||||
utils.HTTPCORSDomainFlag,
|
||||
utils.HTTPVirtualHostsFlag,
|
||||
utils.WSEnabledFlag,
|
||||
utils.WSListenAddrFlag,
|
||||
utils.WSPortFlag,
|
||||
@ -174,6 +173,7 @@ var AppHelpFlagGroups = []flagGroup{
|
||||
utils.GraphQLPortFlag,
|
||||
utils.GraphQLCORSDomainFlag,
|
||||
utils.GraphQLVirtualHostsFlag,
|
||||
utils.RPCGlobalGasCap,
|
||||
utils.JSpathFlag,
|
||||
utils.ExecFlag,
|
||||
utils.PreloadJSFlag,
|
||||
@ -243,20 +243,28 @@ var AppHelpFlagGroups = []flagGroup{
|
||||
Flags: whisperFlags,
|
||||
},
|
||||
{
|
||||
Name: "DEPRECATED",
|
||||
Flags: []cli.Flag{
|
||||
utils.LegacyTestnetFlag,
|
||||
utils.LightLegacyServFlag,
|
||||
utils.LightLegacyPeersFlag,
|
||||
utils.MinerLegacyThreadsFlag,
|
||||
utils.MinerLegacyGasTargetFlag,
|
||||
utils.MinerLegacyGasPriceFlag,
|
||||
utils.MinerLegacyEtherbaseFlag,
|
||||
utils.MinerLegacyExtraDataFlag,
|
||||
},
|
||||
Name: "ALIASED (deprecated)",
|
||||
Flags: append([]cli.Flag{
|
||||
utils.LegacyRPCEnabledFlag,
|
||||
utils.LegacyRPCListenAddrFlag,
|
||||
utils.LegacyRPCPortFlag,
|
||||
utils.LegacyRPCCORSDomainFlag,
|
||||
utils.LegacyRPCVirtualHostsFlag,
|
||||
utils.LegacyRPCApiFlag,
|
||||
utils.LegacyWSListenAddrFlag,
|
||||
utils.LegacyWSPortFlag,
|
||||
utils.LegacyWSAllowedOriginsFlag,
|
||||
utils.LegacyWSApiFlag,
|
||||
utils.LegacyGpoBlocksFlag,
|
||||
utils.LegacyGpoPercentileFlag,
|
||||
}, debug.DeprecatedFlags...),
|
||||
},
|
||||
{
|
||||
Name: "MISC",
|
||||
Flags: []cli.Flag{
|
||||
utils.SnapshotFlag,
|
||||
cli.HelpFlag,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -314,12 +322,19 @@ func init() {
|
||||
categorized[flag.String()] = struct{}{}
|
||||
}
|
||||
}
|
||||
deprecated := make(map[string]struct{})
|
||||
for _, flag := range utils.DeprecatedFlags {
|
||||
deprecated[flag.String()] = struct{}{}
|
||||
}
|
||||
// Only add uncategorized flags if they are not deprecated
|
||||
var uncategorized []cli.Flag
|
||||
for _, flag := range data.(*cli.App).Flags {
|
||||
if _, ok := categorized[flag.String()]; !ok {
|
||||
if _, ok := deprecated[flag.String()]; !ok {
|
||||
uncategorized = append(uncategorized, flag)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(uncategorized) > 0 {
|
||||
// Append all ungategorized options to the misc group
|
||||
miscs := len(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags)
|
||||
|
@ -165,10 +165,6 @@ var (
|
||||
Usage: "Network identifier (integer, 1=Frontier, 3=Ropsten, 4=Rinkeby, 5=Görli)",
|
||||
Value: eth.DefaultConfig.NetworkId,
|
||||
}
|
||||
LegacyTestnetFlag = cli.BoolFlag{ // TODO(q9f): Remove after Ropsten is discontinued.
|
||||
Name: "testnet",
|
||||
Usage: "Pre-configured test network (Deprecated: Please choose one of --goerli, --rinkeby, or --ropsten.)",
|
||||
}
|
||||
GoerliFlag = cli.BoolFlag{
|
||||
Name: "goerli",
|
||||
Usage: "Görli network: pre-configured proof-of-authority test network",
|
||||
@ -242,11 +238,6 @@ var (
|
||||
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
|
||||
}
|
||||
// Light server and client settings
|
||||
LightLegacyServFlag = cli.IntFlag{ // Deprecated in favor of light.serve, remove in 2021
|
||||
Name: "lightserv",
|
||||
Usage: "Maximum percentage of time allowed for serving LES requests (deprecated, use --light.serve)",
|
||||
Value: eth.DefaultConfig.LightServ,
|
||||
}
|
||||
LightServeFlag = cli.IntFlag{
|
||||
Name: "light.serve",
|
||||
Usage: "Maximum percentage of time allowed for serving LES requests (multi-threaded processing allows values over 100)",
|
||||
@ -262,11 +253,6 @@ var (
|
||||
Usage: "Outgoing bandwidth limit for serving light clients (kilobytes/sec, 0 = unlimited)",
|
||||
Value: eth.DefaultConfig.LightEgress,
|
||||
}
|
||||
LightLegacyPeersFlag = cli.IntFlag{ // Deprecated in favor of light.maxpeers, remove in 2021
|
||||
Name: "lightpeers",
|
||||
Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)",
|
||||
Value: eth.DefaultConfig.LightPeers,
|
||||
}
|
||||
LightMaxPeersFlag = cli.IntFlag{
|
||||
Name: "light.maxpeers",
|
||||
Usage: "Maximum number of light clients to serve, or light servers to attach to",
|
||||
@ -418,11 +404,6 @@ var (
|
||||
Usage: "Number of CPU threads to use for mining",
|
||||
Value: 0,
|
||||
}
|
||||
MinerLegacyThreadsFlag = cli.IntFlag{
|
||||
Name: "minerthreads",
|
||||
Usage: "Number of CPU threads to use for mining (deprecated, use --miner.threads)",
|
||||
Value: 0,
|
||||
}
|
||||
MinerNotifyFlag = cli.StringFlag{
|
||||
Name: "miner.notify",
|
||||
Usage: "Comma separated HTTP URL list to notify of new work packages",
|
||||
@ -432,11 +413,6 @@ var (
|
||||
Usage: "Target gas floor for mined blocks",
|
||||
Value: eth.DefaultConfig.Miner.GasFloor,
|
||||
}
|
||||
MinerLegacyGasTargetFlag = cli.Uint64Flag{
|
||||
Name: "targetgaslimit",
|
||||
Usage: "Target gas floor for mined blocks (deprecated, use --miner.gastarget)",
|
||||
Value: eth.DefaultConfig.Miner.GasFloor,
|
||||
}
|
||||
MinerGasLimitFlag = cli.Uint64Flag{
|
||||
Name: "miner.gaslimit",
|
||||
Usage: "Target gas ceiling for mined blocks",
|
||||
@ -447,29 +423,15 @@ var (
|
||||
Usage: "Minimum gas price for mining a transaction",
|
||||
Value: eth.DefaultConfig.Miner.GasPrice,
|
||||
}
|
||||
MinerLegacyGasPriceFlag = BigFlag{
|
||||
Name: "gasprice",
|
||||
Usage: "Minimum gas price for mining a transaction (deprecated, use --miner.gasprice)",
|
||||
Value: eth.DefaultConfig.Miner.GasPrice,
|
||||
}
|
||||
MinerEtherbaseFlag = cli.StringFlag{
|
||||
Name: "miner.etherbase",
|
||||
Usage: "Public address for block mining rewards (default = first account)",
|
||||
Value: "0",
|
||||
}
|
||||
MinerLegacyEtherbaseFlag = cli.StringFlag{
|
||||
Name: "etherbase",
|
||||
Usage: "Public address for block mining rewards (default = first account, deprecated, use --miner.etherbase)",
|
||||
Value: "0",
|
||||
}
|
||||
MinerExtraDataFlag = cli.StringFlag{
|
||||
Name: "miner.extradata",
|
||||
Usage: "Block extra data set by the miner (default = client version)",
|
||||
}
|
||||
MinerLegacyExtraDataFlag = cli.StringFlag{
|
||||
Name: "extradata",
|
||||
Usage: "Block extra data set by the miner (default = client version, deprecated, use --miner.extradata)",
|
||||
}
|
||||
MinerRecommitIntervalFlag = cli.DurationFlag{
|
||||
Name: "miner.recommit",
|
||||
Usage: "Time interval to recreate the block being mined",
|
||||
@ -529,32 +491,32 @@ var (
|
||||
Name: "ipcpath",
|
||||
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
|
||||
}
|
||||
RPCEnabledFlag = cli.BoolFlag{
|
||||
Name: "rpc",
|
||||
HTTPEnabledFlag = cli.BoolFlag{
|
||||
Name: "http",
|
||||
Usage: "Enable the HTTP-RPC server",
|
||||
}
|
||||
RPCListenAddrFlag = cli.StringFlag{
|
||||
Name: "rpcaddr",
|
||||
HTTPListenAddrFlag = cli.StringFlag{
|
||||
Name: "http.addr",
|
||||
Usage: "HTTP-RPC server listening interface",
|
||||
Value: node.DefaultHTTPHost,
|
||||
}
|
||||
RPCPortFlag = cli.IntFlag{
|
||||
Name: "rpcport",
|
||||
HTTPPortFlag = cli.IntFlag{
|
||||
Name: "http.port",
|
||||
Usage: "HTTP-RPC server listening port",
|
||||
Value: node.DefaultHTTPPort,
|
||||
}
|
||||
RPCCORSDomainFlag = cli.StringFlag{
|
||||
Name: "rpccorsdomain",
|
||||
HTTPCORSDomainFlag = cli.StringFlag{
|
||||
Name: "http.corsdomain",
|
||||
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
|
||||
Value: "",
|
||||
}
|
||||
RPCVirtualHostsFlag = cli.StringFlag{
|
||||
Name: "rpcvhosts",
|
||||
HTTPVirtualHostsFlag = cli.StringFlag{
|
||||
Name: "http.vhosts",
|
||||
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
|
||||
Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","),
|
||||
}
|
||||
RPCApiFlag = cli.StringFlag{
|
||||
Name: "rpcapi",
|
||||
HTTPApiFlag = cli.StringFlag{
|
||||
Name: "http.api",
|
||||
Usage: "API's offered over the HTTP-RPC interface",
|
||||
Value: "",
|
||||
}
|
||||
@ -563,22 +525,22 @@ var (
|
||||
Usage: "Enable the WS-RPC server",
|
||||
}
|
||||
WSListenAddrFlag = cli.StringFlag{
|
||||
Name: "wsaddr",
|
||||
Name: "ws.addr",
|
||||
Usage: "WS-RPC server listening interface",
|
||||
Value: node.DefaultWSHost,
|
||||
}
|
||||
WSPortFlag = cli.IntFlag{
|
||||
Name: "wsport",
|
||||
Name: "ws.port",
|
||||
Usage: "WS-RPC server listening port",
|
||||
Value: node.DefaultWSPort,
|
||||
}
|
||||
WSApiFlag = cli.StringFlag{
|
||||
Name: "wsapi",
|
||||
Name: "ws.api",
|
||||
Usage: "API's offered over the WS-RPC interface",
|
||||
Value: "",
|
||||
}
|
||||
WSAllowedOriginsFlag = cli.StringFlag{
|
||||
Name: "wsorigins",
|
||||
Name: "ws.origins",
|
||||
Usage: "Origins from which to accept websockets requests",
|
||||
Value: "",
|
||||
}
|
||||
@ -685,12 +647,12 @@ var (
|
||||
|
||||
// Gas price oracle settings
|
||||
GpoBlocksFlag = cli.IntFlag{
|
||||
Name: "gpoblocks",
|
||||
Name: "gpo.blocks",
|
||||
Usage: "Number of recent blocks to check for gas prices",
|
||||
Value: eth.DefaultConfig.GPO.Blocks,
|
||||
}
|
||||
GpoPercentileFlag = cli.IntFlag{
|
||||
Name: "gpopercentile",
|
||||
Name: "gpo.percentile",
|
||||
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices",
|
||||
Value: eth.DefaultConfig.GPO.Percentile,
|
||||
}
|
||||
@ -924,23 +886,51 @@ func splitAndTrim(input string) []string {
|
||||
// setHTTP creates the HTTP RPC listener interface string from the set
|
||||
// command line flags, returning empty if the HTTP endpoint is disabled.
|
||||
func setHTTP(ctx *cli.Context, cfg *node.Config) {
|
||||
if ctx.GlobalBool(RPCEnabledFlag.Name) && cfg.HTTPHost == "" {
|
||||
if ctx.GlobalBool(LegacyRPCEnabledFlag.Name) && cfg.HTTPHost == "" {
|
||||
log.Warn("The flag --rpc is deprecated and will be removed in the future, please use --http")
|
||||
cfg.HTTPHost = "127.0.0.1"
|
||||
if ctx.GlobalIsSet(RPCListenAddrFlag.Name) {
|
||||
cfg.HTTPHost = ctx.GlobalString(RPCListenAddrFlag.Name)
|
||||
if ctx.GlobalIsSet(LegacyRPCListenAddrFlag.Name) {
|
||||
cfg.HTTPHost = ctx.GlobalString(LegacyRPCListenAddrFlag.Name)
|
||||
log.Warn("The flag --rpcaddr is deprecated and will be removed in the future, please use --http.addr")
|
||||
}
|
||||
}
|
||||
if ctx.GlobalIsSet(RPCPortFlag.Name) {
|
||||
cfg.HTTPPort = ctx.GlobalInt(RPCPortFlag.Name)
|
||||
if ctx.GlobalBool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" {
|
||||
cfg.HTTPHost = "127.0.0.1"
|
||||
if ctx.GlobalIsSet(HTTPListenAddrFlag.Name) {
|
||||
cfg.HTTPHost = ctx.GlobalString(HTTPListenAddrFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(RPCCORSDomainFlag.Name) {
|
||||
cfg.HTTPCors = splitAndTrim(ctx.GlobalString(RPCCORSDomainFlag.Name))
|
||||
}
|
||||
if ctx.GlobalIsSet(RPCApiFlag.Name) {
|
||||
cfg.HTTPModules = splitAndTrim(ctx.GlobalString(RPCApiFlag.Name))
|
||||
|
||||
if ctx.GlobalIsSet(LegacyRPCPortFlag.Name) {
|
||||
cfg.HTTPPort = ctx.GlobalInt(LegacyRPCPortFlag.Name)
|
||||
log.Warn("The flag --rpcport is deprecated and will be removed in the future, please use --http.port")
|
||||
}
|
||||
if ctx.GlobalIsSet(RPCVirtualHostsFlag.Name) {
|
||||
cfg.HTTPVirtualHosts = splitAndTrim(ctx.GlobalString(RPCVirtualHostsFlag.Name))
|
||||
if ctx.GlobalIsSet(HTTPPortFlag.Name) {
|
||||
cfg.HTTPPort = ctx.GlobalInt(HTTPPortFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(LegacyRPCCORSDomainFlag.Name) {
|
||||
cfg.HTTPCors = splitAndTrim(ctx.GlobalString(LegacyRPCCORSDomainFlag.Name))
|
||||
log.Warn("The flag --rpccorsdomain is deprecated and will be removed in the future, please use --http.corsdomain")
|
||||
}
|
||||
if ctx.GlobalIsSet(HTTPCORSDomainFlag.Name) {
|
||||
cfg.HTTPCors = splitAndTrim(ctx.GlobalString(HTTPCORSDomainFlag.Name))
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(LegacyRPCApiFlag.Name) {
|
||||
cfg.HTTPModules = splitAndTrim(ctx.GlobalString(LegacyRPCApiFlag.Name))
|
||||
log.Warn("The flag --rpcapi is deprecated and will be removed in the future, please use --http.api")
|
||||
}
|
||||
if ctx.GlobalIsSet(HTTPApiFlag.Name) {
|
||||
cfg.HTTPModules = splitAndTrim(ctx.GlobalString(HTTPApiFlag.Name))
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(LegacyRPCVirtualHostsFlag.Name) {
|
||||
cfg.HTTPVirtualHosts = splitAndTrim(ctx.GlobalString(LegacyRPCVirtualHostsFlag.Name))
|
||||
log.Warn("The flag --rpcvhosts is deprecated and will be removed in the future, please use --http.vhosts")
|
||||
}
|
||||
if ctx.GlobalIsSet(HTTPVirtualHostsFlag.Name) {
|
||||
cfg.HTTPVirtualHosts = splitAndTrim(ctx.GlobalString(HTTPVirtualHostsFlag.Name))
|
||||
}
|
||||
}
|
||||
|
||||
@ -967,16 +957,34 @@ func setGraphQL(ctx *cli.Context, cfg *node.Config) {
|
||||
func setWS(ctx *cli.Context, cfg *node.Config) {
|
||||
if ctx.GlobalBool(WSEnabledFlag.Name) && cfg.WSHost == "" {
|
||||
cfg.WSHost = "127.0.0.1"
|
||||
if ctx.GlobalIsSet(LegacyWSListenAddrFlag.Name) {
|
||||
cfg.WSHost = ctx.GlobalString(LegacyWSListenAddrFlag.Name)
|
||||
log.Warn("The flag --wsaddr is deprecated and will be removed in the future, please use --ws.addr")
|
||||
}
|
||||
if ctx.GlobalIsSet(WSListenAddrFlag.Name) {
|
||||
cfg.WSHost = ctx.GlobalString(WSListenAddrFlag.Name)
|
||||
}
|
||||
}
|
||||
if ctx.GlobalIsSet(LegacyWSPortFlag.Name) {
|
||||
cfg.WSPort = ctx.GlobalInt(LegacyWSPortFlag.Name)
|
||||
log.Warn("The flag --wsport is deprecated and will be removed in the future, please use --ws.port")
|
||||
}
|
||||
if ctx.GlobalIsSet(WSPortFlag.Name) {
|
||||
cfg.WSPort = ctx.GlobalInt(WSPortFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(LegacyWSAllowedOriginsFlag.Name) {
|
||||
cfg.WSOrigins = splitAndTrim(ctx.GlobalString(LegacyWSAllowedOriginsFlag.Name))
|
||||
log.Warn("The flag --wsorigins is deprecated and will be removed in the future, please use --ws.origins")
|
||||
}
|
||||
if ctx.GlobalIsSet(WSAllowedOriginsFlag.Name) {
|
||||
cfg.WSOrigins = splitAndTrim(ctx.GlobalString(WSAllowedOriginsFlag.Name))
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(LegacyWSApiFlag.Name) {
|
||||
cfg.WSModules = splitAndTrim(ctx.GlobalString(LegacyWSApiFlag.Name))
|
||||
log.Warn("The flag --wsapi is deprecated and will be removed in the future, please use --ws.api")
|
||||
}
|
||||
if ctx.GlobalIsSet(WSApiFlag.Name) {
|
||||
cfg.WSModules = splitAndTrim(ctx.GlobalString(WSApiFlag.Name))
|
||||
}
|
||||
@ -996,8 +1004,9 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
|
||||
|
||||
// setLes configures the les server and ultra light client settings from the command line flags.
|
||||
func setLes(ctx *cli.Context, cfg *eth.Config) {
|
||||
if ctx.GlobalIsSet(LightLegacyServFlag.Name) {
|
||||
cfg.LightServ = ctx.GlobalInt(LightLegacyServFlag.Name)
|
||||
if ctx.GlobalIsSet(LegacyLightServFlag.Name) {
|
||||
cfg.LightServ = ctx.GlobalInt(LegacyLightServFlag.Name)
|
||||
log.Warn("The flag --lightserv is deprecated and will be removed in the future, please use --light.serve")
|
||||
}
|
||||
if ctx.GlobalIsSet(LightServeFlag.Name) {
|
||||
cfg.LightServ = ctx.GlobalInt(LightServeFlag.Name)
|
||||
@ -1008,8 +1017,9 @@ func setLes(ctx *cli.Context, cfg *eth.Config) {
|
||||
if ctx.GlobalIsSet(LightEgressFlag.Name) {
|
||||
cfg.LightEgress = ctx.GlobalInt(LightEgressFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(LightLegacyPeersFlag.Name) {
|
||||
cfg.LightPeers = ctx.GlobalInt(LightLegacyPeersFlag.Name)
|
||||
if ctx.GlobalIsSet(LegacyLightPeersFlag.Name) {
|
||||
cfg.LightPeers = ctx.GlobalInt(LegacyLightPeersFlag.Name)
|
||||
log.Warn("The flag --lightpeers is deprecated and will be removed in the future, please use --light.maxpeers")
|
||||
}
|
||||
if ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
|
||||
cfg.LightPeers = ctx.GlobalInt(LightMaxPeersFlag.Name)
|
||||
@ -1073,8 +1083,10 @@ func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error
|
||||
func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
|
||||
// Extract the current etherbase, new flag overriding legacy one
|
||||
var etherbase string
|
||||
if ctx.GlobalIsSet(MinerLegacyEtherbaseFlag.Name) {
|
||||
etherbase = ctx.GlobalString(MinerLegacyEtherbaseFlag.Name)
|
||||
if ctx.GlobalIsSet(LegacyMinerEtherbaseFlag.Name) {
|
||||
etherbase = ctx.GlobalString(LegacyMinerEtherbaseFlag.Name)
|
||||
log.Warn("The flag --etherbase is deprecated and will be removed in the future, please use --miner.etherbase")
|
||||
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerEtherbaseFlag.Name) {
|
||||
etherbase = ctx.GlobalString(MinerEtherbaseFlag.Name)
|
||||
@ -1119,27 +1131,27 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
|
||||
setBootstrapNodesV5(ctx, cfg)
|
||||
|
||||
lightClient := ctx.GlobalString(SyncModeFlag.Name) == "light"
|
||||
lightServer := (ctx.GlobalInt(LightLegacyServFlag.Name) != 0 || ctx.GlobalInt(LightServeFlag.Name) != 0)
|
||||
lightServer := (ctx.GlobalInt(LegacyLightServFlag.Name) != 0 || ctx.GlobalInt(LightServeFlag.Name) != 0)
|
||||
|
||||
lightPeers := ctx.GlobalInt(LightLegacyPeersFlag.Name)
|
||||
lightPeers := ctx.GlobalInt(LegacyLightPeersFlag.Name)
|
||||
if ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
|
||||
lightPeers = ctx.GlobalInt(LightMaxPeersFlag.Name)
|
||||
}
|
||||
if lightClient && !ctx.GlobalIsSet(LightLegacyPeersFlag.Name) && !ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
|
||||
if lightClient && !ctx.GlobalIsSet(LegacyLightPeersFlag.Name) && !ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
|
||||
// dynamic default - for clients we use 1/10th of the default for servers
|
||||
lightPeers /= 10
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(MaxPeersFlag.Name) {
|
||||
cfg.MaxPeers = ctx.GlobalInt(MaxPeersFlag.Name)
|
||||
if lightServer && !ctx.GlobalIsSet(LightLegacyPeersFlag.Name) && !ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
|
||||
if lightServer && !ctx.GlobalIsSet(LegacyLightPeersFlag.Name) && !ctx.GlobalIsSet(LightMaxPeersFlag.Name) {
|
||||
cfg.MaxPeers += lightPeers
|
||||
}
|
||||
} else {
|
||||
if lightServer {
|
||||
cfg.MaxPeers += lightPeers
|
||||
}
|
||||
if lightClient && (ctx.GlobalIsSet(LightLegacyPeersFlag.Name) || ctx.GlobalIsSet(LightMaxPeersFlag.Name)) && cfg.MaxPeers < lightPeers {
|
||||
if lightClient && (ctx.GlobalIsSet(LegacyLightPeersFlag.Name) || ctx.GlobalIsSet(LightMaxPeersFlag.Name)) && cfg.MaxPeers < lightPeers {
|
||||
cfg.MaxPeers = lightPeers
|
||||
}
|
||||
}
|
||||
@ -1259,9 +1271,18 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
|
||||
}
|
||||
|
||||
func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
|
||||
if ctx.GlobalIsSet(LegacyGpoBlocksFlag.Name) {
|
||||
cfg.Blocks = ctx.GlobalInt(LegacyGpoBlocksFlag.Name)
|
||||
log.Warn("The flag --gpoblocks is deprecated and will be removed in the future, please use --gpo.blocks")
|
||||
}
|
||||
if ctx.GlobalIsSet(GpoBlocksFlag.Name) {
|
||||
cfg.Blocks = ctx.GlobalInt(GpoBlocksFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(LegacyGpoPercentileFlag.Name) {
|
||||
cfg.Percentile = ctx.GlobalInt(LegacyGpoPercentileFlag.Name)
|
||||
log.Warn("The flag --gpopercentile is deprecated and will be removed in the future, please use --gpo.percentile")
|
||||
}
|
||||
if ctx.GlobalIsSet(GpoPercentileFlag.Name) {
|
||||
cfg.Percentile = ctx.GlobalInt(GpoPercentileFlag.Name)
|
||||
}
|
||||
@ -1341,14 +1362,16 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
|
||||
if ctx.GlobalIsSet(MinerNotifyFlag.Name) {
|
||||
cfg.Notify = strings.Split(ctx.GlobalString(MinerNotifyFlag.Name), ",")
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerLegacyExtraDataFlag.Name) {
|
||||
cfg.ExtraData = []byte(ctx.GlobalString(MinerLegacyExtraDataFlag.Name))
|
||||
if ctx.GlobalIsSet(LegacyMinerExtraDataFlag.Name) {
|
||||
cfg.ExtraData = []byte(ctx.GlobalString(LegacyMinerExtraDataFlag.Name))
|
||||
log.Warn("The flag --extradata is deprecated and will be removed in the future, please use --miner.extradata")
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerExtraDataFlag.Name) {
|
||||
cfg.ExtraData = []byte(ctx.GlobalString(MinerExtraDataFlag.Name))
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerLegacyGasTargetFlag.Name) {
|
||||
cfg.GasFloor = ctx.GlobalUint64(MinerLegacyGasTargetFlag.Name)
|
||||
if ctx.GlobalIsSet(LegacyMinerGasTargetFlag.Name) {
|
||||
cfg.GasFloor = ctx.GlobalUint64(LegacyMinerGasTargetFlag.Name)
|
||||
log.Warn("The flag --targetgaslimit is deprecated and will be removed in the future, please use --miner.gastarget")
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerGasTargetFlag.Name) {
|
||||
cfg.GasFloor = ctx.GlobalUint64(MinerGasTargetFlag.Name)
|
||||
@ -1356,8 +1379,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
|
||||
if ctx.GlobalIsSet(MinerGasLimitFlag.Name) {
|
||||
cfg.GasCeil = ctx.GlobalUint64(MinerGasLimitFlag.Name)
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) {
|
||||
cfg.GasPrice = GlobalBig(ctx, MinerLegacyGasPriceFlag.Name)
|
||||
if ctx.GlobalIsSet(LegacyMinerGasPriceFlag.Name) {
|
||||
cfg.GasPrice = GlobalBig(ctx, LegacyMinerGasPriceFlag.Name)
|
||||
log.Warn("The flag --gasprice is deprecated and will be removed in the future, please use --miner.gasprice")
|
||||
}
|
||||
if ctx.GlobalIsSet(MinerGasPriceFlag.Name) {
|
||||
cfg.GasPrice = GlobalBig(ctx, MinerGasPriceFlag.Name)
|
||||
@ -1451,7 +1475,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
|
||||
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
||||
// Avoid conflicting network flags
|
||||
CheckExclusive(ctx, DeveloperFlag, LegacyTestnetFlag, RopstenFlag, RinkebyFlag, GoerliFlag)
|
||||
CheckExclusive(ctx, LightLegacyServFlag, LightServeFlag, SyncModeFlag, "light")
|
||||
CheckExclusive(ctx, LegacyLightServFlag, LightServeFlag, SyncModeFlag, "light")
|
||||
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
|
||||
|
||||
var ks *keystore.KeyStore
|
||||
@ -1571,7 +1595,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
||||
log.Info("Using developer account", "address", developer.Address)
|
||||
|
||||
cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address)
|
||||
if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(MinerLegacyGasPriceFlag.Name) {
|
||||
if !ctx.GlobalIsSet(MinerGasPriceFlag.Name) && !ctx.GlobalIsSet(LegacyMinerGasPriceFlag.Name) {
|
||||
cfg.Miner.GasPrice = big.NewInt(1)
|
||||
}
|
||||
default:
|
||||
|
163
cmd/utils/flags_legacy.go
Normal file
163
cmd/utils/flags_legacy.go
Normal file
@ -0,0 +1,163 @@
|
||||
// Copyright 2020 The go-ethereum Authors
|
||||
// This file is part of go-ethereum.
|
||||
//
|
||||
// go-ethereum is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// go-ethereum 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"gopkg.in/urfave/cli.v1"
|
||||
)
|
||||
|
||||
var ShowDeprecated = cli.Command{
|
||||
Action: showDeprecated,
|
||||
Name: "show-deprecated-flags",
|
||||
Usage: "Show flags that have been deprecated",
|
||||
ArgsUsage: " ",
|
||||
Category: "MISCELLANEOUS COMMANDS",
|
||||
Description: "Show flags that have been deprecated and will soon be removed",
|
||||
}
|
||||
|
||||
var DeprecatedFlags = []cli.Flag{
|
||||
LegacyTestnetFlag,
|
||||
LegacyLightServFlag,
|
||||
LegacyLightPeersFlag,
|
||||
LegacyMinerThreadsFlag,
|
||||
LegacyMinerGasTargetFlag,
|
||||
LegacyMinerGasPriceFlag,
|
||||
LegacyMinerEtherbaseFlag,
|
||||
LegacyMinerExtraDataFlag,
|
||||
}
|
||||
|
||||
var (
|
||||
// (Deprecated April 2018)
|
||||
LegacyMinerThreadsFlag = cli.IntFlag{
|
||||
Name: "minerthreads",
|
||||
Usage: "Number of CPU threads to use for mining (deprecated, use --miner.threads)",
|
||||
Value: 0,
|
||||
}
|
||||
LegacyMinerGasTargetFlag = cli.Uint64Flag{
|
||||
Name: "targetgaslimit",
|
||||
Usage: "Target gas floor for mined blocks (deprecated, use --miner.gastarget)",
|
||||
Value: eth.DefaultConfig.Miner.GasFloor,
|
||||
}
|
||||
LegacyMinerGasPriceFlag = BigFlag{
|
||||
Name: "gasprice",
|
||||
Usage: "Minimum gas price for mining a transaction (deprecated, use --miner.gasprice)",
|
||||
Value: eth.DefaultConfig.Miner.GasPrice,
|
||||
}
|
||||
LegacyMinerEtherbaseFlag = cli.StringFlag{
|
||||
Name: "etherbase",
|
||||
Usage: "Public address for block mining rewards (default = first account, deprecated, use --miner.etherbase)",
|
||||
Value: "0",
|
||||
}
|
||||
LegacyMinerExtraDataFlag = cli.StringFlag{
|
||||
Name: "extradata",
|
||||
Usage: "Block extra data set by the miner (default = client version, deprecated, use --miner.extradata)",
|
||||
}
|
||||
|
||||
// (Deprecated June 2019)
|
||||
LegacyLightServFlag = cli.IntFlag{
|
||||
Name: "lightserv",
|
||||
Usage: "Maximum percentage of time allowed for serving LES requests (deprecated, use --light.serve)",
|
||||
Value: eth.DefaultConfig.LightServ,
|
||||
}
|
||||
LegacyLightPeersFlag = cli.IntFlag{
|
||||
Name: "lightpeers",
|
||||
Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated, use --light.maxpeers)",
|
||||
Value: eth.DefaultConfig.LightPeers,
|
||||
}
|
||||
|
||||
// (Deprecated April 2020)
|
||||
LegacyTestnetFlag = cli.BoolFlag{ // TODO(q9f): Remove after Ropsten is discontinued.
|
||||
Name: "testnet",
|
||||
Usage: "Pre-configured test network (Deprecated: Please choose one of --goerli, --rinkeby, or --ropsten.)",
|
||||
}
|
||||
LegacyRPCEnabledFlag = cli.BoolFlag{
|
||||
Name: "rpc",
|
||||
Usage: "Enable the HTTP-RPC server (deprecated, use --http)",
|
||||
}
|
||||
LegacyRPCListenAddrFlag = cli.StringFlag{
|
||||
Name: "rpcaddr",
|
||||
Usage: "HTTP-RPC server listening interface (deprecated, use --http.addr)",
|
||||
Value: node.DefaultHTTPHost,
|
||||
}
|
||||
LegacyRPCPortFlag = cli.IntFlag{
|
||||
Name: "rpcport",
|
||||
Usage: "HTTP-RPC server listening port (deprecated, use --http.port)",
|
||||
Value: node.DefaultHTTPPort,
|
||||
}
|
||||
LegacyRPCCORSDomainFlag = cli.StringFlag{
|
||||
Name: "rpccorsdomain",
|
||||
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced) (deprecated, use --http.corsdomain)",
|
||||
Value: "",
|
||||
}
|
||||
LegacyRPCVirtualHostsFlag = cli.StringFlag{
|
||||
Name: "rpcvhosts",
|
||||
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (deprecated, use --http.vhosts)",
|
||||
Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","),
|
||||
}
|
||||
LegacyRPCApiFlag = cli.StringFlag{
|
||||
Name: "rpcapi",
|
||||
Usage: "API's offered over the HTTP-RPC interface (deprecated, use --http.api)",
|
||||
Value: "",
|
||||
}
|
||||
LegacyWSListenAddrFlag = cli.StringFlag{
|
||||
Name: "wsaddr",
|
||||
Usage: "WS-RPC server listening interface (deprecated, use --ws.addr)",
|
||||
Value: node.DefaultWSHost,
|
||||
}
|
||||
LegacyWSPortFlag = cli.IntFlag{
|
||||
Name: "wsport",
|
||||
Usage: "WS-RPC server listening port (deprecated, use --ws.port)",
|
||||
Value: node.DefaultWSPort,
|
||||
}
|
||||
LegacyWSApiFlag = cli.StringFlag{
|
||||
Name: "wsapi",
|
||||
Usage: "API's offered over the WS-RPC interface (deprecated, use --ws.api)",
|
||||
Value: "",
|
||||
}
|
||||
LegacyWSAllowedOriginsFlag = cli.StringFlag{
|
||||
Name: "wsorigins",
|
||||
Usage: "Origins from which to accept websockets requests (deprecated, use --ws.origins)",
|
||||
Value: "",
|
||||
}
|
||||
LegacyGpoBlocksFlag = cli.IntFlag{
|
||||
Name: "gpoblocks",
|
||||
Usage: "Number of recent blocks to check for gas prices (deprecated, use --gpo.blocks)",
|
||||
Value: eth.DefaultConfig.GPO.Blocks,
|
||||
}
|
||||
LegacyGpoPercentileFlag = cli.IntFlag{
|
||||
Name: "gpopercentile",
|
||||
Usage: "Suggested gas price is the given percentile of a set of recent transaction gas prices (deprecated, use --gpo.percentile)",
|
||||
Value: eth.DefaultConfig.GPO.Percentile,
|
||||
}
|
||||
)
|
||||
|
||||
// showDeprecated displays deprecated flags that will be soon removed from the codebase.
|
||||
func showDeprecated(*cli.Context) {
|
||||
fmt.Println("--------------------------------------------------------------------")
|
||||
fmt.Println("The following flags are deprecated and will be removed in the future!")
|
||||
fmt.Println("--------------------------------------------------------------------")
|
||||
fmt.Println()
|
||||
|
||||
for _, flag := range DeprecatedFlags {
|
||||
fmt.Println(flag.String())
|
||||
}
|
||||
}
|
@ -60,39 +60,68 @@ var (
|
||||
Usage: "Enable the pprof HTTP server",
|
||||
}
|
||||
pprofPortFlag = cli.IntFlag{
|
||||
Name: "pprofport",
|
||||
Name: "pprof.port",
|
||||
Usage: "pprof HTTP server listening port",
|
||||
Value: 6060,
|
||||
}
|
||||
pprofAddrFlag = cli.StringFlag{
|
||||
Name: "pprofaddr",
|
||||
Name: "pprof.addr",
|
||||
Usage: "pprof HTTP server listening interface",
|
||||
Value: "127.0.0.1",
|
||||
}
|
||||
memprofilerateFlag = cli.IntFlag{
|
||||
Name: "memprofilerate",
|
||||
Name: "pprof.memprofilerate",
|
||||
Usage: "Turn on memory profiling with the given rate",
|
||||
Value: runtime.MemProfileRate,
|
||||
}
|
||||
blockprofilerateFlag = cli.IntFlag{
|
||||
Name: "blockprofilerate",
|
||||
Name: "pprof.blockprofilerate",
|
||||
Usage: "Turn on block profiling with the given rate",
|
||||
}
|
||||
cpuprofileFlag = cli.StringFlag{
|
||||
Name: "cpuprofile",
|
||||
Name: "pprof.cpuprofile",
|
||||
Usage: "Write CPU profile to the given file",
|
||||
}
|
||||
traceFlag = cli.StringFlag{
|
||||
Name: "trace",
|
||||
Usage: "Write execution trace to the given file",
|
||||
}
|
||||
// (Deprecated April 2020)
|
||||
legacyPprofPortFlag = cli.IntFlag{
|
||||
Name: "pprofport",
|
||||
Usage: "pprof HTTP server listening port (deprecated, use --pprof.port)",
|
||||
Value: 6060,
|
||||
}
|
||||
legacyPprofAddrFlag = cli.StringFlag{
|
||||
Name: "pprofaddr",
|
||||
Usage: "pprof HTTP server listening interface (deprecated, use --pprof.addr)",
|
||||
Value: "127.0.0.1",
|
||||
}
|
||||
legacyMemprofilerateFlag = cli.IntFlag{
|
||||
Name: "memprofilerate",
|
||||
Usage: "Turn on memory profiling with the given rate (deprecated, use --pprof.memprofilerate)",
|
||||
Value: runtime.MemProfileRate,
|
||||
}
|
||||
legacyBlockprofilerateFlag = cli.IntFlag{
|
||||
Name: "blockprofilerate",
|
||||
Usage: "Turn on block profiling with the given rate (deprecated, use --pprof.blockprofilerate)",
|
||||
}
|
||||
legacyCpuprofileFlag = cli.StringFlag{
|
||||
Name: "cpuprofile",
|
||||
Usage: "Write CPU profile to the given file (deprecated, use --pprof.cpuprofile)",
|
||||
}
|
||||
)
|
||||
|
||||
// Flags holds all command-line flags required for debugging.
|
||||
var Flags = []cli.Flag{
|
||||
verbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
|
||||
pprofFlag, pprofAddrFlag, pprofPortFlag,
|
||||
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
|
||||
pprofFlag, pprofAddrFlag, pprofPortFlag, memprofilerateFlag,
|
||||
blockprofilerateFlag, cpuprofileFlag, traceFlag,
|
||||
}
|
||||
|
||||
var DeprecatedFlags = []cli.Flag{
|
||||
legacyPprofPortFlag, legacyPprofAddrFlag, legacyMemprofilerateFlag,
|
||||
legacyBlockprofilerateFlag, legacyCpuprofileFlag,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -121,22 +150,51 @@ func Setup(ctx *cli.Context) error {
|
||||
log.Root().SetHandler(glogger)
|
||||
|
||||
// profiling, tracing
|
||||
if ctx.GlobalIsSet(legacyMemprofilerateFlag.Name) {
|
||||
runtime.MemProfileRate = ctx.GlobalInt(legacyMemprofilerateFlag.Name)
|
||||
log.Warn("The flag --memprofilerate is deprecated and will be removed in the future, please use --pprof.memprofilerate")
|
||||
}
|
||||
runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name)
|
||||
|
||||
if ctx.GlobalIsSet(legacyBlockprofilerateFlag.Name) {
|
||||
Handler.SetBlockProfileRate(ctx.GlobalInt(legacyBlockprofilerateFlag.Name))
|
||||
log.Warn("The flag --blockprofilerate is deprecated and will be removed in the future, please use --pprof.blockprofilerate")
|
||||
}
|
||||
Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name))
|
||||
|
||||
if traceFile := ctx.GlobalString(traceFlag.Name); traceFile != "" {
|
||||
if err := Handler.StartGoTrace(traceFile); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if cpuFile := ctx.GlobalString(cpuprofileFlag.Name); cpuFile != "" {
|
||||
if err := Handler.StartCPUProfile(cpuFile); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if cpuFile := ctx.GlobalString(legacyCpuprofileFlag.Name); cpuFile != "" {
|
||||
log.Warn("The flag --cpuprofile is deprecated and will be removed in the future, please use --pprof.cpuprofile")
|
||||
if err := Handler.StartCPUProfile(cpuFile); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// pprof server
|
||||
if ctx.GlobalBool(pprofFlag.Name) {
|
||||
address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name))
|
||||
listenHost := ctx.GlobalString(pprofAddrFlag.Name)
|
||||
if ctx.GlobalIsSet(legacyPprofAddrFlag.Name) && !ctx.GlobalIsSet(pprofAddrFlag.Name) {
|
||||
listenHost = ctx.GlobalString(legacyPprofAddrFlag.Name)
|
||||
log.Warn("The flag --pprofaddr is deprecated and will be removed in the future, please use --pprof.addr")
|
||||
}
|
||||
|
||||
port := ctx.GlobalInt(pprofPortFlag.Name)
|
||||
if ctx.GlobalIsSet(legacyPprofPortFlag.Name) && !ctx.GlobalIsSet(pprofPortFlag.Name) {
|
||||
port = ctx.GlobalInt(legacyPprofPortFlag.Name)
|
||||
log.Warn("The flag --pprofport is deprecated and will be removed in the future, please use --pprof.port")
|
||||
}
|
||||
|
||||
address := fmt.Sprintf("%s:%d", listenHost, port)
|
||||
StartPProf(address)
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user