Skip to content

Commit

Permalink
fix(miner): fix repeatedly processing dropped txs in a new block (#491)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
HAOYUatHZ and Thegaram committed Aug 30, 2023
1 parent f883dcd commit ea3a3c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit ea3a3c9

Please sign in to comment.