Skip to content

Commit

Permalink
fix: api: Length check the array sent to eth_feeHistory RPC (#11696)
Browse files Browse the repository at this point in the history
Co-authored-by: Rod Vagg <rod@vagg.org>
Co-authored-by: Steven Allen <steven@stebalien.com>
  • Loading branch information
3 people committed Mar 13, 2024
1 parent f929ae1 commit 9860211
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (

var ErrUnsupported = errors.New("unsupported method")

const maxEthFeeHistoryRewardPercentiles = 100

type EthModuleAPI interface {
EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error)
EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error)
Expand Down Expand Up @@ -698,6 +700,9 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth
}
rewardPercentiles := make([]float64, 0)
if params.RewardPercentiles != nil {
if len(*params.RewardPercentiles) > maxEthFeeHistoryRewardPercentiles {
return ethtypes.EthFeeHistory{}, errors.New("length of the reward percentile array cannot be greater than 100")
}
rewardPercentiles = append(rewardPercentiles, *params.RewardPercentiles...)
}
for i, rp := range rewardPercentiles {
Expand Down

0 comments on commit 9860211

Please sign in to comment.