Skip to content

Commit

Permalink
eth/gasprice: add query limit to defend DDOS attack (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlacfzy authored Apr 25, 2024
1 parent 2a0e399 commit 7cab9c6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions eth/gasprice/feehistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ 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 = 100
)

// blockFees represents a single block for processing
Expand Down Expand Up @@ -219,6 +220,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
Expand Down

0 comments on commit 7cab9c6

Please sign in to comment.