Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: nil pointer error with legacy tx format #562

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
yihuang marked this conversation as resolved.
Show resolved Hide resolved

### Improvements

Expand Down
8 changes: 8 additions & 0 deletions x/evm/types/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down
Loading