Skip to content

Commit 9f5d1db

Browse files
authored
chore: add max int 64 validation for HeaderHashNum and HistoryServeWindow (#795)
1 parent 311b24d commit 9f5d1db

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4545
* (rpc) [#764](https://github.com/crypto-org-chain/ethermint/pull/764) rpc: apply state overrides to eth_estimateGas
4646
* (ante) [#775](https://github.com/crypto-org-chain/ethermint/pull/775) fix: race condition in antecache
4747
* (ante) [#789](https://github.com/crypto-org-chain/ethermint/pull/789) fix: add check on evm transaction tip
48+
* (evm) [#789](https://github.com/crypto-org-chain/ethermint/pull/795) chore: add validation for HeaderHashNum and HistoryServeWindow in params
4849

4950
## [v0.22.0] - 2025-08-12
5051

x/evm/types/params.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package types
1717

1818
import (
1919
"fmt"
20+
"math"
2021
"math/big"
2122

2223
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -89,6 +90,14 @@ func (p Params) Validate() error {
8990
return err
9091
}
9192

93+
if err := ValidateInt64Overflow(p.HeaderHashNum); err != nil {
94+
return err
95+
}
96+
97+
if err := ValidateInt64Overflow(p.HistoryServeWindow); err != nil {
98+
return err
99+
}
100+
92101
return ValidateChainConfig(p.ChainConfig)
93102
}
94103

@@ -140,6 +149,17 @@ func ValidateChainConfig(i interface{}) error {
140149
return cfg.Validate()
141150
}
142151

152+
func ValidateInt64Overflow(i interface{}) error {
153+
num, ok := i.(uint64)
154+
if !ok {
155+
return fmt.Errorf("invalid parameter type: %T", i)
156+
}
157+
if num > math.MaxInt64 {
158+
return fmt.Errorf("value too large: %d, maximum value is: %d", num, uint64(math.MaxInt64))
159+
}
160+
return nil
161+
}
162+
143163
// IsLondon returns if london hardfork is enabled.
144164
func IsLondon(ethConfig *params.ChainConfig, height int64) bool {
145165
return ethConfig.IsLondon(big.NewInt(height))

0 commit comments

Comments
 (0)