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 11, 2024
1 parent d9a0040 commit 7516aff
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 @@ -41,6 +41,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 @@ -689,6 +691,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 7516aff

Please sign in to comment.