fix(miner): fix repeatedly processing dropped txs in a new block (#491)

* 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 <peter@scroll.io>

* add lock

* use mu

---------

Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
This commit is contained in:
HAOYUatHZ 2023-08-30 14:38:04 +08:00 committed by GitHub
parent f883dcdc21
commit ea3a3c9a5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -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) {

View file

@ -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

View file

@ -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
)