Skip to content

Commit a1bfa0e

Browse files
authored
remove current state lock (#1438)
* remove current state lock * revert formatting
1 parent 2136604 commit a1bfa0e

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

core/txpool/legacypool/legacypool.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ type LegacyPool struct {
230230
signer types.Signer
231231
mu sync.RWMutex
232232

233-
// [currentStateLock] is required to allow concurrent access to address nonces
234-
// and balances during reorgs and gossip handling.
235-
currentStateLock sync.Mutex
236233
// closed when the transaction pool is stopped. Any goroutine can listen
237234
// to this to be notified if it should shut down.
238235
generalShutdownChan chan struct{}
@@ -688,9 +685,6 @@ func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) erro
688685
// validateTx checks whether a transaction is valid according to the consensus
689686
// rules and adheres to some heuristic limits of the local node (price and size).
690687
func (pool *LegacyPool) validateTx(tx *types.Transaction, local bool) error {
691-
pool.currentStateLock.Lock()
692-
defer pool.currentStateLock.Unlock()
693-
694688
opts := &txpool.ValidationOptionsWithState{
695689
State: pool.currentState,
696690
Rules: pool.chainconfig.Rules(
@@ -1503,9 +1497,7 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
15031497
return
15041498
}
15051499
pool.currentHead.Store(newHead)
1506-
pool.currentStateLock.Lock()
15071500
pool.currentState = statedb
1508-
pool.currentStateLock.Unlock()
15091501
pool.pendingNonces = newNoncer(statedb)
15101502

15111503
// when we reset txPool we should explicitly check if fee struct for min base fee has changed
@@ -1529,9 +1521,6 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
15291521
// future queue to the set of pending transactions. During this process, all
15301522
// invalidated transactions (low nonce, low balance) are deleted.
15311523
func (pool *LegacyPool) promoteExecutables(accounts []common.Address) []*types.Transaction {
1532-
pool.currentStateLock.Lock()
1533-
defer pool.currentStateLock.Unlock()
1534-
15351524
// Track the promoted transactions to broadcast them at once
15361525
var promoted []*types.Transaction
15371526

@@ -1738,9 +1727,6 @@ func (pool *LegacyPool) truncateQueue() {
17381727
// is always explicitly triggered by SetBaseFee and it would be unnecessary and wasteful
17391728
// to trigger a re-heap is this function
17401729
func (pool *LegacyPool) demoteUnexecutables() {
1741-
pool.currentStateLock.Lock()
1742-
defer pool.currentStateLock.Unlock()
1743-
17441730
// Iterate over all accounts and demote any non-executable transactions
17451731
gasLimit := pool.currentHead.Load().GasLimit
17461732
for addr, list := range pool.pending {

0 commit comments

Comments
 (0)