Skip to content

Commit

Permalink
rollup: do not add reorganized txs to mempool (ethereum#92)
Browse files Browse the repository at this point in the history
* rollup: do not add reorganized txs to mempool

* txpool: fix build

* txpool: hide behind usingovm
  • Loading branch information
tynes authored Nov 11, 2020
1 parent 7099c4c commit 008a57d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"math"
"math/big"
"os"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -1168,10 +1169,14 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.pendingNonces = newTxNoncer(statedb)
pool.currentMaxGas = newHead.GasLimit

// Inject any transactions discarded due to reorgs
log.Debug("Reinjecting stale transactions", "count", len(reinject))
senderCacher.recover(pool.signer, reinject)
pool.addTxsLocked(reinject, false)
// OVM Change. Do not reinject reorganized transactions
// into the mempool.
if os.Getenv("USING_OVM") != "true" {
// Inject any transactions discarded due to reorgs
log.Debug("Reinjecting stale transactions", "count", len(reinject))
senderCacher.recover(pool.signer, reinject)
pool.addTxsLocked(reinject, false)
}

// Update all fork indicator by next pending block number.
next := new(big.Int).Add(newHead.Number, big.NewInt(1))
Expand Down
2 changes: 1 addition & 1 deletion rollup/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ func (s *SyncService) maybeReorg(index uint64, tx *types.Transaction) error {
// due to nonces coming from the god key. Do an equality check using
// `to`, `data`, `l1TxOrigin` and `gasLimit`
if !isCtcTxEqual(tx, prev) {
log.Info("Different transaction detected, reorganizing", "new", tx.Hash().Hex(), "previous", prev.Hash().Hex())
log.Info("Different transaction detected, reorganizing", "new", tx.Hash().Hex(), "previous", prev.Hash().Hex(), "index", index)
// Set the sync status to true. This will grab a lock around
// the mempool such that transactions will no longer be able to come
// via RPC.
Expand Down

0 comments on commit 008a57d

Please sign in to comment.