From fd368732610dc518b5a02836bf6ca4eee0aa61a3 Mon Sep 17 00:00:00 2001 From: NevermoreRandom <92708920+NevermoreRandom@users.noreply.github.com> Date: Mon, 8 Nov 2021 16:22:31 +0800 Subject: [PATCH] rpc: decode raw transaction via RLP (#727) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Decode raw transaction via RLP * add changelog * Apply suggestions from code review Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- CHANGELOG.md | 1 + rpc/ethereum/namespaces/eth/api.go | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1a0a2e..5ab88f90 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. diff --git a/rpc/ethereum/namespaces/eth/api.go b/rpc/ethereum/namespaces/eth/api.go index c19f9dc0..3d57a612 100644 --- a/rpc/ethereum/namespaces/eth/api.go +++ b/rpc/ethereum/namespaces/eth/api.go @@ -432,17 +432,16 @@ 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) - if err != nil { + tx := ðtypes.Transaction{} + if err := tx.UnmarshalBinary(data); 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{} + if err := ethereumTx.FromEthereumTx(tx); err != nil { + e.logger.Error("transaction converting failed", "error", err.Error()) + return common.Hash{}, err } if err := ethereumTx.ValidateBasic(); err != nil {