eth_sendTransaction returns internal trace on missing param (#1284)
* added test, used get method for from param * gosec fixes * adding nosec v1 * added test to python tests, removed testing lines * fixing flake issues * test-unit-cover * changelog fix * changelog 2 * fix gomod2nix * integration tests Co-authored-by: Freddy Caceres <facs95@gmail.com>
This commit is contained in:
parent
f9c74e239c
commit
1ea0cb31b7
@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* (rpc) [#1179](https://github.com/evmos/ethermint/pull/1179) Fix gas used in traceTransaction response.
|
* (rpc) [#1179](https://github.com/evmos/ethermint/pull/1179) Fix gas used in traceTransaction response.
|
||||||
|
* (rpc) [#1284](https://github.com/evmos/ethermint/pull/1284) Fix internal trace response upon incomplete `eth_sendTransaction` call.
|
||||||
|
|
||||||
## [v0.18.0] - 2022-08-04
|
## [v0.18.0] - 2022-08-04
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
// SendTransaction sends transaction based on received args using Node's key to sign it
|
// SendTransaction sends transaction based on received args using Node's key to sign it
|
||||||
func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) {
|
func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) {
|
||||||
// Look up the wallet containing the requested signer
|
// Look up the wallet containing the requested signer
|
||||||
_, err := b.clientCtx.Keyring.KeyByAddress(sdk.AccAddress(args.From.Bytes()))
|
_, err := b.clientCtx.Keyring.KeyByAddress(sdk.AccAddress(args.GetFrom().Bytes()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.logger.Error("failed to find key in keyring", "address", args.From, "error", err.Error())
|
b.logger.Error("failed to find key in keyring", "address", args.GetFrom(), "error", err.Error())
|
||||||
return common.Hash{}, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error())
|
return common.Hash{}, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ func (s *websocketsServer) Start() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
|
/* #nosec G114 -- http functions have no support for timeouts */
|
||||||
if s.certFile == "" || s.keyFile == "" {
|
if s.certFile == "" || s.keyFile == "" {
|
||||||
err = http.ListenAndServe(s.wsAddr, ws)
|
err = http.ListenAndServe(s.wsAddr, ws)
|
||||||
} else {
|
} else {
|
||||||
|
@ -323,6 +323,15 @@ def make_same_rpc_calls(rpc1, rpc2, method, params):
|
|||||||
assert res, err
|
assert res, err
|
||||||
|
|
||||||
|
|
||||||
|
def test_incomplete_send_transaction(ethermint, geth):
|
||||||
|
# Send ethereum tx with nothing in from field
|
||||||
|
eth_rpc = ethermint.w3.provider
|
||||||
|
geth_rpc = geth.w3.provider
|
||||||
|
gas_price = ethermint.w3.eth.gas_price
|
||||||
|
tx = {"from": "", "to": ADDRS["community"], "value": 0, "gasPrice": gas_price}
|
||||||
|
make_same_rpc_calls(eth_rpc, geth_rpc, "eth_sendTransaction", [tx])
|
||||||
|
|
||||||
|
|
||||||
def same_types(object_a, object_b):
|
def same_types(object_a, object_b):
|
||||||
|
|
||||||
if isinstance(object_a, dict):
|
if isinstance(object_a, dict):
|
||||||
|
@ -329,6 +329,24 @@ func waitForReceipt(t *testing.T, hash hexutil.Bytes) map[string]interface{} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEth_IncompleteSendTransaction(t *testing.T) {
|
||||||
|
// get gasprice
|
||||||
|
gasPrice := GetGasPrice(t)
|
||||||
|
|
||||||
|
// make tx params without from address
|
||||||
|
param := make([]map[string]string, 1)
|
||||||
|
param[0] = make(map[string]string)
|
||||||
|
param[0]["from"] = ""
|
||||||
|
param[0]["to"] = "0x1122334455667788990011223344556677889900"
|
||||||
|
param[0]["value"] = "0x1"
|
||||||
|
param[0]["gasPrice"] = gasPrice
|
||||||
|
_, err := callWithError("eth_sendTransaction", param)
|
||||||
|
|
||||||
|
// require well-formatted error (should not be "method handler crashed")
|
||||||
|
require.Error(t, err)
|
||||||
|
require.NotEqual(t, err.Error(), "method handler crashed", "no from field dealt with incorrectly")
|
||||||
|
}
|
||||||
|
|
||||||
func TestEth_GetFilterChanges_NoTopics(t *testing.T) {
|
func TestEth_GetFilterChanges_NoTopics(t *testing.T) {
|
||||||
rpcRes := call(t, "eth_blockNumber", []string{})
|
rpcRes := call(t, "eth_blockNumber", []string{})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user