mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-23 23:24:30 +00:00
eth/gasprice: add query limit for FeeHistory to defend DDOS attack (#29644)
This commit is contained in:
parent
bdd7cf1f0c
commit
8f68af5da0
1 changed files with 5 additions and 0 deletions
|
|
@ -42,6 +42,8 @@ const (
|
|||
// maxBlockFetchers is the max number of goroutines to spin up to pull blocks
|
||||
// for the fee history calculation (mostly relevant for LES).
|
||||
maxBlockFetchers = 4
|
||||
// maxQueryLimit is the max number of requested percentiles.
|
||||
maxQueryLimit = 100
|
||||
)
|
||||
|
||||
// blockFees represents a single block for processing
|
||||
|
|
@ -221,6 +223,9 @@ func (oracle *Oracle) FeeHistory(ctx context.Context, blocks uint64, unresolvedL
|
|||
if len(rewardPercentiles) != 0 {
|
||||
maxFeeHistory = oracle.maxBlockHistory
|
||||
}
|
||||
if len(rewardPercentiles) > maxQueryLimit {
|
||||
return common.Big0, nil, nil, nil, fmt.Errorf("%w: over the query limit %d", errInvalidPercentile, maxQueryLimit)
|
||||
}
|
||||
if blocks > maxFeeHistory {
|
||||
log.Warn("Sanitizing fee history length", "requested", blocks, "truncated", maxFeeHistory)
|
||||
blocks = maxFeeHistory
|
||||
|
|
|
|||
Loading…
Reference in a new issue