From ea3a3c9a5d4617838c0eb0b2e8e8970a0e727ca4 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Wed, 30 Aug 2023 14:38:04 +0800 Subject: [PATCH] fix(miner): fix repeatedly processing dropped txs in a new block (#491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * squash * improve comments * Remove tx (#493) * force drop * minor * store skipped L2 tx for `circuitcapacitychecker.ErrUnknown` * Update miner/worker.go Co-authored-by: Péter Garamvölgyi * add lock * use mu --------- Co-authored-by: Péter Garamvölgyi --- core/tx_pool.go | 9 +++++++++ miner/worker.go | 4 ++++ params/version.go | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index abd45c796c..e9a8894af3 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1023,6 +1023,15 @@ func (pool *TxPool) Has(hash common.Hash) bool { return pool.all.Get(hash) != nil } +// RemoveTx is similar to removeTx, but with locking to prevent concurrency. +// Note: currently should only be called by miner/worker.go. +func (pool *TxPool) RemoveTx(hash common.Hash, outofbound bool) { + pool.mu.Lock() + defer pool.mu.Unlock() + + pool.removeTx(hash, outofbound) +} + // removeTx removes a single transaction from the queue, moving all subsequent // transactions back to the future queue. func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) { diff --git a/miner/worker.go b/miner/worker.go index 3476d26688..0e463f2bcb 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1090,6 +1090,7 @@ loop: // Skip L2 transaction and all other transactions from the same sender account log.Info("Skipping L2 message", "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "first tx row consumption overflow") txs.Pop() + w.eth.TxPool().RemoveTx(tx.Hash(), true) } // Reset ccc so that we can process other transactions for this block @@ -1121,10 +1122,13 @@ loop: // Circuit capacity check: unknown circuit capacity checker error for L2MessageTx, skip the account log.Trace("Unknown circuit capacity checker error for L2MessageTx", "tx", tx.Hash().String()) log.Info("Skipping L2 message", "tx", tx.Hash().String(), "block", w.current.header.Number, "reason", "unknown row consumption error") + // TODO: propagate more info about the error from CCC + rawdb.WriteSkippedTransaction(w.eth.ChainDb(), tx, "unknown circuit capacity checker error", w.current.header.Number.Uint64(), nil) // Normally we would do `txs.Pop()` here. // However, after `ErrUnknown`, ccc might remain in an // inconsistent state, so we cannot pack more transactions. + w.eth.TxPool().RemoveTx(tx.Hash(), true) circuitCapacityReached = true break loop diff --git a/params/version.go b/params/version.go index 44d4eacb2b..8bc7b09a83 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 4 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 55 // Patch version component of the current release + VersionPatch = 56 // Patch version component of the current release VersionMeta = "sepolia" // Version metadata to append to the version string )