Skip to content

Commit

Permalink
internal/cli: added missing flags (ethereum#744)
Browse files Browse the repository at this point in the history
* minor comment update

* added support for rpc.evmtimeout flag

* added support for vmdebug (EnablePreimageRecording) flag

* added support for jsonrpc.auth.(jwtsecret, addr, port, vhosts) flags

* added support for miner.recommit flag

* added support for gpo.maxheaderhistory and gpo.maxblockhistory flag

* Revert "added support for miner.recommit flag"

This reverts commit fcb722e4bf5bdda23d4c91da40ab95c9023a80c3.

* added pprof related flags (expect --pprof.cpuprofile - Write CPU profile to the given file)

* added support for --dev.gaslimit flag

* added support for --fdlimit flag

* added support for --netrestrict flag

* added support for --nodekey and --nodekeyhex flag

* added support for --vmodule, --log.json, --log.backtrace, and --log.debug flags

* fixed related lint errors

* fix lints from develop (few lints decided to appear from code that was untouched, weird)

* more weird lints from develop

* small precautionary fix

* small bug ;) fix in NetRestrict

* weird lints

* change vmdebug = true to vmdebug = false
  • Loading branch information
pratikspatil024 authored Mar 20, 2023
1 parent 71eadd0 commit 584856b
Show file tree
Hide file tree
Showing 24 changed files with 768 additions and 35 deletions.
27 changes: 27 additions & 0 deletions builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ chain = "mainnet"
# chain = "mumbai"
# identity = "Annon-Identity"
# verbosity = 3
# vmdebug = false
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "/var/lib/bor/keystore"
Expand All @@ -16,13 +17,22 @@ syncmode = "full"
# devfakeauthor = false
# ["eth.requiredblocks"]

# [log]
# vmodule = ""
# json = false
# backtrace = ""
# debug = true

[p2p]
# maxpeers = 1
# nodiscover = true
# maxpendpeers = 50
# bind = "0.0.0.0"
# port = 30303
# nat = "any"
# netrestrict = ""
# nodekey = ""
# nodekeyhex = ""
[p2p.discovery]
# v5disc = false
bootnodes = ["enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303", "enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303"]
Expand Down Expand Up @@ -65,6 +75,7 @@ syncmode = "full"
# ipcdisable = false
# ipcpath = ""
# gascap = 50000000
# evmtimeout = "5s"
# txfeecap = 5.0
# allow-unprotected-txs = false
# [jsonrpc.http]
Expand All @@ -89,6 +100,11 @@ syncmode = "full"
# host = ""
# vhosts = ["*"]
# corsdomain = ["*"]
# [jsonrpc.auth]
# jwtsecret = ""
# addr = "localhost"
# port = 8551
# vhosts = ["localhost"]
# [jsonrpc.timeouts]
# read = "30s"
# write = "30s"
Expand All @@ -97,6 +113,8 @@ syncmode = "full"
[gpo]
# blocks = 20
# percentile = 60
# maxheaderhistory = 1024
# maxblockhistory = 1024
# maxprice = "5000000000000"
ignoreprice = "30000000000"

Expand Down Expand Up @@ -130,6 +148,7 @@ syncmode = "full"
# txlookuplimit = 2350000
# triesinmemory = 128
# timeout = "1h0m0s"
# fdlimit = 0

[accounts]
# allow-insecure-unlock = true
Expand All @@ -144,3 +163,11 @@ syncmode = "full"
# [developer]
# dev = false
# period = 0
# gaslimit = 11500000

# [pprof]
# pprof = false
# port = 6060
# addr = "127.0.0.1"
# memprofilerate = 524288
# blockprofilerate = 0
1 change: 1 addition & 0 deletions core/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ func TestTransactionGapFilling(t *testing.T) {
if queued != 1 {
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 1)
}

if err := validateEvents(events, 1); err != nil {
t.Fatalf("original event firing failed: %v", err)
}
Expand Down
33 changes: 30 additions & 3 deletions docs/cli/example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

chain = "mainnet" # Name of the chain to sync ("mumbai", "mainnet") or path to a genesis file
identity = "Annon-Identity" # Name/Identity of the node (default = OS hostname)
verbosity = 3 # Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (`log-level` was replaced by `verbosity`, and thus will be deprecated soon)
verbosity = 3 # Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (`log-level` was replaced by `verbosity`, and thus will be deprecated soon)
vmdebug = false # Record information useful for VM and contract debugging
datadir = "var/lib/bor" # Path of the data directory to store information
ancient = "" # Data directory for ancient chain segments (default = inside chaindata)
keystore = "" # Path of the directory where keystores are located
Expand All @@ -19,13 +20,22 @@ devfakeauthor = false # Run miner without validator set authorization [de
"31000000" = "0x2087b9e2b353209c2c21e370c82daa12278efd0fe5f0febe6c29035352cf050e"
"32000000" = "0x875500011e5eecc0c554f95d07b31cf59df4ca2505f4dbbfffa7d4e4da917c68"

