From 8827b3a5cb93eb7b20b0c3d602d576245451c9fb Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 1 Oct 2024 18:48:07 +0700 Subject: [PATCH] rename DropAllTxs -> DropTransactions for consistency. Add to txpool interface. Make simulated beacon rollback use the new method, fix old hack --- core/txpool/blobpool/blobpool.go | 4 ++-- core/txpool/legacypool/legacypool.go | 4 ++-- core/txpool/subpool.go | 4 ++-- core/txpool/txpool.go | 7 +++++++ eth/catalyst/simulated_beacon.go | 9 +-------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index 921b1950c6..9737d6cdc7 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -1715,9 +1715,9 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus { return txpool.TxStatusUnknown } -// DropAllTxs implements txpool.SubPool, removing all tracked transactions +// DropTransactions implements txpool.SubPool, removing all tracked transactions // from the blob pool and persistent store. -func (p *BlobPool) DropAllTxs() { +func (p *BlobPool) DropTransactions() { p.lock.Lock() defer p.lock.Unlock() diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 5469b6c580..94fe846371 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1962,9 +1962,9 @@ func numSlots(tx *types.Transaction) int { return int((tx.Size() + txSlotSize - 1) / txSlotSize) } -// DropAllTxs implements txpool.SubPool, removing all tracked txs from the pool +// DropTransactions implements txpool.SubPool, removing all tracked txs from the pool // and rotating the journal. -func (p *LegacyPool) DropAllTxs() { +func (p *LegacyPool) DropTransactions() { p.mu.Lock() defer p.mu.Unlock() diff --git a/core/txpool/subpool.go b/core/txpool/subpool.go index c8d676c1b2..f9312a101b 100644 --- a/core/txpool/subpool.go +++ b/core/txpool/subpool.go @@ -169,6 +169,6 @@ type SubPool interface { // identified by their hashes. Status(hash common.Hash) TxStatus - // DropAllTxs removes all tracked transactions from the pool - DropAllTxs() + // DropTransactions removes all tracked transactions from the pool + DropTransactions() } diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 54ae3be569..90058d15bd 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -497,3 +497,10 @@ func (p *TxPool) Sync() error { return errors.New("pool already terminated") } } + +// DropTransactions removes all tracked txs from the subpools. +func (p *TxPool) DropTransactions() { + for _, subpool := range p.subpools { + subpool.DropTransactions() + } +} diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go index db46afc30d..056ab633a5 100644 --- a/eth/catalyst/simulated_beacon.go +++ b/eth/catalyst/simulated_beacon.go @@ -21,7 +21,6 @@ import ( "crypto/sha256" "errors" "fmt" - "math/big" "sync" "time" @@ -34,7 +33,6 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" - "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" ) @@ -287,12 +285,7 @@ func (c *SimulatedBeacon) Commit() common.Hash { // Rollback un-sends previously added transactions. func (c *SimulatedBeacon) Rollback() { - // Flush all transactions from the transaction pools - maxUint256 := new(big.Int).Sub(new(big.Int).Lsh(common.Big1, 256), common.Big1) - c.eth.TxPool().SetGasTip(maxUint256) - // Set the gas tip back to accept new transactions - // TODO (Marius van der Wijden): set gas tip to parameter passed by config - c.eth.TxPool().SetGasTip(big.NewInt(params.GWei)) + c.eth.TxPool().DropTransactions() } // Fork sets the head to the provided hash.