Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
rpc: decode raw transaction via RLP (#727)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
NevermoreRandom and fedekunze committed Nov 8, 2021
1 parent 882dd4e commit fd36873
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 6 additions & 7 deletions rpc/ethereum/namespaces/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := &ethtypes.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 {
Expand Down

0 comments on commit fd36873

Please sign in to comment.