Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3e44d3c
feat: refactor MsgEthereumTx with eth transaction
yihuang Jun 17, 2025
a31f152
fix lint
yihuang Jul 21, 2025
fcb879e
feat: update go-ethereum to 1.16
yihuang Jul 21, 2025
1eb0f14
fix: estimate gas missing fields for new tx type
yihuang Jul 21, 2025
0769093
Merge branch 'fix-estimate-gas' into evm-msg-optim
yihuang Jul 21, 2025
4b0dcd3
support eip-7702
yihuang Jul 21, 2025
2cc9384
support eip-7702
yihuang Jul 21, 2025
53884b7
update RPCTransaction
yihuang Jul 21, 2025
86e8c2f
fix test
yihuang Jul 21, 2025
78b4609
Merge branch 'geth-1-16' into evm-msg-optim
yihuang Jul 21, 2025
684dc1a
use go-ethereum 1.16
yihuang Jul 21, 2025
89f608b
fix lint
yihuang Jul 21, 2025
3bfd875
revert dependency change
yihuang Jul 23, 2025
2cde48e
add AuthorizationList EvmTxArgs
yihuang Jul 23, 2025
a3c363f
Merge branch 'main' into evm-msg-optim
yihuang Jul 23, 2025
a690408
revert dep change
yihuang Jul 23, 2025
8deb2dc
go mod tidy
yihuang Jul 23, 2025
027988f
support SetCodeTx in tests
yihuang Jul 23, 2025
3998a41
add debug log for auth failure
yihuang Jul 23, 2025
9164b47
support 7702 in rpc
yihuang Jul 23, 2025
bfc1f19
fix rpc for modern tx type
yihuang Jul 23, 2025
ffec51a
reuse receipt utility in backend
yihuang Jul 24, 2025
bcf3004
fix test
yihuang Jul 24, 2025
b22c725
fix test
yihuang Jul 24, 2025
f5cfdab
fix test
yihuang Jul 24, 2025
dad4d3a
Merge remote-tracking branch 'upstream/main' into evm-msg-optim
yihuang Jul 29, 2025
cfb32aa
fix tests
yihuang Jul 29, 2025
ca9ecfd
fix lint
yihuang Jul 29, 2025
50fbb88
Merge branch 'main' into evm-msg-optim
yihuang Aug 6, 2025
755bbb9
align tx_args with geth
yihuang Aug 6, 2025
8540c9d
fix tests
yihuang Aug 6, 2025
573afee
Merge branch 'main' into evm-msg-optim
yihuang Aug 8, 2025
7b697ae
Merge remote-tracking branch 'upstream/main' into evm-msg-optim
yihuang Aug 11, 2025
03496f6
fix lint
yihuang Aug 11, 2025
5cd67ef
Merge branch 'main' into evm-msg-optim
Aug 11, 2025
67b4ecc
Merge branch 'main' into evm-msg-optim
Aug 11, 2025
40d3080
Merge branch 'main' into evm-msg-optim
yihuang Aug 12, 2025
c0a8c98
fix lint
yihuang Aug 12, 2025
329dc42
rename symbol
yihuang Aug 12, 2025
efaf66b
wrap errors
yihuang Aug 12, 2025
2dde23a
fix review suggestions
yihuang Aug 12, 2025
549abc4
fix review suggestions
yihuang Aug 12, 2025
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
15 changes: 7 additions & 8 deletions ante/evm/04_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"errors"
"math/big"

ethtypes "github.com/ethereum/go-ethereum/core/types"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
evmtypes "github.com/cosmos/evm/x/vm/types"

