Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "stable"
go-version: 1.23
- name: Gather dependencies
run: go mod download
- name: Run coverage
Expand Down
9 changes: 7 additions & 2 deletions app/ante/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ import (
sanctionkeeper "github.com/MANTRA-Chain/mantrachain/v5/x/sanction/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
evmante "github.com/cosmos/evm/ante/evm"
chainante "github.com/cosmos/evm/evmd/ante"
)

func newEVMAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
decorators := []sdk.AnteDecorator{
sanctionkeeper.NewEVMBlacklistCheckDecorator(*options.SanctionKeeper),
evmante.NewEVMMonoDecorator(
options.EvmOptions.AccountKeeper,
options.EvmOptions.FeeMarketKeeper,
options.EvmOptions.EvmKeeper,
options.EvmOptions.MaxTxGasWanted,
),
)
}
if options.EvmOptions.PendingTxListener != nil {
decorators = append(decorators, chainante.NewTxListenerDecorator(options.EvmOptions.PendingTxListener))
}
return sdk.ChainAnteDecorators(decorators...)
}
5 changes: 5 additions & 0 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
chainante "github.com/cosmos/evm/evmd/ante"
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
)

Expand All @@ -28,6 +29,7 @@ type EVMHandlerOptions struct {
SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
MaxTxGasWanted uint64
TxFeeChecker ante.TxFeeChecker
PendingTxListener chainante.PendingTxListener
}

// Validate checks if the keepers are defined
Expand Down Expand Up @@ -62,6 +64,9 @@ func (options EVMHandlerOptions) Validate() error {
if options.TxFeeChecker == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "tx fee checker is required for EVM AnteHandler")
}
if options.PendingTxListener == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "pending tx listener is required for EVM AnteHandler")
}
return nil
}

Expand Down
15 changes: 15 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
evmosencoding "github.com/cosmos/evm/encoding"
ethcommon "github.com/ethereum/go-ethereum/common"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/client/v2/autocli"
chainante "github.com/cosmos/evm/evmd/ante"
srvflags "github.com/cosmos/evm/server/flags"
cosmosevmtypes "github.com/cosmos/evm/types"
cosmosevmutils "github.com/cosmos/evm/utils"
Expand Down Expand Up @@ -254,6 +256,8 @@ type App struct {
txConfig client.TxConfig
interfaceRegistry types.InterfaceRegistry

pendingTxListeners []chainante.PendingTxListener

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
Expand Down Expand Up @@ -1215,6 +1219,17 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.No
app.SetAnteHandler(ante.NewAnteHandler(handlerOpts))
}

// RegisterPendingTxListener is used by json-rpc server to listen to pending transactions callback.
func (app *App) RegisterPendingTxListener(listener func(ethcommon.Hash)) {
app.pendingTxListeners = append(app.pendingTxListeners, listener)
}

func (app *App) onPendingTx(hash ethcommon.Hash) {
for _, listener := range app.pendingTxListeners {
listener(hash)
}
}

// no post handler currently
// func (app *App) setPostHandler() {
// }
Expand Down
87 changes: 3 additions & 84 deletions app/evmosante.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package app

import (
"fmt"

errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
"github.com/MANTRA-Chain/mantrachain/v5/app/ante"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
evmante "github.com/cosmos/evm/ante"
cosmosevmante "github.com/cosmos/evm/ante/evm"
"github.com/cosmos/evm/crypto/ethsecp256k1"
cosmosevmtypes "github.com/cosmos/evm/types"
)

Expand All @@ -29,80 +19,9 @@ func NewEVMAnteHandlerOptionsFromApp(app *App, txConfig client.TxConfig, maxGasW
IBCKeeper: app.IBCKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: SigVerificationGasConsumer,
SigGasConsumer: evmante.SigVerificationGasConsumer,
MaxTxGasWanted: maxGasWanted,
TxFeeChecker: cosmosevmante.NewDynamicFeeChecker(app.FeeMarketKeeper),
PendingTxListener: app.onPendingTx,
}
}

// SigVerificationGasConsumer is the Cosmos EVM implementation of SignatureVerificationGasConsumer. It consumes gas
// for signature verification based upon the public key type. The cost is fetched from the given params and is matched
// by the concrete type.
// The types of keys supported are:
//
// - ethsecp256k1 (Ethereum keys)
//
// - secp256k1 (Cosmos keys)
//
// - ed25519 (Validators)
//
// - multisig (Cosmos SDK multisigs)
func SigVerificationGasConsumer(
meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params,
) error {
pubkey := sig.PubKey
switch pubkey := pubkey.(type) {
case *ethsecp256k1.PubKey:
// Ethereum keys
meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: eth_secp256k1")
return nil

case *secp256k1.PubKey:
// Ethereum keys
meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1")
return nil

case *ed25519.PubKey:
// Validator keys
meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519")
return errorsmod.Wrap(errortypes.ErrInvalidPubKey, "ED25519 public keys are unsupported")

case multisig.PubKey:
// Multisig keys
multisignature, ok := sig.Data.(*signing.MultiSignatureData)
if !ok {
return fmt.Errorf("expected %T, got, %T", &signing.MultiSignatureData{}, sig.Data)
}
return ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params, sig.Sequence)

default:
return errorsmod.Wrapf(errortypes.ErrInvalidPubKey, "unrecognized/unsupported public key type: %T", pubkey)
}
}

// ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature
func ConsumeMultisignatureVerificationGas(
meter storetypes.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey,
params authtypes.Params, accSeq uint64,
) error {
size := sig.BitArray.Count()
sigIndex := 0

for i := 0; i < size; i++ {
if !sig.BitArray.GetIndex(i) {
continue
}
sigV2 := signing.SignatureV2{
PubKey: pubkey.GetPubKeys()[i],
Data: sig.Signatures[sigIndex],
Sequence: accSeq,
}
err := SigVerificationGasConsumer(meter, sigV2, params)
if err != nil {
return err
}
sigIndex++
}

return nil
}
3 changes: 2 additions & 1 deletion cmd/mantrachaind/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/crisis"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
ethermintclient "github.com/cosmos/evm/client"
evmdebug "github.com/cosmos/evm/client/debug"
cosmosevmserver "github.com/cosmos/evm/server"
cosmosevmserverflags "github.com/cosmos/evm/server/flags"
Expand Down Expand Up @@ -85,7 +86,7 @@ func initRootCmd(
genesisCommand(txConfig, basicManager),
queryCommand(),
txCommand(),
KeyCommands(app.DefaultNodeHome, false),
ethermintclient.KeyCommands(app.DefaultNodeHome, false),
)

_, err := cosmosevmserverflags.AddTxFlags(rootCmd)
Expand Down
102 changes: 0 additions & 102 deletions cmd/mantrachaind/cmd/keys.go

This file was deleted.

32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ replace (
// Direct tag link: https://github.com/MANTRA-Chain/cosmos-sdk/tree/v0.53.3-v5-mantra-1
github.com/cosmos/cosmos-sdk => github.com/MANTRA-Chain/cosmos-sdk v0.53.3-v5-mantra-1

// Direct tag link: https://github.com/MANTRA-Chain/evm/tree/mantra/v0.4.x
github.com/cosmos/evm => github.com/MANTRA-Chain/evm v0.0.0-20250808024246-0088642e4659
github.com/cosmos/evm/evmd => github.com/MANTRA-Chain/evm/evmd v0.0.0-20250808024246-0088642e4659
// Direct tag link: https://github.com/MANTRA-Chain/evm/tree/mantra/v0.4.x_main
github.com/cosmos/evm => github.com/MANTRA-Chain/evm v0.0.0-20250813042541-c9bb610c6904
github.com/cosmos/evm/evmd => github.com/MANTRA-Chain/evm/evmd v0.0.0-20250813042541-c9bb610c6904

// branch: release/1.16
github.com/ethereum/go-ethereum => github.com/cosmos/go-ethereum v0.0.0-20250806193535-2fc7571efa91
Expand Down Expand Up @@ -59,10 +59,10 @@ require (
github.com/CosmWasm/wasmd v0.61.1
github.com/CosmWasm/wasmvm/v3 v3.0.0
github.com/bufbuild/buf v1.46.0
github.com/cometbft/cometbft v0.38.17
github.com/cometbft/cometbft v0.38.18
github.com/cosmos/cosmos-db v1.1.3
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.53.3
github.com/cosmos/cosmos-sdk v0.53.4
github.com/cosmos/evm v1.0.0-rc2.0.20250728233944-0f22f9f84110
github.com/cosmos/evm/evmd v0.0.0-20250725153303-2934281442b2
github.com/cosmos/go-bip39 v1.0.0
Expand All @@ -82,15 +82,15 @@ require (
github.com/skip-mev/feemarket v1.1.1
github.com/spf13/cast v1.9.2
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
github.com/spf13/pflag v1.0.7
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.10.0
golang.org/x/text v0.27.0
golang.org/x/tools v0.34.0
golang.org/x/text v0.28.0
golang.org/x/tools v0.35.0
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a
google.golang.org/grpc v1.74.0
google.golang.org/grpc v1.74.2
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1
google.golang.org/protobuf v1.36.6
google.golang.org/protobuf v1.36.7
)

require (
Expand Down Expand Up @@ -380,14 +380,14 @@ require (
go.uber.org/zap/exp v0.3.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/arch v0.15.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/mod v0.26.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/term v0.33.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/term v0.34.0 // indirect
golang.org/x/time v0.10.0 // indirect
google.golang.org/api v0.222.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
Expand All @@ -399,5 +399,5 @@ require (
pgregory.net/rapid v1.2.0 // indirect
pluginrpc.com/pluginrpc v0.5.0 // indirect
rsc.io/qr v0.2.0 // indirect
sigs.k8s.io/yaml v1.5.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading