From 60a80b7587e461b99afce895afa63b43721b2664 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Thu, 14 Nov 2024 15:45:48 +0800 Subject: [PATCH 1/2] Problem: nil pointer error with legacy tx format --- CHANGELOG.md | 1 + x/evm/types/eth.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a65a26d30..91b04b2301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#558](https://github.com/crypto-org-chain/ethermint/pull/558) New tracer in predecessors to trace balance correctly when `debug_traceTransaction`. * (rpc) [#559](https://github.com/crypto-org-chain/ethermint/pull/559) Use basefee of transaction height instead of minus one height when `debug_traceTransaction`. * (ante) [#560](https://github.com/crypto-org-chain/ethermint/pull/560) Check gasWanted only in checkTx mode. +* (rpc) [#]() Fix nil pointer panic with legacy transaction format. ### Improvements diff --git a/x/evm/types/eth.go b/x/evm/types/eth.go index 4ac6e9fbaa..e6d39b120a 100644 --- a/x/evm/types/eth.go +++ b/x/evm/types/eth.go @@ -4,6 +4,7 @@ import ( "encoding/json" errorsmod "cosmossdk.io/errors" + errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/evmos/ethermint/types" @@ -60,6 +61,9 @@ func (tx *EthereumTx) UnmarshalJSON(bz []byte) error { } func (tx EthereumTx) MarshalJSON() ([]byte, error) { + if tx.Transaction == nil { + return []byte("null"), nil + } bz, err := tx.MarshalBinary() if err != nil { return nil, err @@ -68,6 +72,10 @@ func (tx EthereumTx) MarshalJSON() ([]byte, error) { } func (tx EthereumTx) Validate() error { + if tx.Transaction == nil { + return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "raw tx is missing") + } + // prevent txs with 0 gas to fill up the mempool if tx.Gas() == 0 { return errorsmod.Wrap(ErrInvalidGasLimit, "gas limit must not be zero") From 6e29acdd1fd5d152074f5b0147f396f349e4f129 Mon Sep 17 00:00:00 2001 From: yihuang Date: Thu, 14 Nov 2024 15:47:35 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md Signed-off-by: yihuang --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91b04b2301..ecc8368d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,7 +78,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#558](https://github.com/crypto-org-chain/ethermint/pull/558) New tracer in predecessors to trace balance correctly when `debug_traceTransaction`. * (rpc) [#559](https://github.com/crypto-org-chain/ethermint/pull/559) Use basefee of transaction height instead of minus one height when `debug_traceTransaction`. * (ante) [#560](https://github.com/crypto-org-chain/ethermint/pull/560) Check gasWanted only in checkTx mode. -* (rpc) [#]() Fix nil pointer panic with legacy transaction format. +* (rpc) [#562](https://github.com/crypto-org-chain/ethermint/pull/562) Fix nil pointer panic with legacy transaction format. ### Improvements