From e7c877a603b118d960e250580e169f68da3578cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Thu, 13 Jun 2024 10:36:33 +0300 Subject: [PATCH 1/5] remove chainside related stuff --- miner/scroll_worker.go | 18 ------------------ miner/scroll_worker_test.go | 2 -- 2 files changed, 20 deletions(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 884076fa37a8..143219071c55 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -50,9 +50,6 @@ const ( // chainHeadChanSize is the size of channel listening to ChainHeadEvent. chainHeadChanSize = 10 - // chainSideChanSize is the size of channel listening to ChainSideEvent. - chainSideChanSize = 10 - // minRecommitInterval is the minimal time interval to recreate the mining block with // any newly arrived transactions. minRecommitInterval = 1 * time.Second @@ -108,8 +105,6 @@ type worker struct { txsSub event.Subscription chainHeadCh chan core.ChainHeadEvent chainHeadSub event.Subscription - chainSideCh chan core.ChainSideEvent - chainSideSub event.Subscription // Channels newWorkCh chan *newWorkReq @@ -163,7 +158,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus isLocalBlock: isLocalBlock, txsCh: make(chan core.NewTxsEvent, txChanSize), chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize), - chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize), newWorkCh: make(chan *newWorkReq), exitCh: make(chan struct{}), startCh: make(chan struct{}, 1), @@ -176,7 +170,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus // Subscribe events for blockchain worker.chainHeadSub = eth.BlockChain().SubscribeChainHeadEvent(worker.chainHeadCh) - worker.chainSideSub = eth.BlockChain().SubscribeChainSideEvent(worker.chainSideCh) // Sanitize recommit interval if the user-specified one is too short. recommit := worker.config.Recommit @@ -326,7 +319,6 @@ func (w *worker) mainLoop() { defer w.wg.Done() defer w.txsSub.Unsubscribe() defer w.chainHeadSub.Unsubscribe() - defer w.chainSideSub.Unsubscribe() deadCh := make(chan *pipeline.Result) pipelineResultCh := func() <-chan *pipeline.Result { @@ -369,8 +361,6 @@ func (w *worker) mainLoop() { return case <-w.chainHeadSub.Err(): return - case <-w.chainSideSub.Err(): - return } } } @@ -798,14 +788,6 @@ func copyReceipts(receipts []*types.Receipt) []*types.Receipt { return result } -// postSideBlock fires a side chain event, only use it for testing. -func (w *worker) postSideBlock(event core.ChainSideEvent) { - select { - case w.chainSideCh <- event: - case <-w.exitCh: - } -} - func (w *worker) onTxFailingInPipeline(txIndex int, tx *types.Transaction, err error) bool { if !w.isRunning() { return false diff --git a/miner/scroll_worker_test.go b/miner/scroll_worker_test.go index 15958580ed1e..f5feed40ab2e 100644 --- a/miner/scroll_worker_test.go +++ b/miner/scroll_worker_test.go @@ -254,8 +254,6 @@ func testGenerateBlockAndImport(t *testing.T, isClique bool) { for i := 0; i < 5; i++ { b.txPool.AddLocal(b.newRandomTx(true)) b.txPool.AddLocal(b.newRandomTx(false)) - w.postSideBlock(core.ChainSideEvent{Block: b.newRandomUncle()}) - w.postSideBlock(core.ChainSideEvent{Block: b.newRandomUncle()}) select { case ev := <-sub.Chan(): From 0c660107f0caa547354941d81188264a9e4638ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Thu, 13 Jun 2024 10:44:50 +0300 Subject: [PATCH 2/5] remove newworkloop --- miner/scroll_worker.go | 53 ++++++------------------------------------ 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 143219071c55..6c40f5a89a1d 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -74,12 +74,6 @@ var ( commitGasCounter = metrics.NewRegisteredCounter("miner/commit_gas", nil) ) -// newWorkReq represents a request for new sealing work submitting with relative interrupt notifier. -type newWorkReq struct { - noempty bool - timestamp int64 -} - // prioritizedTransaction represents a single transaction that // should be processed as the first transaction in the next block. type prioritizedTransaction struct { @@ -107,9 +101,8 @@ type worker struct { chainHeadSub event.Subscription // Channels - newWorkCh chan *newWorkReq - startCh chan struct{} - exitCh chan struct{} + startCh chan struct{} + exitCh chan struct{} wg sync.WaitGroup @@ -158,7 +151,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus isLocalBlock: isLocalBlock, txsCh: make(chan core.NewTxsEvent, txChanSize), chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize), - newWorkCh: make(chan *newWorkReq), exitCh: make(chan struct{}), startCh: make(chan struct{}, 1), circuitCapacityChecker: circuitcapacitychecker.NewCircuitCapacityChecker(true), @@ -184,9 +176,8 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus worker.config.MaxAccountsNum = math.MaxInt } - worker.wg.Add(2) + worker.wg.Add(1) go worker.mainLoop() - go worker.newWorkLoop(recommit) // Submit first work to initialize pending state. if init { @@ -282,38 +273,6 @@ func (w *worker) close() { w.wg.Wait() } -// newWorkLoop is a standalone goroutine to submit new mining work upon received events. -func (w *worker) newWorkLoop(recommit time.Duration) { - defer w.wg.Done() - var ( - timestamp int64 // timestamp for each round of mining. - ) - - // commit aborts in-flight transaction execution with given signal and resubmits a new one. - commit := func(noempty bool) { - select { - case w.newWorkCh <- &newWorkReq{noempty: noempty, timestamp: timestamp}: - case <-w.exitCh: - return - } - atomic.StoreInt32(&w.newTxs, 0) - atomic.StoreInt32(&w.newL1Msgs, 0) - } - - for { - select { - case <-w.startCh: - timestamp = time.Now().Unix() - commit(false) - case <-w.chainHeadCh: - timestamp = time.Now().Unix() - commit(true) - case <-w.exitCh: - return - } - } -} - // mainLoop is a standalone goroutine to regenerate the sealing task based on the received event. func (w *worker) mainLoop() { defer w.wg.Done() @@ -330,8 +289,10 @@ func (w *worker) mainLoop() { for { select { - case req := <-w.newWorkCh: - w.startNewPipeline(req.timestamp) + case <-w.startCh: + w.startNewPipeline(time.Now().Unix()) + case <-w.chainHeadCh: + w.startNewPipeline(time.Now().Unix()) case result := <-pipelineResultCh(): w.handlePipelineResult(result) case ev := <-w.txsCh: From ff6092c2529a45c45679bad7f71288e1f96b4766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Thu, 13 Jun 2024 10:45:31 +0300 Subject: [PATCH 3/5] remove unused --- miner/scroll_worker.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 6c40f5a89a1d..04d74caf8876 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -119,9 +119,8 @@ type worker struct { snapshotState *state.StateDB // atomic status counters - running int32 // The indicator whether the consensus engine is running or not. - newTxs int32 // New arrival transaction count since last sealing work submitting. - newL1Msgs int32 // New arrival L1 message count since last sealing work submitting. + running int32 // The indicator whether the consensus engine is running or not. + newTxs int32 // New arrival transaction count since last sealing work submitting. // noempty is the flag used to control whether the feature of pre-seal empty // block is enabled. The default value is false(pre-seal is enabled by default). From 7b038b5be32e59dc9c6e6df78a1e97a6a2b855a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Thu, 13 Jun 2024 10:46:06 +0300 Subject: [PATCH 4/5] remove unused recommit --- miner/scroll_worker.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 04d74caf8876..2f07cc4e81db 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -162,13 +162,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus // Subscribe events for blockchain worker.chainHeadSub = eth.BlockChain().SubscribeChainHeadEvent(worker.chainHeadCh) - // Sanitize recommit interval if the user-specified one is too short. - recommit := worker.config.Recommit - if recommit < minRecommitInterval { - log.Warn("Sanitizing miner recommit interval", "provided", recommit, "updated", minRecommitInterval) - recommit = minRecommitInterval - } - // Sanitize account fetch limit. if worker.config.MaxAccountsNum == 0 { log.Warn("Sanitizing miner account fetch limit", "provided", worker.config.MaxAccountsNum, "updated", math.MaxInt) From 48b999a5f08e1ae6f00c5e3eeb55cc983d9c51c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Thu, 13 Jun 2024 10:56:22 +0300 Subject: [PATCH 5/5] removeunsused --- miner/scroll_worker.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 2f07cc4e81db..749f290fb9c5 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -49,10 +49,6 @@ const ( // chainHeadChanSize is the size of channel listening to ChainHeadEvent. chainHeadChanSize = 10 - - // minRecommitInterval is the minimal time interval to recreate the mining block with - // any newly arrived transactions. - minRecommitInterval = 1 * time.Second ) var (