Skip to content

Commit

Permalink
added support for miner.recommit flag (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikspatil024 authored Mar 17, 2023
1 parent c917e6f commit 238b449
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ syncmode = "full"
# mine = true
# etherbase = "VALIDATOR ADDRESS"
# extradata = ""
# recommit = "2m5s"


# [jsonrpc]
Expand Down
1 change: 1 addition & 0 deletions docs/cli/example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ devfakeauthor = false # Run miner without validator set authorization [de
extradata = "" # Block extra data set by the miner (default = client version)
gaslimit = 30000000 # Target gas ceiling for mined blocks
gasprice = "1000000000" # Minimum gas price for mining a transaction (recommended for mainnet = 30000000000, default suitable for mumbai/devnet)
recommit = "2m5s" # The time interval for miner to re-create mining work

[jsonrpc]
ipcdisable = false # Disable the IPC-RPC server
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ The ```bor server``` command runs the Bor client.

- ```miner.gasprice```: Minimum gas price for mining a transaction (default: 1000000000)

- ```miner.recommit```: The time interval for miner to re-create mining work (default: 2m5s)

### Telemetry Options

- ```metrics```: Enable metrics collection and reporting (default: false)
Expand Down
1 change: 1 addition & 0 deletions internal/cli/dumpconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (c *DumpconfigCommand) Run(args []string) int {
userConfig.TxPool.RejournalRaw = userConfig.TxPool.Rejournal.String()
userConfig.TxPool.LifeTimeRaw = userConfig.TxPool.LifeTime.String()
userConfig.Sealer.GasPriceRaw = userConfig.Sealer.GasPrice.String()
userConfig.Sealer.RecommitRaw = userConfig.Sealer.Recommit.String()
userConfig.Gpo.MaxPriceRaw = userConfig.Gpo.MaxPrice.String()
userConfig.Gpo.IgnorePriceRaw = userConfig.Gpo.IgnorePrice.String()
userConfig.Cache.RejournalRaw = userConfig.Cache.Rejournal.String()
Expand Down
7 changes: 7 additions & 0 deletions internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ type SealerConfig struct {
// GasPrice is the minimum gas price for mining a transaction
GasPrice *big.Int `hcl:"-,optional" toml:"-"`
GasPriceRaw string `hcl:"gasprice,optional" toml:"gasprice,optional"`

// The time interval for miner to re-create mining work.
Recommit time.Duration `hcl:"-,optional" toml:"-"`
RecommitRaw string `hcl:"recommit,optional" toml:"recommit,optional"`
}

type JsonRPCConfig struct {
Expand Down Expand Up @@ -505,6 +509,7 @@ func DefaultConfig() *Config {
GasCeil: 30_000_000, // geth's default
GasPrice: big.NewInt(1 * params.GWei), // geth's default
ExtraData: "",
Recommit: 125 * time.Second,
},
Gpo: &GpoConfig{
Blocks: 20,
Expand Down Expand Up @@ -638,6 +643,7 @@ func (c *Config) fillTimeDurations() error {
td *time.Duration
str *string
}{
{"miner.recommit", &c.Sealer.Recommit, &c.Sealer.RecommitRaw},
{"jsonrpc.timeouts.read", &c.JsonRPC.HttpTimeout.ReadTimeout, &c.JsonRPC.HttpTimeout.ReadTimeoutRaw},
{"jsonrpc.timeouts.write", &c.JsonRPC.HttpTimeout.WriteTimeout, &c.JsonRPC.HttpTimeout.WriteTimeoutRaw},
{"jsonrpc.timeouts.idle", &c.JsonRPC.HttpTimeout.IdleTimeout, &c.JsonRPC.HttpTimeout.IdleTimeoutRaw},
Expand Down Expand Up @@ -758,6 +764,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*

// miner options
{
n.Miner.Recommit = c.Sealer.Recommit
n.Miner.GasPrice = c.Sealer.GasPrice
n.Miner.GasCeil = c.Sealer.GasCeil
n.Miner.ExtraData = []byte(c.Sealer.ExtraData)
Expand Down
7 changes: 7 additions & 0 deletions internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ func (c *Command) Flags() *flagset.Flagset {
Group: "Sealer",
Default: c.cliConfig.Sealer.GasPrice,
})
f.DurationFlag(&flagset.DurationFlag{
Name: "miner.recommit",
Usage: "The time interval for miner to re-create mining work",
Value: &c.cliConfig.Sealer.Recommit,
Default: c.cliConfig.Sealer.Recommit,
Group: "Sealer",
})

// ethstats
f.StringFlag(&flagset.StringFlag{
Expand Down
1 change: 1 addition & 0 deletions packaging/templates/mainnet-v1/archive/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ gcmode = "archive"
# mine = false
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ syncmode = "full"
# mine = false
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ syncmode = "full"
gasprice = "30000000000"
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ syncmode = "full"
gasprice = "30000000000"
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
1 change: 1 addition & 0 deletions packaging/templates/testnet-v4/archive/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ gcmode = "archive"
# mine = false
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ syncmode = "full"
# mine = false
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ syncmode = "full"
# gasprice = "1000000000"
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ syncmode = "full"
# gasprice = "1000000000"
# etherbase = ""
# extradata = ""
# recommit = "2m5s"

[jsonrpc]
ipcpath = "/var/lib/bor/bor.ipc"
Expand Down

0 comments on commit 238b449

Please sign in to comment.