Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/utils: change default value of some flags to simplify sync #855

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/XDC/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestHTTPAttachWelcome(t *testing.T) {
XDC := runXDC(t,
"--datadir", datadir, "--XDCx-datadir", datadir+"/XDCx",
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--miner-etherbase", coinbase, "--http", "--http-port", port)
"--miner-etherbase", coinbase, "--http", "--http-port", port, "--http-api", "eth,net,rpc,web3")

time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
testAttachWelcome(t, XDC, "http://localhost:"+port, httpAPIs)
Expand All @@ -117,7 +117,7 @@ func TestWSAttachWelcome(t *testing.T) {
XDC := runXDC(t,
"--datadir", datadir, "--XDCx-datadir", datadir+"/XDCx",
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--miner-etherbase", coinbase, "--ws", "--ws-port", port)
"--miner-etherbase", coinbase, "--ws", "--ws-port", port, "--ws-api", "eth,net,rpc,web3")

time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
testAttachWelcome(t, XDC, "ws://localhost:"+port, httpAPIs)
Expand Down
64 changes: 28 additions & 36 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,21 +345,21 @@ var (
Name: "miner-gaslimit",
Aliases: []string{"targetgaslimit"},
Usage: "Target gas limit sets the artificial target gas floor for the blocks to mine",
Value: params.XDCGenesisGasLimit,
Value: 50000000,
Category: flags.MinerCategory,
}
MinerGasPriceFlag = &flags.BigFlag{
Name: "miner-gasprice",
Aliases: []string{"gasprice"},
Usage: "Minimal gas price to accept for mining a transactions",
Value: ethconfig.Defaults.GasPrice,
Value: big.NewInt(1),
Category: flags.MinerCategory,
}
MinerEtherbaseFlag = &cli.StringFlag{
Name: "miner-etherbase",
Aliases: []string{"etherbase"},
Usage: "Public address for block mining rewards (default = first account created)",
Value: "0",
Value: "0x000000000000000000000000000000000000abcd",
Category: flags.MinerCategory,
}
MinerExtraDataFlag = &cli.StringFlag{
Expand Down Expand Up @@ -437,13 +437,14 @@ var (
Name: "http",
Aliases: []string{"rpc"},
Usage: "Enable the HTTP-RPC server",
Value: true,
Category: flags.APICategory,
}
HTTPListenAddrFlag = &cli.StringFlag{
Name: "http-addr",
Aliases: []string{"rpcaddr"},
Usage: "HTTP-RPC server listening interface",
Value: node.DefaultHTTPHost,
Value: "0.0.0.0",
Category: flags.APICategory,
}
HTTPPortFlag = &cli.IntFlag{
Expand All @@ -457,21 +458,21 @@ var (
Name: "http-corsdomain",
Aliases: []string{"rpccorsdomain"},
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
Value: "",
Value: "*",
Category: flags.APICategory,
}
HTTPVirtualHostsFlag = &cli.StringFlag{
Name: "http-vhosts",
Aliases: []string{"rpcvhosts"},
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: strings.Join(node.DefaultConfig.HTTPVirtualHosts, ","),
Value: "*",
Category: flags.APICategory,
}
HTTPApiFlag = &cli.StringFlag{
Name: "http-api",
Aliases: []string{"rpcapi"},
Usage: "API's offered over the HTTP-RPC interface",
Value: "",
Value: "debug,eth,net,personal,txpool,web3,XDPoS",
Category: flags.APICategory,
}
HTTPReadTimeoutFlag = &cli.DurationFlag{
Expand All @@ -498,13 +499,14 @@ var (
WSEnabledFlag = &cli.BoolFlag{
Name: "ws",
Usage: "Enable the WS-RPC server",
Value: true,
Category: flags.APICategory,
}
WSListenAddrFlag = &cli.StringFlag{
Name: "ws-addr",
Aliases: []string{"wsaddr"},
Usage: "WS-RPC server listening interface",
Value: node.DefaultWSHost,
Value: "0.0.0.0",
Category: flags.APICategory,
}
WSPortFlag = &cli.IntFlag{
Expand All @@ -518,14 +520,14 @@ var (
Name: "ws-api",
Aliases: []string{"wsapi"},
Usage: "API's offered over the WS-RPC interface",
Value: "",
Value: "debug,eth,net,personal,txpool,web3,XDPoS",
Category: flags.APICategory,
}
WSAllowedOriginsFlag = &cli.StringFlag{
Name: "ws-origins",
Aliases: []string{"wsorigins"},
Usage: "Origins from which to accept websockets requests",
Value: "",
Value: "*",
Category: flags.APICategory,
}
ExecFlag = &cli.StringFlag{
Expand Down Expand Up @@ -970,11 +972,11 @@ func splitAndTrim(input string) (ret []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.Bool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" {
cfg.HTTPHost = "127.0.0.1"
if ctx.IsSet(HTTPListenAddrFlag.Name) {
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
if ctx.Bool(HTTPEnabledFlag.Name) {
if cfg.HTTPHost == "" {
cfg.HTTPHost = "127.0.0.1"
}
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
}

if ctx.IsSet(HTTPPortFlag.Name) {
Expand All @@ -989,36 +991,26 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
if ctx.IsSet(HTTPIdleTimeoutFlag.Name) {
cfg.HTTPTimeouts.IdleTimeout = ctx.Duration(HTTPIdleTimeoutFlag.Name)
}
if ctx.IsSet(HTTPCORSDomainFlag.Name) {
cfg.HTTPCors = splitAndTrim(ctx.String(HTTPCORSDomainFlag.Name))
}
if ctx.IsSet(HTTPApiFlag.Name) {
cfg.HTTPModules = splitAndTrim(ctx.String(HTTPApiFlag.Name))
}
if ctx.IsSet(HTTPVirtualHostsFlag.Name) {
cfg.HTTPVirtualHosts = splitAndTrim(ctx.String(HTTPVirtualHostsFlag.Name))
}
cfg.HTTPCors = splitAndTrim(ctx.String(HTTPCORSDomainFlag.Name))
cfg.HTTPModules = splitAndTrim(ctx.String(HTTPApiFlag.Name))
cfg.HTTPVirtualHosts = splitAndTrim(ctx.String(HTTPVirtualHostsFlag.Name))
}

// setWS creates the WebSocket RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled.
func setWS(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(WSEnabledFlag.Name) && cfg.WSHost == "" {
cfg.WSHost = "127.0.0.1"
if ctx.IsSet(WSListenAddrFlag.Name) {
cfg.WSHost = ctx.String(WSListenAddrFlag.Name)
if ctx.Bool(WSEnabledFlag.Name) {
if cfg.WSHost == "" {
cfg.WSHost = "127.0.0.1"
}
cfg.WSHost = ctx.String(WSListenAddrFlag.Name)
}

if ctx.IsSet(WSPortFlag.Name) {
cfg.WSPort = ctx.Int(WSPortFlag.Name)
}
if ctx.IsSet(WSAllowedOriginsFlag.Name) {
cfg.WSOrigins = splitAndTrim(ctx.String(WSAllowedOriginsFlag.Name))
}
if ctx.IsSet(WSApiFlag.Name) {
cfg.WSModules = splitAndTrim(ctx.String(WSApiFlag.Name))
}
cfg.WSOrigins = splitAndTrim(ctx.String(WSAllowedOriginsFlag.Name))
cfg.WSModules = splitAndTrim(ctx.String(WSApiFlag.Name))
}

// setIPC creates an IPC path configuration from the set command line flags,
Expand Down Expand Up @@ -1098,6 +1090,8 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *ethconfig.Config
Fatalf("Option %q: %v", MinerEtherbaseFlag.Name, err)
}
cfg.Etherbase = account.Address
} else {
cfg.Etherbase = common.HexToAddress(ctx.String(MinerEtherbaseFlag.Name))
}
}

Expand Down Expand Up @@ -1482,9 +1476,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.IsSet(MinerExtraDataFlag.Name) {
cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name))
}
if ctx.IsSet(MinerGasPriceFlag.Name) {
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
}
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
if ctx.IsSet(CacheLogSizeFlag.Name) {
cfg.FilterLogCacheSize = ctx.Int(CacheLogSizeFlag.Name)
}
Expand Down