Skip to content

Commit 141968a

Browse files
authored
core/txpool/legacypool: fix data race in checkDelegationLimit (#31475)
1 parent 714fa4f commit 141968a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/txpool/legacypool/legacypool.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ func (pool *LegacyPool) checkDelegationLimit(tx *types.Transaction) error {
618618
from, _ := types.Sender(pool.signer, tx) // validated
619619

620620
// Short circuit if the sender has neither delegation nor pending delegation.
621-
if pool.currentState.GetCodeHash(from) == types.EmptyCodeHash && len(pool.all.auths[from]) == 0 {
621+
if pool.currentState.GetCodeHash(from) == types.EmptyCodeHash && pool.all.delegationTxsCount(from) == 0 {
622622
return nil
623623
}
624624
pending := pool.pending[from]
@@ -1849,6 +1849,13 @@ func (t *lookup) removeAuthorities(tx *types.Transaction) {
18491849
}
18501850
}
18511851

1852+
// delegationTxsCount returns the number of pending authorizations for the specified address.
1853+
func (t *lookup) delegationTxsCount(addr common.Address) int {
1854+
t.lock.RLock()
1855+
defer t.lock.RUnlock()
1856+
return len(t.auths[addr])
1857+
}
1858+
18521859
// numSlots calculates the number of slots needed for a single transaction.
18531860
func numSlots(tx *types.Transaction) int {
18541861
return int((tx.Size() + txSlotSize - 1) / txSlotSize)

0 commit comments

Comments
 (0)