From 3112cc14e5bf4562cd6015a3a5c557fb0965621b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Mon, 23 Sep 2024 08:42:35 +0300 Subject: [PATCH] remove pause/resume reorg --- core/tx_pool.go | 24 +----------------------- miner/scroll_worker.go | 7 ------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 41b253e70227..281168114c9a 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -280,7 +280,6 @@ type TxPool struct { queueTxEventCh chan *types.Transaction reorgDoneCh chan chan struct{} reorgShutdownCh chan struct{} // requests shutdown of scheduleReorgLoop - reorgPauseCh chan bool // requests to pause scheduleReorgLoop realTxActivityShutdownCh chan struct{} wg sync.WaitGroup // tracks loop, scheduleReorgLoop initDoneCh chan struct{} // is closed once the pool is initialized (for tests) @@ -317,7 +316,6 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block reorgDoneCh: make(chan chan struct{}), reorgShutdownCh: make(chan struct{}), realTxActivityShutdownCh: make(chan struct{}), - reorgPauseCh: make(chan bool), initDoneCh: make(chan struct{}), gasPrice: new(big.Int).SetUint64(config.PriceLimit), } @@ -1229,14 +1227,13 @@ func (pool *TxPool) scheduleReorgLoop() { curDone chan struct{} // non-nil while runReorg is active nextDone = make(chan struct{}) launchNextRun bool - reorgsPaused bool reset *txpoolResetRequest dirtyAccounts *accountSet queuedEvents = make(map[common.Address]*txSortedMap) ) for { // Launch next background reorg if needed - if curDone == nil && launchNextRun && !reorgsPaused { + if curDone == nil && launchNextRun { // Run the background reorg and announcements go pool.runReorg(nextDone, reset, dirtyAccounts, queuedEvents) @@ -1288,7 +1285,6 @@ func (pool *TxPool) scheduleReorgLoop() { } close(nextDone) return - case reorgsPaused = <-pool.reorgPauseCh: } } } @@ -1793,24 +1789,6 @@ func (pool *TxPool) calculateTxsLifecycle(txs types.Transactions, t time.Time) { } } -// PauseReorgs stops any new reorg jobs to be started but doesn't interrupt any existing ones that are in flight -// Keep in mind this function might block, although it is not expected to block for any significant amount of time -func (pool *TxPool) PauseReorgs() { - select { - case pool.reorgPauseCh <- true: - case <-pool.reorgShutdownCh: - } -} - -// ResumeReorgs allows new reorg jobs to be started. -// Keep in mind this function might block, although it is not expected to block for any significant amount of time -func (pool *TxPool) ResumeReorgs() { - select { - case pool.reorgPauseCh <- false: - case <-pool.reorgShutdownCh: - } -} - // addressByHeartbeat is an account address tagged with its last activity timestamp. type addressByHeartbeat struct { address common.Address diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 02f331bc200a..8f7c76c69025 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -569,9 +569,6 @@ func (w *worker) processTxPool() (bool, error) { // Fill the block with all available pending transactions. pending := w.eth.TxPool().PendingWithMax(false, w.config.MaxAccountsNum) - // Allow txpool to be reorged as we build current block - w.eth.TxPool().ResumeReorgs() - // Split the pending transactions into locals and remotes localTxs, remoteTxs := make(map[common.Address]types.Transactions), pending for _, account := range w.eth.TxPool().Locals() { @@ -892,10 +889,6 @@ func (w *worker) commit() (common.Hash, error) { } } - // A new block event will trigger a reorg in the txpool, pause reorgs to defer this until we fetch txns for next block. - // We may end up trying to process txns that we already included in the previous block, but they will all fail the nonce check - w.eth.TxPool().PauseReorgs() - // Commit block and state to database. _, err = w.chain.WriteBlockWithState(block, w.current.receipts, w.current.coalescedLogs, w.current.state, true) if err != nil {