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

internal/cli: added missing flags #744

Merged
merged 24 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
964944a
minor comment update
pratikspatil024 Feb 14, 2023
ba0cca0
added support for rpc.evmtimeout flag
pratikspatil024 Feb 14, 2023
dd474af
added support for vmdebug (EnablePreimageRecording) flag
pratikspatil024 Feb 14, 2023
2c9373f
added support for jsonrpc.auth.(jwtsecret, addr, port, vhosts) flags
pratikspatil024 Feb 14, 2023
fcb722e
added support for miner.recommit flag
pratikspatil024 Feb 14, 2023
b59d794
added support for gpo.maxheaderhistory and gpo.maxblockhistory flag
pratikspatil024 Feb 15, 2023
ee79398
Revert "added support for miner.recommit flag"
pratikspatil024 Feb 15, 2023
85e21cc
added pprof related flags (expect --pprof.cpuprofile - Write CPU prof…
pratikspatil024 Feb 16, 2023
aeaac2e
added support for --dev.gaslimit flag
pratikspatil024 Feb 16, 2023
9649fe1
added support for --fdlimit flag
pratikspatil024 Feb 17, 2023
fd822ed
added support for --netrestrict flag
pratikspatil024 Feb 22, 2023
f1439ce
added support for --nodekey and --nodekeyhex flag
pratikspatil024 Feb 22, 2023
44c3e7e
added support for --vmodule, --log.json, --log.backtrace, and --log.d…
pratikspatil024 Feb 23, 2023
441efb0
Merge branch 'develop' into pos-1144
pratikspatil024 Feb 24, 2023
2d93fb6
fixed related lint errors
pratikspatil024 Feb 28, 2023
7047437
fix lints from develop (few lints decided to appear from code that wa…
pratikspatil024 Mar 6, 2023
2476c08
more weird lints from develop
pratikspatil024 Mar 9, 2023
f858c86
small precautionary fix
pratikspatil024 Mar 9, 2023
141b8c6
small bug ;) fix in NetRestrict
pratikspatil024 Mar 16, 2023
06ccf84
Merge branch 'develop' of https://github.com/maticnetwork/bor into po…
pratikspatil024 Mar 16, 2023
3fc3be3
weird lints
pratikspatil024 Mar 16, 2023
e7a408b
Merge branch 'develop' of https://github.com/maticnetwork/bor into po…
pratikspatil024 Mar 20, 2023
741e75c
change vmdebug = true to vmdebug = false
pratikspatil024 Mar 20, 2023
c72d42f
Merge branch 'develop' of https://github.com/maticnetwork/bor into po…
pratikspatil024 Mar 20, 2023
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
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 = true
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 @@ -64,6 +74,7 @@ syncmode = "full"
# ipcdisable = false
# ipcpath = ""
# gascap = 50000000
# evmtimeout = "5s"
# txfeecap = 5.0
# allow-unprotected-txs = false
# [jsonrpc.http]
Expand All @@ -88,6 +99,11 @@ syncmode = "full"
# host = ""
# vhosts = ["*"]
# corsdomain = ["*"]
# [jsonrpc.auth]
# jwtsecret = ""
# addr = "localhost"
# port = 8551
# vhosts = ["localhost"]
# [jsonrpc.timeouts]
# read = "30s"
# write = "30s"
Expand All @@ -96,6 +112,8 @@ syncmode = "full"
[gpo]
# blocks = 20
# percentile = 60
# maxheaderhistory = 1024
# maxblockhistory = 1024
# maxprice = "5000000000000"
ignoreprice = "30000000000"

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

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

# [pprof]
# pprof = false
# port = 6060
# addr = "127.0.0.1"
# memprofilerate = 524288
# blockprofilerate = 0
3 changes: 3 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,7 @@ func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types
// the chain mutex to be held.
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
var stateSyncLogs []*types.Log

if stateSyncLogs, err = bc.writeBlockWithState(block, receipts, logs, state); err != nil {
return NonStatTy, err
}
Expand All @@ -1371,13 +1372,15 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
if err != nil {
return NonStatTy, err
}

if reorg {
// Reorganise the chain if the parent is not the head block
if block.ParentHash() != currentBlock.Hash() {
if err := bc.reorg(currentBlock, block); err != nil {
return NonStatTy, err
}
}

status = CanonStatTy
} else {
status = SideStatTy
Expand Down
1 change: 1 addition & 0 deletions core/rawdb/bor_receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.Raw
return data
}
}

return nil // Can't find the data anywhere.
}

Expand Down
9 changes: 6 additions & 3 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ var (
// modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198
//
// def mult_complexity(x):
// if x <= 64: return x ** 2
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
// else: return x ** 2 // 16 + 480 * x - 199680
//
// if x <= 64: return x ** 2
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
// else: return x ** 2 // 16 + 480 * x - 199680
//
// where is x is max(length_of_MODULUS, length_of_BASE)
func modexpMultComplexity(x *big.Int) *big.Int {
Expand Down Expand Up @@ -383,10 +384,12 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
exp = new(big.Int).SetBytes(getData(input, baseLen, expLen))
mod = new(big.Int).SetBytes(getData(input, baseLen+expLen, modLen))
)

if mod.BitLen() == 0 {
// Modulo 0 is undefined, return zero
return common.LeftPadBytes([]byte{}, int(modLen)), nil
}

return common.LeftPadBytes(base.Exp(base, exp, mod).Bytes(), int(modLen)), nil
}

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 = true # 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 @@ -64,6 +74,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 @@ -88,6 +99,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 @@ -96,6 +112,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 @@ -133,6 +151,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 @@ -145,5 +164,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