[log]
vmodule = "" # Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
json = false # Format logs with JSON
backtrace = "" # Request a stack trace at a specific logging statement (e.g. "block.go:271")
debug = true # Prepends log messages with call-site location (file and line number) - {requires some effort}

[p2p]
maxpeers = 50 # Maximum number of network peers (network disabled if set to 0)
maxpendpeers = 50 # Maximum number of pending connection attempts
bind = "0.0.0.0" # Network binding address
port = 30303 # Network listening port
nodiscover = false # Disables the peer discovery mechanism (manual peer addition)
nat = "any" # NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
netrestrict = "" # Restricts network communication to the given IP networks (CIDR masks)
nodekey = "" # P2P node key file
nodekeyhex = "" # P2P node key as hex
[p2p.discovery]
v5disc = false # Enables the experimental RLPx V5 (Topic Discovery) mechanism
bootnodes = [] # Comma separated enode URLs for P2P discovery bootstrap
Expand Down Expand Up @@ -65,6 +75,7 @@ devfakeauthor = false # Run miner without validator set authorization [de
ipcdisable = false # Disable the IPC-RPC server
ipcpath = "" # Filename for IPC socket/pipe within the datadir (explicit paths escape it)
gascap = 50000000 # Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)
evmtimeout = "5s" # Sets a timeout used for eth_call (0=infinite)
txfeecap = 5.0 # Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)
allow-unprotected-txs = false # Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC (default: false)
[jsonrpc.http]
Expand All @@ -89,6 +100,11 @@ devfakeauthor = false # Run miner without validator set authorization [de
host = "" #
vhosts = ["localhost"] # Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
corsdomain = ["localhost"] # Comma separated list of domains from which to accept cross origin requests (browser enforced)
[jsonrpc.auth]
jwtsecret = "" # Path to a JWT secret to use for authenticated RPC endpoints
addr = "localhost" # Listening address for authenticated APIs
port = 8551 # Listening port for authenticated APIs
vhosts = ["localhost"] # Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
[jsonrpc.timeouts]
read = "30s"
write = "30s"
Expand All @@ -97,6 +113,8 @@ devfakeauthor = false # Run miner without validator set authorization [de
[gpo]
blocks = 20 # Number of recent blocks to check for gas prices
percentile = 60 # Suggested gas price is the given percentile of a set of recent transaction gas prices
maxheaderhistory = 1024 # Maximum header history of gasprice oracle
maxblockhistory = 1024 # Maximum block history of gasprice oracle
maxprice = "5000000000000" # Maximum gas price will be recommended by gpo
ignoreprice = "2" # Gas price below which gpo will ignore transactions (recommended for mainnet = 30000000000, default suitable for mumbai/devnet)

Expand Down Expand Up @@ -134,6 +152,7 @@ devfakeauthor = false # Run miner without validator set authorization [de
txlookuplimit = 2350000 # Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)
triesinmemory = 128 # Number of block states (tries) to keep in memory
timeout = "1h0m0s" # Time after which the Merkle Patricia Trie is stored to disc from memory
fdlimit = 0 # Raise the open file descriptor resource limit (default = system fd limit)

[accounts]
unlock = [] # Comma separated list of accounts to unlock
Expand All @@ -146,5 +165,13 @@ devfakeauthor = false # Run miner without validator set authorization [de
addr = ":3131" # Address and port to bind the GRPC server

[developer]
dev = false # Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled
period = 0 # Block period to use in developer mode (0 = mine only if transaction pending)
dev = false # Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled
period = 0 # Block period to use in developer mode (0 = mine only if transaction pending)
gaslimit = 11500000 # Initial block gas limit

[pprof]
pprof = false # Enable the pprof HTTP server
port = 6060 # pprof HTTP server listening port
addr = "127.0.0.1" # pprof HTTP server listening interface
memprofilerate = 524288 # Turn on memory profiling with the given rate
blockprofilerate = 0 # Turn on block profiling with the given rate
48 changes: 47 additions & 1 deletion docs/cli/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ The ```bor server``` command runs the Bor client.

- ```datadir```: Path of the data directory to store information

- ```vmdebug```: Record information useful for VM and contract debugging (default: false)

- ```datadir.ancient```: Data directory for ancient chain segments (default = inside chaindata)

- ```keystore```: Path of the directory where keystores are located

- ```config```: File for the config file
- ```config```: Path to the TOML configuration file

- ```syncmode```: Blockchain sync mode (only "full" sync supported) (default: full)

Expand Down Expand Up @@ -48,6 +50,10 @@ The ```bor server``` command runs the Bor client.

- ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 60)

- ```gpo.maxheaderhistory```: Maximum header history of gasprice oracle (default: 1024)

- ```gpo.maxblockhistory```: Maximum block history of gasprice oracle (default: 1024)

- ```gpo.maxprice```: Maximum gas price will be recommended by gpo (default: 5000000000000)

- ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions (default: 2)
Expand All @@ -60,6 +66,18 @@ The ```bor server``` command runs the Bor client.

- ```dev.period```: Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)

- ```dev.gaslimit```: Initial block gas limit (default: 11500000)

- ```pprof```: Enable the pprof HTTP server (default: false)

- ```pprof.port```: pprof HTTP server listening port (default: 6060)

- ```pprof.addr```: pprof HTTP server listening interface (default: 127.0.0.1)

- ```pprof.memprofilerate```: Turn on memory profiling with the given rate (default: 524288)

- ```pprof.blockprofilerate```: Turn on block profiling with the given rate (default: 0)

### Account Management Options

- ```unlock```: Comma separated list of accounts to unlock
Expand Down Expand Up @@ -94,10 +112,14 @@ The ```bor server``` command runs the Bor client.

- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default: 2350000)

- ```fdlimit```: Raise the open file descriptor resource limit (default = system fd limit) (default: 0)

### JsonRPC Options

- ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite) (default: 50000000)

- ```rpc.evmtimeout```: Sets a timeout used for eth_call (0=infinite) (default: 5s)

- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) (default: 5)

- ```rpc.allow-unprotected-txs```: Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC (default: false)
Expand All @@ -106,6 +128,14 @@ The ```bor server``` command runs the Bor client.

- ```ipcpath```: Filename for IPC socket/pipe within the datadir (explicit paths escape it)

- ```authrpc.jwtsecret```: Path to a JWT secret to use for authenticated RPC endpoints

- ```authrpc.addr```: Listening address for authenticated APIs (default: localhost)

- ```authrpc.port```: Listening port for authenticated APIs (default: 8551)

- ```authrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)

- ```http.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) (default: localhost)

- ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)
Expand Down Expand Up @@ -138,6 +168,16 @@ The ```bor server``` command runs the Bor client.

- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well. (default: false)

### Logging Options

- ```vmodule```: Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)

- ```log.json```: Format logs with JSON (default: false)

- ```log.backtrace```: Request a stack trace at a specific logging statement (e.g. 'block.go:271')

- ```log.debug```: Prepends log messages with call-site location (file and line number) (default: false)

### P2P Options

- ```bind```: Network binding address (default: 0.0.0.0)
Expand All @@ -152,6 +192,12 @@ The ```bor server``` command runs the Bor client.

- ```nat```: NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: any)

- ```netrestrict```: Restricts network communication to the given IP networks (CIDR masks)

- ```nodekey```: P2P node key file

- ```nodekeyhex```: P2P node key as hex

- ```nodiscover```: Disables the peer discovery mechanism (manual peer addition) (default: false)

- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false)
Expand Down
1 change: 1 addition & 0 deletions eth/filters/bor_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (api *PublicFilterAPI) NewDeposits(ctx context.Context, crit ethereum.State
stateSyncData := make(chan *types.StateSyncData, 10)
stateSyncSub := api.events.SubscribeNewDeposits(stateSyncData)

// nolint: gosimple
for {
select {
case h := <-stateSyncData:
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func TestCommand_DebugBlock(t *testing.T) {

// enable developer mode
config.Developer.Enabled = true
config.Developer.Period = 2 // block time
config.Developer.Period = 2 // block time
config.Developer.GasLimit = 11500000 // initial block gaslimit

// enable archive mode for getting traces of ancient blocks
config.GcMode = "archive"
Expand Down
1 change: 1 addition & 0 deletions internal/cli/dumpconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (c *DumpconfigCommand) Run(args []string) int {
userConfig := command.GetConfig()

// convert the big.Int and time.Duration fields to their corresponding Raw fields
userConfig.JsonRPC.RPCEVMTimeoutRaw = userConfig.JsonRPC.RPCEVMTimeout.String()
userConfig.JsonRPC.HttpTimeout.ReadTimeoutRaw = userConfig.JsonRPC.HttpTimeout.ReadTimeout.String()
userConfig.JsonRPC.HttpTimeout.WriteTimeoutRaw = userConfig.JsonRPC.HttpTimeout.WriteTimeout.String()
userConfig.JsonRPC.HttpTimeout.IdleTimeoutRaw = userConfig.JsonRPC.HttpTimeout.IdleTimeout.String()
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/server/chains/developer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// GetDeveloperChain returns the developer mode configs.
func GetDeveloperChain(period uint64, faucet common.Address) *Chain {
func GetDeveloperChain(period uint64, gasLimitt uint64, faucet common.Address) *Chain {
// Override the default period to the user requested one
config := *params.AllCliqueProtocolChanges
config.Clique = &params.CliqueConfig{
Expand All @@ -26,7 +26,7 @@ func GetDeveloperChain(period uint64, faucet common.Address) *Chain {
Genesis: &core.Genesis{
Config: &config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 11500000,
GasLimit: gasLimitt,
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(1),
Alloc: map[common.Address]core.GenesisAccount{
Expand Down
Loading

0 comments on commit 584856b

Please sign in to comment.