diff --git a/app/rpc/namespaces/eth/api.go b/app/rpc/namespaces/eth/api.go index e7bbcc7a08..f1858efee6 100644 --- a/app/rpc/namespaces/eth/api.go +++ b/app/rpc/namespaces/eth/api.go @@ -527,7 +527,7 @@ func (api *PublicEthereumAPI) SendRawTransaction(data hexutil.Bytes) (common.Has // Call performs a raw contract call. func (api *PublicEthereumAPI) Call(args rpctypes.CallArgs, blockNr rpctypes.BlockNumber, _ *map[common.Address]rpctypes.Account) (hexutil.Bytes, error) { api.logger.Debug("eth_call", "args", args, "block number", blockNr) - simRes, err := api.doCall(args, blockNr, big.NewInt(ethermint.DefaultRPCGasLimit)) + simRes, err := api.doCall(args, blockNr, big.NewInt(ethermint.DefaultRPCGasLimit), false) if err != nil { return []byte{}, TransformDataError(err, "eth_call") } @@ -543,7 +543,7 @@ func (api *PublicEthereumAPI) Call(args rpctypes.CallArgs, blockNr rpctypes.Bloc // DoCall performs a simulated call operation through the evmtypes. It returns the // estimated gas used on the operation or an error if fails. func (api *PublicEthereumAPI) doCall( - args rpctypes.CallArgs, blockNum rpctypes.BlockNumber, globalGasCap *big.Int, + args rpctypes.CallArgs, blockNum rpctypes.BlockNumber, globalGasCap *big.Int, isEstimate bool, ) (*sdk.SimulationResponse, error) { clientCtx := api.clientCtx @@ -564,7 +564,11 @@ func (api *PublicEthereumAPI) doCall( addr = *args.From } - nonce, _ := api.accountNonce(api.clientCtx, addr, true) + nonce := uint64(0) + if isEstimate && args.To == nil && args.Data != nil { + //only get real nonce when estimate gas and the action is contract deploy + nonce, _ = api.accountNonce(api.clientCtx, addr, true) + } // Set default gas & gas price if none were set // Change this to uint64(math.MaxUint64 / 2) if gas cap can be configured @@ -650,7 +654,7 @@ func (api *PublicEthereumAPI) doCall( // param from the SDK. func (api *PublicEthereumAPI) EstimateGas(args rpctypes.CallArgs) (hexutil.Uint64, error) { api.logger.Debug("eth_estimateGas", "args", args) - simResponse, err := api.doCall(args, 0, big.NewInt(ethermint.DefaultRPCGasLimit)) + simResponse, err := api.doCall(args, 0, big.NewInt(ethermint.DefaultRPCGasLimit), true) if err != nil { return 0, TransformDataError(err, "eth_estimateGas") } diff --git a/app/types/params.go b/app/types/params.go index 1ad57c8a20..601af90e05 100644 --- a/app/types/params.go +++ b/app/types/params.go @@ -4,5 +4,5 @@ const ( // DefaultGasPrice is default gas price for evm transactions DefaultGasPrice = 20 // DefaultRPCGasLimit is default gas limit for RPC call operations - DefaultRPCGasLimit = 100000000000 + DefaultRPCGasLimit = 30000000 )