Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@

### API-BREAKING

- [\#443](https://github.com/cosmos/evm/pull/443) Move `ante` logic from the `evmd` Go package to the `evm` package to
be exported as a library.
- [\#422](https://github.com/cosmos/evm/pull/422) Align function and package names for consistency.
- [\#305](https://github.com/cosmos/evm/pull/305) Remove evidence precompile due to lack of use cases
5 changes: 5 additions & 0 deletions evmd/ante/handler_options.go → ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ func (options HandlerOptions) Validate() error {
if options.TxFeeChecker == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "tx fee checker is required for AnteHandler")
}

if options.PendingTxListener == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "pending tx listener is required for AnteHandler")
}

return nil
}
6 changes: 4 additions & 2 deletions evmd/ante/tx_listener.go → ante/tx_listener.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ante

import (
sdk "github.com/cosmos/cosmos-sdk/types"
evmtypes "github.com/cosmos/evm/x/vm/types"
"github.com/ethereum/go-ethereum/common"

evmtypes "github.com/cosmos/evm/x/vm/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

type PendingTxListener func(common.Hash)
Expand Down
3 changes: 2 additions & 1 deletion evmd/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ante

import (
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/evm/ante"

sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
Expand All @@ -12,7 +13,7 @@ import (
// Ethereum or SDK transaction to an internal ante handler for performing
// transaction-level processing (e.g. fee payment, signature verification) before
// being passed onto it's respective handler.
func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
func NewAnteHandler(options ante.HandlerOptions) sdk.AnteHandler {
return func(
ctx sdk.Context, tx sdk.Tx, sim bool,
) (newCtx sdk.Context, err error) {
Expand Down
3 changes: 2 additions & 1 deletion evmd/ante/cosmos_handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
baseevmante "github.com/cosmos/evm/ante"
cosmosante "github.com/cosmos/evm/ante/cosmos"
evmante "github.com/cosmos/evm/ante/evm"
evmtypes "github.com/cosmos/evm/x/vm/types"
Expand All @@ -12,7 +13,7 @@ import (
)

// newCosmosAnteHandler creates the default ante handler for Cosmos transactions
func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
func newCosmosAnteHandler(options baseevmante.HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
cosmosante.NewRejectMessagesDecorator(), // reject MsgEthereumTxs
cosmosante.NewAuthzLimiterDecorator( // disable the Msg types that cannot be included on an authz.MsgExec msgs field
Expand Down
4 changes: 2 additions & 2 deletions evmd/ante/evm_antehandler_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ func (s *benchmarkSuite) generateTxType(txType string) (sdktypes.Tx, error) {
}
}

func (s *benchmarkSuite) generateHandlerOptions() evmdante.HandlerOptions {
func (s *benchmarkSuite) generateHandlerOptions() ante.HandlerOptions {
encCfg := s.network.GetEncodingConfig()
return evmdante.HandlerOptions{
return ante.HandlerOptions{
Cdc: s.network.App.AppCodec(),
AccountKeeper: s.network.App.GetAccountKeeper(),
BankKeeper: s.network.App.GetBankKeeper(),
Expand Down
8 changes: 4 additions & 4 deletions evmd/ante/evm_handler.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package ante

import (
"github.com/cosmos/evm/ante"
evmante "github.com/cosmos/evm/ante/evm"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// newMonoEVMAnteHandler creates the sdk.AnteHandler implementation for the EVM transactions.
func newMonoEVMAnteHandler(options HandlerOptions) sdk.AnteHandler {
func newMonoEVMAnteHandler(options ante.HandlerOptions) sdk.AnteHandler {
decorators := []sdk.AnteDecorator{
evmante.NewEVMMonoDecorator(
options.AccountKeeper,
options.FeeMarketKeeper,
options.EvmKeeper,
options.MaxTxGasWanted,
),
ante.NewTxListenerDecorator(options.PendingTxListener),
}
if options.PendingTxListener != nil {
decorators = append(decorators, NewTxListenerDecorator(options.PendingTxListener))
}
Comment on lines -19 to -21
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are requiring this and enforcing via build time constraints


return sdk.ChainAnteDecorators(decorators...)
}
6 changes: 3 additions & 3 deletions evmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type EVMD struct {
interfaceRegistry types.InterfaceRegistry
txConfig client.TxConfig

pendingTxListeners []ante.PendingTxListener
pendingTxListeners []evmante.PendingTxListener

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
Expand Down Expand Up @@ -439,7 +439,7 @@ func NewExampleApp(

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)

Expand Down Expand Up @@ -801,7 +801,7 @@ func NewExampleApp(
}

func (app *EVMD) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) {
options := ante.HandlerOptions{
options := evmante.HandlerOptions{
Cdc: app.appCodec,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
Expand Down
Loading