Skip to content

Commit 59ace5d

Browse files
committed
Merge remote-tracking branch 'origin/develop' into sdk50
2 parents b6aa546 + c39e892 commit 59ace5d

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
7979
- (evm) [#405](https://github.com/crypto-org-chain/ethermint/pull/405) Avoid duplicate cache events emitted from evm hooks.
8080
- (rpc) [#406](https://github.com/crypto-org-chain/ethermint/pull/406) Align filter rule for eth_getLogs when toBlock is newer than latest or extract error occurs.
8181
- (rpc) [#409](https://github.com/crypto-org-chain/ethermint/pull/409) Fix nextBaseFee in eth_feeHistory before fee market param change.
82+
- (rpc) [#425](https://github.com/crypto-org-chain/ethermint/pull/425) Avoid Int64() out of bound error in gas related api.
8283

8384
### Improvements
8485

rpc/backend/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type EVMBackend interface {
7272
RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
7373
RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection
7474
RPCTxFeeCap() float64 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for send-transaction variants. The unit is ether.
75-
RPCMinGasPrice() int64
75+
RPCMinGasPrice() *big.Int
7676

7777
// Sign Tx
7878
Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)

rpc/backend/call_tx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ func (b *Backend) GasPrice() (*hexutil.Big, error) {
432432
}
433433
result = result.Add(result, head.BaseFee)
434434
} else {
435-
result = big.NewInt(b.RPCMinGasPrice())
435+
result = b.RPCMinGasPrice()
436436
}
437437

438438
// return at least GlobalMinGasPrice from FeeMarket module

rpc/backend/node_info.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,17 @@ func (b *Backend) RPCBlockRangeCap() int32 {
333333
// RPCMinGasPrice returns the minimum gas price for a transaction obtained from
334334
// the node config. If set value is 0, it will default to 20.
335335

336-
func (b *Backend) RPCMinGasPrice() int64 {
336+
func (b *Backend) RPCMinGasPrice() *big.Int {
337337
evmParams, err := b.queryClient.Params(b.ctx, &evmtypes.QueryParamsRequest{})
338338
if err != nil {
339-
return ethermint.DefaultGasPrice
339+
return new(big.Int).SetInt64(ethermint.DefaultGasPrice)
340340
}
341341

342342
minGasPrice := b.cfg.GetMinGasPrices()
343-
amt := minGasPrice.AmountOf(evmParams.Params.EvmDenom).TruncateInt64()
344-
if amt == 0 {
345-
return ethermint.DefaultGasPrice
343+
amt := minGasPrice.AmountOf(evmParams.Params.EvmDenom).TruncateInt()
344+
if amt.IsZero() {
345+
return new(big.Int).SetInt64(ethermint.DefaultGasPrice)
346346
}
347347

348-
return amt
348+
return amt.BigInt()
349349
}

rpc/backend/node_info_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818
)
1919

2020
func (suite *BackendTestSuite) TestRPCMinGasPrice() {
21+
defaultPrice := new(big.Int).SetInt64(ethermint.DefaultGasPrice)
22+
bigPrice, _ := new(big.Int).SetString("18446744073709551616", 10)
2123
testCases := []struct {
2224
name string
2325
registerMock func()
24-
expMinGasPrice int64
26+
expMinGasPrice *big.Int
2527
expPass bool
2628
}{
2729
{
@@ -30,7 +32,7 @@ func (suite *BackendTestSuite) TestRPCMinGasPrice() {
3032
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
3133
RegisterParamsWithoutHeaderError(queryClient, 1)
3234
},
33-
ethermint.DefaultGasPrice,
35+
defaultPrice,
3436
true,
3537
},
3638
{
@@ -39,7 +41,18 @@ func (suite *BackendTestSuite) TestRPCMinGasPrice() {
3941
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
4042
RegisterParamsWithoutHeader(queryClient, 1)
4143
},
42-
ethermint.DefaultGasPrice,
44+
defaultPrice,
45+
true,
46+
},
47+
{
48+
"pass - min gas price exceeds math.MaxUint64",
49+
func() {
50+
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
51+
RegisterParamsWithoutHeader(queryClient, 1)
52+
amt, _ := sdkmath.NewIntFromString("18446744073709551616")
53+
suite.backend.cfg.SetMinGasPrices([]sdk.DecCoin{sdk.NewDecCoin(ethermint.AttoPhoton, amt)})
54+
},
55+
bigPrice,
4356
true,
4457
},
4558
}

0 commit comments

Comments
 (0)