From aba59c1bfcde51c9d582de0d2d1fdab8681c8e1b Mon Sep 17 00:00:00 2001 From: NevermoreRandom Date: Mon, 8 Nov 2021 11:59:22 +0800 Subject: [PATCH 1/3] Decode raw transaction via RLP --- rpc/ethereum/namespaces/eth/api.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rpc/ethereum/namespaces/eth/api.go b/rpc/ethereum/namespaces/eth/api.go index c19f9dc004..7f9a7d72b8 100644 --- a/rpc/ethereum/namespaces/eth/api.go +++ b/rpc/ethereum/namespaces/eth/api.go @@ -432,17 +432,18 @@ func (e *PublicAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) e.logger.Debug("eth_sendRawTransaction", "length", len(data)) // RLP decode raw transaction bytes - tx, err := e.clientCtx.TxConfig.TxDecoder()(data) + tx := ðtypes.Transaction{} + err := tx.UnmarshalBinary(data) if err != nil { e.logger.Error("transaction decoding failed", "error", err.Error()) - return common.Hash{}, err } - ethereumTx, isEthTx := tx.(*evmtypes.MsgEthereumTx) - if !isEthTx { - e.logger.Debug("invalid transaction type", "type", fmt.Sprintf("%T", tx)) - return common.Hash{}, fmt.Errorf("invalid transaction type %T", tx) + ethereumTx := &evmtypes.MsgEthereumTx{} + err = ethereumTx.FromEthereumTx(tx) + if err != nil { + e.logger.Error("transaction converting failed", "error", err.Error()) + return common.Hash{}, err } if err := ethereumTx.ValidateBasic(); err != nil { From 4f3aef4e4b06eb9b992867c9fe85e632680417e2 Mon Sep 17 00:00:00 2001 From: NevermoreRandom Date: Mon, 8 Nov 2021 13:55:02 +0800 Subject: [PATCH 2/3] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1a0a2e45..5ab88f90e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (rpc) [tharsis#727](https://github.com/tharsis/ethermint/pull/727) Decode raw transaction using RLP. * (rpc) [tharsis#661](https://github.com/tharsis/ethermint/pull/661) Fix OOM bug when creating too many filters using JSON-RPC. * (evm) [tharsis#660](https://github.com/tharsis/ethermint/pull/660) Fix `nil` pointer panic in `ApplyNativeMessage`. * (evm, test) [tharsis#649](https://github.com/tharsis/ethermint/pull/649) Test DynamicFeeTx. From 60f2a68750e2a6d3b7314d099b88cc90a3f56520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Kunze=20K=C3=BCllmer?= <31522760+fedekunze@users.noreply.github.com> Date: Mon, 8 Nov 2021 09:18:41 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- rpc/ethereum/namespaces/eth/api.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rpc/ethereum/namespaces/eth/api.go b/rpc/ethereum/namespaces/eth/api.go index 7f9a7d72b8..3d57a6129c 100644 --- a/rpc/ethereum/namespaces/eth/api.go +++ b/rpc/ethereum/namespaces/eth/api.go @@ -433,15 +433,13 @@ func (e *PublicAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) // RLP decode raw transaction bytes tx := ðtypes.Transaction{} - err := tx.UnmarshalBinary(data) - if err != nil { + if err := tx.UnmarshalBinary(data); err != nil { e.logger.Error("transaction decoding failed", "error", err.Error()) return common.Hash{}, err } ethereumTx := &evmtypes.MsgEthereumTx{} - err = ethereumTx.FromEthereumTx(tx) - if err != nil { + if err := ethereumTx.FromEthereumTx(tx); err != nil { e.logger.Error("transaction converting failed", "error", err.Error()) return common.Hash{}, err }