Skip to content

Commit 019e52c

Browse files
authored
feat(worker): allow empty blocks (#1153)
1 parent e1e578d commit 019e52c

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ var (
133133
utils.MinerNoVerifyFlag,
134134
utils.MinerStoreSkippedTxTracesFlag,
135135
utils.MinerMaxAccountsNumFlag,
136+
utils.MinerAllowEmptyFlag,
136137
utils.NATFlag,
137138
utils.NoDiscoverFlag,
138139
utils.DiscoveryV5Flag,

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
197197
utils.MinerNoVerifyFlag,
198198
utils.MinerStoreSkippedTxTracesFlag,
199199
utils.MinerMaxAccountsNumFlag,
200+
utils.MinerAllowEmptyFlag,
200201
},
201202
},
202203
{

cmd/utils/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ var (
515515
Usage: "Maximum number of accounts that miner will fetch the pending transactions of when building a new block",
516516
Value: math.MaxInt,
517517
}
518+
MinerAllowEmptyFlag = cli.BoolFlag{
519+
Name: "miner.allowempty",
520+
Usage: "Allow sealing empty blocks",
521+
}
518522
// Account settings
519523
UnlockedAccountFlag = cli.StringFlag{
520524
Name: "unlock",
@@ -1620,6 +1624,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
16201624
if ctx.GlobalIsSet(MinerMaxAccountsNumFlag.Name) {
16211625
cfg.MaxAccountsNum = ctx.GlobalInt(MinerMaxAccountsNumFlag.Name)
16221626
}
1627+
if ctx.GlobalIsSet(MinerAllowEmptyFlag.Name) {
1628+
cfg.AllowEmpty = ctx.GlobalBool(MinerAllowEmptyFlag.Name)
1629+
}
16231630
if ctx.GlobalIsSet(LegacyMinerGasTargetFlag.Name) {
16241631
log.Warn("The generic --miner.gastarget flag is deprecated and will be removed in the future!")
16251632
}

miner/miner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type Config struct {
6060
StoreSkippedTxTraces bool // Whether store the wrapped traces when storing a skipped tx
6161
MaxAccountsNum int // Maximum number of accounts that miner will fetch the pending transactions of when building a new block
6262
CCCMaxWorkers int // Maximum number of workers to use for async CCC tasks
63+
AllowEmpty bool // If true, then we allow sealing empty blocks
6364

6465
SigningDisabled bool // Whether to disable signing blocks with consensus enginek
6566
}

miner/scroll_worker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ func (w *worker) mainLoop() {
400400
w.current.deadlineReached = true
401401
if len(w.current.txs) > 0 {
402402
_, err = w.commit()
403+
} else if w.config.AllowEmpty {
404+
log.Warn("Committing empty block", "number", w.current.header.Number)
405+
_, err = w.commit()
403406
}
404407
case ev := <-w.txsCh:
405408
idleTimer.UpdateSince(idleStart)

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 28 // Patch version component of the current release
27+
VersionPatch = 29 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)