Skip to content

Commit

Permalink
added support for miner.recommit flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikspatil024 committed Feb 14, 2023
1 parent 2c9373f commit fcb722e
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 @@ -59,6 +59,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 @@ ethstats = "" # Reporting URL of a ethstats service (nodename:sec
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 @@ -178,6 +178,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 @@ -59,6 +59,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 @@ -526,6 +530,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 @@ -665,6 +670,7 @@ func (c *Config) fillTimeDurations() error {
td *time.Duration
str *string
}{
{"miner.recommit", &c.Sealer.Recommit, &c.Sealer.RecommitRaw},
{"jsonrpc.evmtimeout", &c.JsonRPC.RPCEVMTimeout, &c.JsonRPC.RPCEVMTimeoutRaw},
{"jsonrpc.timeouts.read", &c.JsonRPC.HttpTimeout.ReadTimeout, &c.JsonRPC.HttpTimeout.ReadTimeoutRaw},
{"jsonrpc.timeouts.write", &c.JsonRPC.HttpTimeout.WriteTimeout, &c.JsonRPC.HttpTimeout.WriteTimeoutRaw},
Expand Down Expand Up @@ -784,6 +790,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

4 comments on commit fcb722e

@thogard785
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Just a heads up - allowing this number to be set below 2 seconds will have a profound impact on polygon. IMO it would be the biggest single change to the chain since its creation. Trades would go from always being comfortably settled in block+2 to all of the sudden having a possibility of block+1 settlement/inclusion. This is probably a good thing for most people, but it would have a profound impact on the incentives that drive bots / spammers. I'm unsure if it'd be for the better or the worse, but things would certainly be different.

@pratikspatil024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @thogard785. I agree with you.

@pratikspatil024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @thogard785 let's discuss it over here.

@thogard785
Copy link
Contributor

@thogard785 thogard785 commented on fcb722e Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Just FYI I’m w/ Fastlane labs - we’re an mev protocol on polygon. this change is definitely something that would benefit us because it would allow us to simulate bundles deterministically (assuming top of block) rather than dealing with risk of something changing in the block in between tx arrival and settlement.

But I also have some concerns:

  1. during sprint changes or if a backup and primary are battling it out for the head, I worry that a mismatched settlement period between the two could have a drastic effect. IE validator of block N is t+1 settlement, but validator of block N +1 is t+2 settlement… so block N+2 might be pretty desolate. There could be other interactions like that too - def worth thinking about.
  2. Trading will be affected. I think for the better, but definitely worth diving deeper on.
  3. I’m curious about the extra load this’ll put on the validator if it gets lowered. Common sense says validators won’t lower it if it hurts performance, but lowering it would be directly tied to more profitable blocks, meaning there’s an economic incentive to increase the stress of their nodes. It might be a trivial increase anyway though, idk.

This is neat though. Selfishly, I hope it goes to live bc it will enable us at pfl to do a LOT of things that we can’t do right now. Let me think about it some more though.

Please sign in to comment.