Expand All @@ -17,17 +19,14 @@ import (

// ValidateMsg validates an Ethereum specific message type and returns an error
// if invalid. It checks the following requirements:
// - nil MUST be passed as the from address
// - If the transaction is a contract creation or call, the corresponding operation must be enabled in the EVM parameters
func ValidateMsg(
evmParams evmtypes.Params,
txData evmtypes.TxData,
from sdktypes.AccAddress,
txData *ethtypes.Transaction,
) error {
if from != nil {
return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "invalid from address; expected nil; got: %q", from.String())
if txData == nil {
return errorsmod.Wrap(errortypes.ErrInvalidRequest, "transaction is nil")
}

return checkDisabledCreateCall(
txData,
&evmParams.AccessControl,
Expand All @@ -37,10 +36,10 @@ func ValidateMsg(
// checkDisabledCreateCall checks if the transaction is a contract creation or call,
// and if those actions are disabled through governance.
func checkDisabledCreateCall(
txData evmtypes.TxData,
txData *ethtypes.Transaction,
permissions *evmtypes.AccessControl,
) error {
to := txData.GetTo()
to := txData.To()
blockCreate := permissions.Create.AccessType == evmtypes.AccessTypeRestricted
blockCall := permissions.Call.AccessType == evmtypes.AccessTypeRestricted

Expand Down
10 changes: 8 additions & 2 deletions ante/evm/05_signature_verification.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package evm

import (
"bytes"
"math/big"

ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -92,7 +93,12 @@ func SignatureVerification(
)
}

// set up the sender to the transaction field if not already
msg.From = sender.Hex()
if !bytes.Equal(msg.From, sender.Bytes()) {
return errorsmod.Wrapf(
errortypes.ErrorInvalidSigner,
"rejected ethereum transaction with invalid sender address; expected %s, got %s",
evmtypes.HexAddress(msg.From), sender.String(),
)
}
return nil
}
19 changes: 12 additions & 7 deletions ante/evm/06_account_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package evm

import (
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/x/vm/keeper"
"github.com/cosmos/evm/x/vm/statedb"
evmtypes "github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"
Expand All @@ -22,19 +22,24 @@ import (
// - account balance is lower than the transaction cost
func VerifyAccountBalance(
ctx sdk.Context,
evmKeeper anteinterfaces.EVMKeeper,
accountKeeper anteinterfaces.AccountKeeper,
account *statedb.Account,
from common.Address,
txData evmtypes.TxData,
txData *ethtypes.Transaction,
) error {
// Only EOA are allowed to send transactions.
if account != nil && account.IsContract() {
return errorsmod.Wrapf(
errortypes.ErrInvalidType,
"the sender is not EOA: address %s", from,
)
// check eip-7702
code := evmKeeper.GetCode(ctx, common.BytesToHash(account.CodeHash))
_, delegated := ethtypes.ParseDelegation(code)
if len(code) > 0 && !delegated {
return errorsmod.Wrapf(
errortypes.ErrInvalidType,
"the sender is not EOA: address %s", from,
)
}
}

if account == nil {
acc := accountKeeper.NewAccountWithAddress(ctx, from.Bytes())
accountKeeper.SetAccount(ctx, acc)
Expand Down
3 changes: 2 additions & 1 deletion ante/evm/08_gas_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/types"
Expand Down Expand Up @@ -84,7 +85,7 @@ func deductFees(

// GetMsgPriority returns the priority of an Eth Tx capped by the minimum priority
func GetMsgPriority(
txData evmtypes.TxData,
txData *ethtypes.Transaction,
minPriority int64,
baseFee *big.Int,
) int64 {
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/11_emit_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func EmitTxHashEvent(ctx sdk.Context, msg *evmtypes.MsgEthereumTx, blockTxIndex,
ctx.EventManager().EmitEvent(
sdk.NewEvent(
evmtypes.EventTypeEthereumTx,
sdk.NewAttribute(evmtypes.AttributeKeyEthereumTxHash, msg.Hash),
sdk.NewAttribute(evmtypes.AttributeKeyEthereumTxHash, msg.Hash().String()),
sdk.NewAttribute(evmtypes.AttributeKeyTxIndex, strconv.FormatUint(blockTxIndex+msgIndex, 10)), // #nosec G115
),
)
Expand Down
14 changes: 7 additions & 7 deletions ante/evm/mono_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
return ctx, err
}

feeAmt := txData.Fee()
gas := txData.GetGas()
feeAmt := ethMsg.GetFee()
gas := txData.Gas()
fee := sdkmath.LegacyNewDecFromBigInt(feeAmt)
gasLimit := sdkmath.LegacyNewDecFromBigInt(new(big.Int).SetUint64(gas))

Expand All @@ -104,13 +104,13 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
}
}

if txData.TxType() == ethtypes.DynamicFeeTxType && decUtils.BaseFee != nil {
if txData.Type() >= ethtypes.DynamicFeeTxType && decUtils.BaseFee != nil {
// If the base fee is not empty, we compute the effective gas price
// according to current base fee price. The gas limit is specified
// by the user, while the price is given by the minimum between the
// max price paid for the entire tx, and the sum between the price
// for the tip and the base fee.
feeAmt = txData.EffectiveFee(decUtils.BaseFee)
feeAmt = ethMsg.GetEffectiveFee(decUtils.BaseFee)
fee = sdkmath.LegacyNewDecFromBigInt(feeAmt)
}

Expand All @@ -123,7 +123,6 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
if err := ValidateMsg(
decUtils.EvmParams,
txData,
ethMsg.GetFrom(),
); err != nil {
return ctx, err
}
Expand All @@ -147,6 +146,7 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
account := md.evmKeeper.GetAccount(ctx, fromAddr)
if err := VerifyAccountBalance(
ctx,
md.evmKeeper,
md.accountKeeper,
account,
fromAddr,
Expand Down Expand Up @@ -216,7 +216,7 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne

// Update the fee to be paid for the tx adding the fee specified for the
// current message.
decUtils.TxFee.Add(decUtils.TxFee, txData.Fee())
decUtils.TxFee.Add(decUtils.TxFee, ethMsg.GetFee())

// Update the transaction gas limit adding the gas specified in the
// current message.
Expand All @@ -233,7 +233,7 @@ func (md MonoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne
)
}

if err := IncrementNonce(ctx, md.accountKeeper, acc, txData.GetNonce()); err != nil {
if err := IncrementNonce(ctx, md.accountKeeper, acc, txData.Nonce()); err != nil {
return ctx, err
}

Expand Down
3 changes: 1 addition & 2 deletions ante/evm/mono_decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ func signMsgEthereumTx(t *testing.T, privKey *ethsecp256k1.PrivKey, args *evmsdk
t.Helper()
msg := evmsdktypes.NewTx(args)
fromAddr := common.BytesToAddress(privKey.PubKey().Address().Bytes())
msg.From = fromAddr.Hex()
msg.From = fromAddr.Bytes()
ethSigner := ethtypes.LatestSignerForChainID(evmsdktypes.GetEthChainConfig().ChainID)
require.NoError(t, msg.Sign(ethSigner, utiltx.NewSigner(privKey)))
msg.From = ""
return msg
}

Expand Down
63 changes: 0 additions & 63 deletions api/cosmos/evm/vm/v1/access_list_tx.go

This file was deleted.

64 changes: 0 additions & 64 deletions api/cosmos/evm/vm/v1/dynamic_fee_tx.go

This file was deleted.

43 changes: 0 additions & 43 deletions api/cosmos/evm/vm/v1/legacy_tx.go

This file was deleted.

Loading