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:
parent
5ff2a2c45f
commit
08a8191002
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user