Commit 776df0a9 authored by Conner Fromknecht's avatar Conner Fromknecht

fix: remove empty block mining argument

As of the prior commit, all calls to the `commit` pass a noempty value
of true, indicating that the sequencer should not start mining empty
blocks. Therefore, we can remove all usage of noempty from the worker.
parent 285f0b2c
...@@ -110,7 +110,6 @@ const ( ...@@ -110,7 +110,6 @@ const (
// newWorkReq represents a request for new sealing work submitting with relative interrupt notifier. // newWorkReq represents a request for new sealing work submitting with relative interrupt notifier.
type newWorkReq struct { type newWorkReq struct {
interrupt *int32 interrupt *int32
noempty bool
timestamp int64 timestamp int64
} }
...@@ -307,12 +306,12 @@ func (w *worker) newWorkLoop(recommit time.Duration) { ...@@ -307,12 +306,12 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
<-timer.C // discard the initial tick <-timer.C // discard the initial tick
// commit aborts in-flight transaction execution with given signal and resubmits a new one. // commit aborts in-flight transaction execution with given signal and resubmits a new one.
commit := func(noempty bool, s int32) { commit := func(s int32) {
if interrupt != nil { if interrupt != nil {
atomic.StoreInt32(interrupt, s) atomic.StoreInt32(interrupt, s)
} }
interrupt = new(int32) interrupt = new(int32)
w.newWorkCh <- &newWorkReq{interrupt: interrupt, noempty: noempty, timestamp: timestamp} w.newWorkCh <- &newWorkReq{interrupt: interrupt, timestamp: timestamp}
timer.Reset(recommit) timer.Reset(recommit)
atomic.StoreInt32(&w.newTxs, 0) atomic.StoreInt32(&w.newTxs, 0)
} }
...@@ -352,7 +351,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) { ...@@ -352,7 +351,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
select { select {
case <-w.startCh: case <-w.startCh:
clearPending(w.chain.CurrentBlock().NumberU64()) clearPending(w.chain.CurrentBlock().NumberU64())
commit(true, commitInterruptNewHead) commit(commitInterruptNewHead)
// Remove this code for the OVM implementation. It is responsible for // Remove this code for the OVM implementation. It is responsible for
// cleaning up memory with the call to `clearPending`, so be sure to // cleaning up memory with the call to `clearPending`, so be sure to
...@@ -361,7 +360,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) { ...@@ -361,7 +360,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
case <-w.chainHeadCh: case <-w.chainHeadCh:
clearPending(head.Block.NumberU64()) clearPending(head.Block.NumberU64())
timestamp = time.Now().Unix() timestamp = time.Now().Unix()
commit(false, commitInterruptNewHead) commit(commitInterruptNewHead)
*/ */
case <-timer.C: case <-timer.C:
...@@ -373,7 +372,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) { ...@@ -373,7 +372,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timer.Reset(recommit) timer.Reset(recommit)
continue continue
} }
commit(true, commitInterruptResubmit) commit(commitInterruptResubmit)
} }
case interval := <-w.resubmitIntervalCh: case interval := <-w.resubmitIntervalCh:
...@@ -421,7 +420,7 @@ func (w *worker) mainLoop() { ...@@ -421,7 +420,7 @@ func (w *worker) mainLoop() {
for { for {
select { select {
case req := <-w.newWorkCh: case req := <-w.newWorkCh:
w.commitNewWork(req.interrupt, req.noempty, req.timestamp) w.commitNewWork(req.interrupt, req.timestamp)
case ev := <-w.chainSideCh: case ev := <-w.chainSideCh:
// Short circuit for duplicate side blocks // Short circuit for duplicate side blocks
...@@ -544,7 +543,7 @@ func (w *worker) mainLoop() { ...@@ -544,7 +543,7 @@ func (w *worker) mainLoop() {
// If clique is running in dev mode(period is 0), disable // If clique is running in dev mode(period is 0), disable
// advance sealing here. // advance sealing here.
if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 { if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 {
w.commitNewWork(nil, true, time.Now().Unix()) w.commitNewWork(nil, time.Now().Unix())
} }
} }
atomic.AddInt32(&w.newTxs, int32(len(ev.Txs))) atomic.AddInt32(&w.newTxs, int32(len(ev.Txs)))
...@@ -960,7 +959,7 @@ func (w *worker) commitNewTx(tx *types.Transaction) error { ...@@ -960,7 +959,7 @@ func (w *worker) commitNewTx(tx *types.Transaction) error {
} }
// commitNewWork generates several new sealing tasks based on the parent block. // commitNewWork generates several new sealing tasks based on the parent block.
func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) { func (w *worker) commitNewWork(interrupt *int32, timestamp int64) {
w.mu.RLock() w.mu.RLock()
defer w.mu.RUnlock() defer w.mu.RUnlock()
...@@ -1036,12 +1035,6 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64) ...@@ -1036,12 +1035,6 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
commitUncles(w.localUncles) commitUncles(w.localUncles)
commitUncles(w.remoteUncles) commitUncles(w.remoteUncles)
if !noempty {
// Create an empty block based on temporary copied state for sealing in advance without waiting block
// execution finished.
w.commit(uncles, nil, false, tstart)
}
// Fill the block with all available pending transactions. // Fill the block with all available pending transactions.
pending, err := w.eth.TxPool().Pending() pending, err := w.eth.TxPool().Pending()
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment