rpc: add NoBaseFee check in backend.BaseFee (#697)

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
JayT106 2021-10-23 13:47:32 -04:00 committed by GitHub
parent 5ff2a2c45f
commit 08a8191002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 9 deletions

View File

@ -807,6 +807,16 @@ func (e *EVMBackend) BaseFee(height int64) (*big.Int, error) {
return nil, nil
}
// Checks the feemarket param NoBaseFee settings, return 0 if it is enabled.
resParams, err := e.queryClient.FeeMarket.Params(e.ctx, &feemarkettypes.QueryParamsRequest{})
if err != nil {
return nil, err
}
if resParams.Params.NoBaseFee {
return big.NewInt(0), nil
}
blockRes, err := e.clientCtx.Client.BlockResults(e.ctx, &height)
if err != nil {
return nil, err

View File

@ -412,20 +412,22 @@ func TestEth_SendTransaction_Transfer(t *testing.T) {
}
func TestEth_SendTransaction_ContractDeploy(t *testing.T) {
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["data"] = "0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029"
param[0]["gas"] = "0x200000"
param[0]["gasPrice"] = "0x1"
rpcRes := call(t, "eth_sendTransaction", param)
param := makeTestContractDeployParam(true)
rpcRes, err := callWithError("eth_sendTransaction", param)
require.NoError(t, err)
var hash hexutil.Bytes
err := json.Unmarshal(rpcRes.Result, &hash)
err = json.Unmarshal(rpcRes.Result, &hash)
require.NoError(t, err)
}
func TestEth_SendTransaction_ContractDeploy_no_gas_param(t *testing.T) {
param := makeTestContractDeployParam(false)
_, err := callWithError("eth_sendTransaction", param)
// server returns internal error.
require.Error(t, err)
}
func TestEth_NewFilter(t *testing.T) {
param := make([]map[string][]string, 1)
param[0] = make(map[string][]string)
@ -1026,6 +1028,19 @@ func makeEthTxParam() []map[string]string {
return param
}
func makeTestContractDeployParam(withGas bool) []map[string]string {
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["data"] = "0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029"
if withGas {
param[0]["gas"] = "0x200000"
param[0]["gasPrice"] = "0x1"
}
return param
}
func TestEth_EthResend(t *testing.T) {
tx := make(map[string]string)
tx["from"] = "0x" + fmt.Sprintf("%x", from)