mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
core/txpool/blobpool: limit reorder buffer size for DoS protection
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
cb59ff5cf8
commit
81a116801d
1 changed files with 7 additions and 1 deletions
|
|
@ -101,6 +101,10 @@ const (
|
|||
// the pool will still accept and convert legacy blob transactions. After this
|
||||
// window, all legacy blob transactions will be rejected.
|
||||
conversionTimeWindow = time.Hour * 2
|
||||
|
||||
// maxGappedTxs is the maximum number of gapped transactions kept overall.
|
||||
// This is a safety limit to avoid DoS vectors.
|
||||
maxGapped = 128
|
||||
)
|
||||
|
||||
// blobTxMeta is the minimal subset of types.BlobTx necessary to validate and
|
||||
|
|
@ -1739,7 +1743,9 @@ func (p *BlobPool) add(tx *types.Transaction) (err error) {
|
|||
// Store the tx in memory, and revalidate later
|
||||
from, _ := types.Sender(p.signer, tx)
|
||||
allowance := p.gappedAllowance(from)
|
||||
if allowance >= 1 {
|
||||
if allowance >= 1 && len(p.gapped) < maxGapped {
|
||||
// if maxGapped is reached, it is better to give time to gapped
|
||||
// transactions by keeping the old and dropping this one
|
||||
p.gapped[from] = append(p.gapped[from], tx)
|
||||
log.Trace("blobpool:add added to Gapped blob queue", "allowance", allowance, "hash", tx.Hash(), "from", from, "nonce", tx.Nonce(), "qlen", len(p.gapped[from]))
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue