Unverified Commit c989bca1 authored by rene's avatar rene Committed by GitHub

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: 's avatarMartin Holst Swende <martin@swende.se>
parent 58765661
...@@ -222,11 +222,11 @@ func init() { ...@@ -222,11 +222,11 @@ func init() {
utils.LightKDFFlag, utils.LightKDFFlag,
utils.NoUSBFlag, utils.NoUSBFlag,
utils.SmartCardDaemonPathFlag, utils.SmartCardDaemonPathFlag,
utils.RPCListenAddrFlag, utils.HTTPListenAddrFlag,
utils.RPCVirtualHostsFlag, utils.HTTPVirtualHostsFlag,
utils.IPCDisabledFlag, utils.IPCDisabledFlag,
utils.IPCPathFlag, utils.IPCPathFlag,
utils.RPCEnabledFlag, utils.HTTPEnabledFlag,
rpcPortFlag, rpcPortFlag,
signerSecretFlag, signerSecretFlag,
customDBFlag, customDBFlag,
...@@ -579,9 +579,9 @@ func signer(c *cli.Context) error { ...@@ -579,9 +579,9 @@ func signer(c *cli.Context) error {
Service: api, Service: api,
Version: "1.0"}, Version: "1.0"},
} }
if c.GlobalBool(utils.RPCEnabledFlag.Name) { if c.GlobalBool(utils.HTTPEnabledFlag.Name) {
vhosts := splitAndTrim(c.GlobalString(utils.RPCVirtualHostsFlag.Name)) vhosts := splitAndTrim(c.GlobalString(utils.HTTPVirtualHostsFlag.Name))
cors := splitAndTrim(c.GlobalString(utils.RPCCORSDomainFlag.Name)) cors := splitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
srv := rpc.NewServer() srv := rpc.NewServer()
err := node.RegisterApisFromWhitelist(rpcAPI, []string{"account"}, srv, false) err := node.RegisterApisFromWhitelist(rpcAPI, []string{"account"}, srv, false)
...@@ -591,7 +591,7 @@ func signer(c *cli.Context) error { ...@@ -591,7 +591,7 @@ func signer(c *cli.Context) error {
handler := node.NewHTTPHandlerStack(srv, cors, vhosts) handler := node.NewHTTPHandlerStack(srv, cors, vhosts)
// start http server // 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) httpServer, addr, err := node.StartHTTPEndpoint(httpEndpoint, rpc.DefaultHTTPTimeouts, handler)
if err != nil { if err != nil {
utils.Fatalf("Could not start RPC api: %v", err) utils.Fatalf("Could not start RPC api: %v", err)
......
...@@ -93,11 +93,11 @@ var ( ...@@ -93,11 +93,11 @@ var (
utils.GCModeFlag, utils.GCModeFlag,
utils.SnapshotFlag, utils.SnapshotFlag,
utils.LightServeFlag, utils.LightServeFlag,
utils.LightLegacyServFlag, utils.LegacyLightServFlag,
utils.LightIngressFlag, utils.LightIngressFlag,
utils.LightEgressFlag, utils.LightEgressFlag,
utils.LightMaxPeersFlag, utils.LightMaxPeersFlag,
utils.LightLegacyPeersFlag, utils.LegacyLightPeersFlag,
utils.LightKDFFlag, utils.LightKDFFlag,
utils.UltraLightServersFlag, utils.UltraLightServersFlag,
utils.UltraLightFractionFlag, utils.UltraLightFractionFlag,
...@@ -114,17 +114,17 @@ var ( ...@@ -114,17 +114,17 @@ var (
utils.MaxPendingPeersFlag, utils.MaxPendingPeersFlag,
utils.MiningEnabledFlag, utils.MiningEnabledFlag,
utils.MinerThreadsFlag, utils.MinerThreadsFlag,
utils.MinerLegacyThreadsFlag, utils.LegacyMinerThreadsFlag,
utils.MinerNotifyFlag, utils.MinerNotifyFlag,
utils.MinerGasTargetFlag, utils.MinerGasTargetFlag,
utils.MinerLegacyGasTargetFlag, utils.LegacyMinerGasTargetFlag,
utils.MinerGasLimitFlag, utils.MinerGasLimitFlag,
utils.MinerGasPriceFlag, utils.MinerGasPriceFlag,
utils.MinerLegacyGasPriceFlag, utils.LegacyMinerGasPriceFlag,
utils.MinerEtherbaseFlag, utils.MinerEtherbaseFlag,
utils.MinerLegacyEtherbaseFlag, utils.LegacyMinerEtherbaseFlag,
utils.MinerExtraDataFlag, utils.MinerExtraDataFlag,
utils.MinerLegacyExtraDataFlag, utils.LegacyMinerExtraDataFlag,
utils.MinerRecommitIntervalFlag, utils.MinerRecommitIntervalFlag,
utils.MinerNoVerfiyFlag, utils.MinerNoVerfiyFlag,
utils.NATFlag, utils.NATFlag,
...@@ -146,29 +146,41 @@ var ( ...@@ -146,29 +146,41 @@ var (
utils.FakePoWFlag, utils.FakePoWFlag,
utils.NoCompactionFlag, utils.NoCompactionFlag,
utils.GpoBlocksFlag, utils.GpoBlocksFlag,
utils.LegacyGpoBlocksFlag,
utils.GpoPercentileFlag, utils.GpoPercentileFlag,
utils.LegacyGpoPercentileFlag,
utils.EWASMInterpreterFlag, utils.EWASMInterpreterFlag,
utils.EVMInterpreterFlag, utils.EVMInterpreterFlag,
configFileFlag, configFileFlag,
} }
rpcFlags = []cli.Flag{ rpcFlags = []cli.Flag{
utils.RPCEnabledFlag, utils.HTTPEnabledFlag,
utils.RPCListenAddrFlag, utils.HTTPListenAddrFlag,
utils.RPCPortFlag, utils.HTTPPortFlag,
utils.RPCCORSDomainFlag, utils.HTTPCORSDomainFlag,
utils.RPCVirtualHostsFlag, utils.HTTPVirtualHostsFlag,
utils.LegacyRPCEnabledFlag,
utils.LegacyRPCListenAddrFlag,
utils.LegacyRPCPortFlag,
utils.LegacyRPCCORSDomainFlag,
utils.LegacyRPCVirtualHostsFlag,
utils.GraphQLEnabledFlag, utils.GraphQLEnabledFlag,
utils.GraphQLListenAddrFlag, utils.GraphQLListenAddrFlag,
utils.GraphQLPortFlag, utils.GraphQLPortFlag,
utils.GraphQLCORSDomainFlag, utils.GraphQLCORSDomainFlag,
utils.GraphQLVirtualHostsFlag, utils.GraphQLVirtualHostsFlag,
utils.RPCApiFlag, utils.HTTPApiFlag,
utils.LegacyRPCApiFlag,
utils.WSEnabledFlag, utils.WSEnabledFlag,
utils.WSListenAddrFlag, utils.WSListenAddrFlag,
utils.LegacyWSListenAddrFlag,
utils.WSPortFlag, utils.WSPortFlag,
utils.LegacyWSPortFlag,
utils.WSApiFlag, utils.WSApiFlag,
utils.LegacyWSApiFlag,
utils.WSAllowedOriginsFlag, utils.WSAllowedOriginsFlag,
utils.LegacyWSAllowedOriginsFlag,
utils.IPCDisabledFlag, utils.IPCDisabledFlag,
utils.IPCPathFlag, utils.IPCPathFlag,
utils.InsecureUnlockAllowedFlag, utils.InsecureUnlockAllowedFlag,
...@@ -227,6 +239,8 @@ func init() { ...@@ -227,6 +239,8 @@ func init() {
dumpConfigCommand, dumpConfigCommand,
// See retesteth.go // See retesteth.go
retestethCommand, retestethCommand,
// See cmd/utils/flags_legacy.go
utils.ShowDeprecated,
} }
sort.Sort(cli.CommandsByName(app.Commands)) sort.Sort(cli.CommandsByName(app.Commands))
...@@ -234,6 +248,7 @@ func init() { ...@@ -234,6 +248,7 @@ func init() {
app.Flags = append(app.Flags, rpcFlags...) app.Flags = append(app.Flags, rpcFlags...)
app.Flags = append(app.Flags, consoleFlags...) app.Flags = append(app.Flags, consoleFlags...)
app.Flags = append(app.Flags, debug.Flags...) 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, whisperFlags...)
app.Flags = append(app.Flags, metricsFlags...) app.Flags = append(app.Flags, metricsFlags...)
...@@ -360,7 +375,7 @@ func startNode(ctx *cli.Context, stack *node.Node) { ...@@ -360,7 +375,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
// Set contract backend for ethereum service if local node // Set contract backend for ethereum service if local node
// is serving LES requests. // 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 var ethService *eth.Ethereum
if err := stack.Service(&ethService); err != nil { if err := stack.Service(&ethService); err != nil {
utils.Fatalf("Failed to retrieve ethereum service: %v", err) utils.Fatalf("Failed to retrieve ethereum service: %v", err)
...@@ -445,16 +460,18 @@ func startNode(ctx *cli.Context, stack *node.Node) { ...@@ -445,16 +460,18 @@ func startNode(ctx *cli.Context, stack *node.Node) {
utils.Fatalf("Ethereum service not running: %v", err) utils.Fatalf("Ethereum service not running: %v", err)
} }
// Set the gas price to the limits from the CLI and start mining // Set the gas price to the limits from the CLI and start mining
gasprice := utils.GlobalBig(ctx, utils.MinerLegacyGasPriceFlag.Name) gasprice := utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
if ctx.IsSet(utils.MinerGasPriceFlag.Name) { if ctx.GlobalIsSet(utils.LegacyMinerGasPriceFlag.Name) && !ctx.GlobalIsSet(utils.MinerGasPriceFlag.Name) {
gasprice = utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name) gasprice = utils.GlobalBig(ctx, utils.LegacyMinerGasPriceFlag.Name)
} }
ethereum.TxPool().SetGasPrice(gasprice) ethereum.TxPool().SetGasPrice(gasprice)
threads := ctx.GlobalInt(utils.MinerLegacyThreadsFlag.Name) threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name)
if ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) { if ctx.GlobalIsSet(utils.LegacyMinerThreadsFlag.Name) && !ctx.GlobalIsSet(utils.MinerThreadsFlag.Name) {
threads = ctx.GlobalInt(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 { if err := ethereum.StartMining(threads); err != nil {
utils.Fatalf("Failed to start mining: %v", err) utils.Fatalf("Failed to start mining: %v", err)
} }
......
...@@ -887,8 +887,8 @@ func retesteth(ctx *cli.Context) error { ...@@ -887,8 +887,8 @@ func retesteth(ctx *cli.Context) error {
Version: "1.0", Version: "1.0",
}, },
} }
vhosts := splitAndTrim(ctx.GlobalString(utils.RPCVirtualHostsFlag.Name)) vhosts := splitAndTrim(ctx.GlobalString(utils.HTTPVirtualHostsFlag.Name))
cors := splitAndTrim(ctx.GlobalString(utils.RPCCORSDomainFlag.Name)) cors := splitAndTrim(ctx.GlobalString(utils.HTTPCORSDomainFlag.Name))
// register apis and create handler stack // register apis and create handler stack
srv := rpc.NewServer() srv := rpc.NewServer()
...@@ -904,7 +904,7 @@ func retesteth(ctx *cli.Context) error { ...@@ -904,7 +904,7 @@ func retesteth(ctx *cli.Context) error {
WriteTimeout: 120 * time.Second, WriteTimeout: 120 * time.Second,
IdleTimeout: 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) httpServer, _, err := node.StartHTTPEndpoint(httpEndpoint, RetestethHTTPTimeouts, handler)
if err != nil { if err != nil {
utils.Fatalf("Could not start RPC api: %v", err) utils.Fatalf("Could not start RPC api: %v", err)
......
...@@ -157,13 +157,12 @@ var AppHelpFlagGroups = []flagGroup{ ...@@ -157,13 +157,12 @@ var AppHelpFlagGroups = []flagGroup{
Flags: []cli.Flag{ Flags: []cli.Flag{
utils.IPCDisabledFlag, utils.IPCDisabledFlag,
utils.IPCPathFlag, utils.IPCPathFlag,
utils.RPCEnabledFlag, utils.HTTPEnabledFlag,
utils.RPCListenAddrFlag, utils.HTTPListenAddrFlag,
utils.RPCPortFlag, utils.HTTPPortFlag,
utils.RPCApiFlag, utils.HTTPApiFlag,
utils.RPCGlobalGasCap, utils.HTTPCORSDomainFlag,
utils.RPCCORSDomainFlag, utils.HTTPVirtualHostsFlag,
utils.RPCVirtualHostsFlag,
utils.WSEnabledFlag, utils.WSEnabledFlag,
utils.WSListenAddrFlag, utils.WSListenAddrFlag,
utils.WSPortFlag, utils.WSPortFlag,
...@@ -174,6 +173,7 @@ var AppHelpFlagGroups = []flagGroup{ ...@@ -174,6 +173,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.GraphQLPortFlag, utils.GraphQLPortFlag,
utils.GraphQLCORSDomainFlag, utils.GraphQLCORSDomainFlag,
utils.GraphQLVirtualHostsFlag, utils.GraphQLVirtualHostsFlag,
utils.RPCGlobalGasCap,
utils.JSpathFlag, utils.JSpathFlag,
utils.ExecFlag, utils.ExecFlag,
utils.PreloadJSFlag, utils.PreloadJSFlag,
...@@ -243,20 +243,28 @@ var AppHelpFlagGroups = []flagGroup{ ...@@ -243,20 +243,28 @@ var AppHelpFlagGroups = []flagGroup{
Flags: whisperFlags, Flags: whisperFlags,
}, },
{ {
Name: "DEPRECATED", Name: "ALIASED (deprecated)",
Flags: []cli.Flag{ Flags: append([]cli.Flag{
utils.LegacyTestnetFlag, utils.LegacyRPCEnabledFlag,
utils.LightLegacyServFlag, utils.LegacyRPCListenAddrFlag,
utils.LightLegacyPeersFlag, utils.LegacyRPCPortFlag,
utils.MinerLegacyThreadsFlag, utils.LegacyRPCCORSDomainFlag,
utils.MinerLegacyGasTargetFlag, utils.LegacyRPCVirtualHostsFlag,
utils.MinerLegacyGasPriceFlag, utils.LegacyRPCApiFlag,
utils.MinerLegacyEtherbaseFlag, utils.LegacyWSListenAddrFlag,
utils.MinerLegacyExtraDataFlag, utils.LegacyWSPortFlag,
}, utils.LegacyWSAllowedOriginsFlag,
utils.LegacyWSApiFlag,
utils.LegacyGpoBlocksFlag,
utils.LegacyGpoPercentileFlag,
}, debug.DeprecatedFlags...),
}, },
{ {
Name: "MISC", Name: "MISC",
Flags: []cli.Flag{
utils.SnapshotFlag,
cli.HelpFlag,
},
}, },
} }
...@@ -314,10 +322,17 @@ func init() { ...@@ -314,10 +322,17 @@ func init() {
categorized[flag.String()] = struct{}{} 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 var uncategorized []cli.Flag
for _, flag := range data.(*cli.App).Flags { for _, flag := range data.(*cli.App).Flags {
if _, ok := categorized[flag.String()]; !ok { if _, ok := categorized[flag.String()]; !ok {
uncategorized = append(uncategorized, flag) if _, ok := deprecated[flag.String()]; !ok {
uncategorized = append(uncategorized, flag)
}
} }
} }
if len(uncategorized) > 0 { if len(uncategorized) > 0 {
......
This diff is collapsed.
// 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 ( ...@@ -60,39 +60,68 @@ var (
Usage: "Enable the pprof HTTP server", Usage: "Enable the pprof HTTP server",
} }
pprofPortFlag = cli.IntFlag{ pprofPortFlag = cli.IntFlag{
Name: "pprofport", Name: "pprof.port",
Usage: "pprof HTTP server listening port", Usage: "pprof HTTP server listening port",
Value: 6060, Value: 6060,
} }
pprofAddrFlag = cli.StringFlag{ pprofAddrFlag = cli.StringFlag{
Name: "pprofaddr", Name: "pprof.addr",
Usage: "pprof HTTP server listening interface", Usage: "pprof HTTP server listening interface",
Value: "127.0.0.1", Value: "127.0.0.1",
} }
memprofilerateFlag = cli.IntFlag{ memprofilerateFlag = cli.IntFlag{
Name: "memprofilerate", Name: "pprof.memprofilerate",
Usage: "Turn on memory profiling with the given rate", Usage: "Turn on memory profiling with the given rate",
Value: runtime.MemProfileRate, Value: runtime.MemProfileRate,
} }
blockprofilerateFlag = cli.IntFlag{ blockprofilerateFlag = cli.IntFlag{
Name: "blockprofilerate", Name: "pprof.blockprofilerate",
Usage: "Turn on block profiling with the given rate", Usage: "Turn on block profiling with the given rate",
} }
cpuprofileFlag = cli.StringFlag{ cpuprofileFlag = cli.StringFlag{
Name: "cpuprofile", Name: "pprof.cpuprofile",
Usage: "Write CPU profile to the given file", Usage: "Write CPU profile to the given file",
} }
traceFlag = cli.StringFlag{ traceFlag = cli.StringFlag{
Name: "trace", Name: "trace",
Usage: "Write execution trace to the given file", 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. // Flags holds all command-line flags required for debugging.
var Flags = []cli.Flag{ var Flags = []cli.Flag{
verbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag, verbosityFlag, vmoduleFlag, backtraceAtFlag, debugFlag,
pprofFlag, pprofAddrFlag, pprofPortFlag, pprofFlag, pprofAddrFlag, pprofPortFlag, memprofilerateFlag,
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
}
var DeprecatedFlags = []cli.Flag{
legacyPprofPortFlag, legacyPprofAddrFlag, legacyMemprofilerateFlag,
legacyBlockprofilerateFlag, legacyCpuprofileFlag,
} }
var ( var (
...@@ -121,22 +150,51 @@ func Setup(ctx *cli.Context) error { ...@@ -121,22 +150,51 @@ func Setup(ctx *cli.Context) error {
log.Root().SetHandler(glogger) log.Root().SetHandler(glogger)
// profiling, tracing // 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) 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)) Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name))
if traceFile := ctx.GlobalString(traceFlag.Name); traceFile != "" { if traceFile := ctx.GlobalString(traceFlag.Name); traceFile != "" {
if err := Handler.StartGoTrace(traceFile); err != nil { if err := Handler.StartGoTrace(traceFile); err != nil {
return err return err
} }
} }
if cpuFile := ctx.GlobalString(cpuprofileFlag.Name); cpuFile != "" { if cpuFile := ctx.GlobalString(cpuprofileFlag.Name); cpuFile != "" {
if err := Handler.StartCPUProfile(cpuFile); err != nil { if err := Handler.StartCPUProfile(cpuFile); err != nil {
return err 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 // pprof server
if ctx.GlobalBool(pprofFlag.Name) { 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) StartPProf(address)
} }
return nil return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment