Skip to content

[Feature]: Simplify MsgEthereumTx #220

@yihuang

Description

@yihuang

Summary

Predecessor: #222

After the great cleanup in #222, we should eventually remove the internal tx types, and embed ethtypes.Transaction in MsgEthereumTx directly.

Problem Definition

No response

Proposed Feature

MsgEthereumTx is a thin wrapper around the raw signed ethereum tx, let's implement it just as it‘s supposed to be:

message MsgEthereumTx {
  option (cosmos.msg.v1.signer) = "from";
  option (gogoproto.goproto_getters) = false;

  reserved 1, 2, 3, 4;

  // from is the bytes of ethereum signer address. This address value is checked
  // against the address derived from the signature (V, R, S) using the
  // secp256k1 elliptic curve
  bytes from = 5;
  // raw ethereum signed transaction
  bytes raw = 6 [(gogoproto.customtype) = "EthereumTx", (gogoproto.nullable) = false];
}
type EthereumTx struct {
	*ethtypes.Transaction
}

func NewEthereumTx(tx *ethtypes.Transaction) *EthereumTx {
	return &EthereumTx{*tx}
}

func (tx *EthereumTx) Size() int {
	return tx.Size()
}

func (tx *EthereumTx) MarshalTo(dst []byte) (int, error) {
	bz, err := tx.MarshalBinary()
	if err != nil {
		return 0, err
	}
	copy(dst, bz)
	return len(bz), nil
}

func (tx *EthereumTx) Unmarshal(dst []byte) error {
	return tx.UnmarshalBinary(dst)
}

from must be verified to be signer of the tx in ante handler.

it's a significant simplification and performance improvement, and future proof with newer ethereum tx types.

benchmark on ethermint shows end to end 5% faster execution just with this change.

Work Breakdown

#### Must have
- [ ] discuss proposal (if proposal rejected, close EPIC)
- [ ] create ADR (if ADR rejected, close EPIC)
- [ ] add sub-tasks needed to implement the proposed feature
#### Nice to have
- [ ] add sub-tasks that are nice to have for the proposed feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions