Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
ac47fa4
move tests to remove circular dependency
vladjdk Sep 23, 2025
463ad28
remove ante2
vladjdk Sep 23, 2025
73f5395
Merge branch 'vlad/remove-evmd-dep' into vlad/config-refactor
vladjdk Sep 23, 2025
c3dc99e
wip: move all config files out of evmd
vladjdk Sep 23, 2025
9b9dd66
wip: add todos
vladjdk Sep 23, 2025
dc32dbb
reset config to fix test
vladjdk Sep 23, 2025
019f3d8
fix evmd tests by adding resets to the evmappoptions
vladjdk Sep 23, 2025
3aff36b
remove testutil/config constants
vladjdk Sep 24, 2025
567764f
fix eips test
vladjdk Sep 24, 2025
91d432c
remove all configs except for genesis from testutil/config and consol…
vladjdk Sep 24, 2025
2b13bcf
lints and merge main
vladjdk Sep 24, 2025
6bee431
Merge branch 'main' into vlad/config-refactor
vladjdk Sep 24, 2025
dda4aac
changelogchangelogchangelogchangelogchangelog
vladjdk Sep 24, 2025
e050fc1
Merge remote-tracking branch 'origin/vlad/config-refactor' into vlad/…
vladjdk Sep 24, 2025
94fc72a
lints
vladjdk Sep 24, 2025
fde47c0
wip: removing app options (tests failing)
vladjdk Sep 24, 2025
7e8c25f
begin storing coin info in the vm keeper storage
vladjdk Sep 24, 2025
87904e3
remove debugging artifact
vladjdk Sep 24, 2025
bedbd6d
artifact removal 2
vladjdk Sep 24, 2025
799db42
fix unit tests
vladjdk Sep 24, 2025
5bd1add
wip: fix ibc testing
vladjdk Sep 25, 2025
f16467c
delete all evmappoptions from tests
vladjdk Sep 25, 2025
b9fb2a7
fix ibc precompile integration test balance getters
vladjdk Sep 25, 2025
77a30c2
Merge remote-tracking branch 'origin/main' into vlad/remove-app-options
vladjdk Sep 26, 2025
71b7722
fix all evmd tests
vladjdk Sep 26, 2025
f8c0743
fix precisebank keeper test
vladjdk Sep 26, 2025
de569ea
fix smore tests
vladjdk Sep 26, 2025
0eeb6ec
lol
vladjdk Sep 26, 2025
0995962
add upgrade handler
vladjdk Sep 26, 2025
79d63fc
lints
vladjdk Sep 26, 2025
356d183
changelog
vladjdk Sep 26, 2025
c65a7cb
Fix imports, add upgrade for non-18-decimal chains, and add migration…
vladjdk Sep 27, 2025
6f9190d
Merge branch 'main' into vlad/remove-app-options
vladjdk Oct 7, 2025
20f33be
fix system test
vladjdk Oct 7, 2025
d4b0007
Merge remote-tracking branch 'origin/vlad/remove-app-options' into vl…
vladjdk Oct 7, 2025
dd59c63
Merge branch 'main' into vlad/remove-app-options
vladjdk Oct 7, 2025
47d2ec9
Update docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md
vladjdk Oct 8, 2025
6ec0eea
fix monodecorator test
vladjdk Oct 8, 2025
6efae1b
Merge remote-tracking branch 'origin/vlad/remove-app-options' into vl…
vladjdk Oct 8, 2025
bb572eb
Remove test* denoms and replace with default*
vladjdk Oct 8, 2025
af5caaa
extract var
vladjdk Oct 8, 2025
e8ead26
match vars
vladjdk Oct 8, 2025
cc38dfb
remove chain config from configurator
vladjdk Oct 8, 2025
2d283fa
undo uint8 change
vladjdk Oct 8, 2025
97e8c38
comment fixes
vladjdk Oct 8, 2025
51e5e51
Merge remote-tracking branch 'origin/main' into vlad/remove-app-options
vladjdk Oct 8, 2025
0d932c0
Auto stash before merge of "vlad/remove-app-options" and "origin/main"
vladjdk Oct 8, 2025
a16bba8
set chain config in vm integ tests
vladjdk Oct 8, 2025
949698c
lint
vladjdk Oct 8, 2025
1a51a6f
fix error on test
vladjdk Oct 8, 2025
cbbaa44
fix denoms for ibc chain
vladjdk Oct 9, 2025
4254ca5
add mempool config helper
almk-dev Oct 9, 2025
0ed773a
Revert "fix denoms for ibc chain"
vladjdk Oct 9, 2025
7244188
add mempool config helper
almk-dev Oct 9, 2025
a5cda40
Merge branch 'abdul/refactor-mempool-config' of github.com:cosmos/evm…
almk-dev Oct 9, 2025
0b44e5b
use app options chain id instead of passing param
vladjdk Oct 9, 2025
e56e942
lints
vladjdk Oct 9, 2025
8d966ff
revert make race
vladjdk Oct 9, 2025
303f101
Merge branch 'main' into vlad/remove-app-options
vladjdk Oct 9, 2025
53944aa
add changelog
almk-dev Oct 9, 2025
618b38e
expore legacy fields
almk-dev Oct 9, 2025
4258fe2
use default config
almk-dev Oct 9, 2025
6ff1eb7
add mempool config helper
almk-dev Oct 9, 2025
18f6de0
add changelog
almk-dev Oct 9, 2025
492161e
expore legacy fields
almk-dev Oct 9, 2025
8875479
use default config
almk-dev Oct 9, 2025
9309d3d
Merge branch 'abdul/refactor-mempool-config' of github.com:cosmos/evm…
almk-dev Oct 9, 2025
7d1a502
Merge branch 'main' into abdul/refactor-mempool-config
almk-dev Oct 9, 2025
2197dbb
fix tests
almk-dev Oct 9, 2025
2e7c493
clean up config creator
almk-dev Oct 9, 2025
565ab76
get rid of obvious comments
almk-dev Oct 9, 2025
2ab4b7e
Merge branch 'main' into abdul/refactor-mempool-config
almk-dev Oct 9, 2025
2bc131d
Merge branch 'main' into abdul/refactor-mempool-config
almk-dev Oct 10, 2025
856cdf3
fix lint
almk-dev Oct 10, 2025
e0f6b4f
Merge branch 'main' into abdul/refactor-mempool-config
vladjdk Oct 10, 2025
6800093
add bindings
almk-dev Oct 10, 2025
ca7a05b
Merge branch 'main' into abdul/refactor-mempool-config
almk-dev Oct 10, 2025
70270d0
Merge branch 'main' into abdul/refactor-mempool-config
vladjdk Oct 10, 2025
7a883ac
Merge branch 'main' into abdul/refactor-mempool-config
vladjdk Oct 13, 2025
6f6c4e8
Merge branch 'main' into abdul/refactor-mempool-config
aljo242 Oct 13, 2025
3c06cd0
unbounded txs
vladjdk Oct 13, 2025
504d9c2
add max txs flag binding
vladjdk Oct 14, 2025
8a135bc
set to int
vladjdk Oct 14, 2025
51a76ea
add mempool config to docs
vladjdk Oct 14, 2025
5a1ba61
max-txs param in eip tests
vladjdk Oct 14, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

### IMPROVEMENTS

- [\#698](https://github.com/cosmos/evm/pull/698) Expose mempool configuration flags and move mempool configuration in app.go to helper
- [\#538](https://github.com/cosmos/evm/pull/538) Optimize `eth_estimateGas` gRPC path: short-circuit plain transfers, add optimistic gas bound based on `MaxUsedGas`.
- [\#513](https://github.com/cosmos/evm/pull/513) Replace `TestEncodingConfig` with production `EncodingConfig` in encoding package to remove test dependencies from production code.
- [\#467](https://github.com/cosmos/evm/pull/467) Replace GlobalEVMMempool by passing to JSONRPC on initiate.
Expand Down
59 changes: 59 additions & 0 deletions config/server_app_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/holiman/uint256"
"github.com/spf13/cast"

"github.com/cosmos/evm/mempool/txpool/legacypool"
srvflags "github.com/cosmos/evm/server/flags"

"cosmossdk.io/log"
Expand All @@ -21,6 +22,11 @@ import (
// GetBlockGasLimit reads the genesis json file using AppGenesisFromFile
// to extract the consensus block gas limit before InitChain is called.
func GetBlockGasLimit(appOpts servertypes.AppOptions, logger log.Logger) uint64 {
if appOpts == nil {
logger.Error("app options is nil, using zero block gas limit")
return math.MaxUint64
}

homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
if homeDir == "" {
logger.Error("home directory not found in app options, using zero block gas limit")
Expand Down Expand Up @@ -69,6 +75,11 @@ func GetBlockGasLimit(appOpts servertypes.AppOptions, logger log.Logger) uint64
// This is currently not used, but is kept in case this is useful for the mempool,
// in addition to the min tip flag
func GetMinGasPrices(appOpts servertypes.AppOptions, logger log.Logger) sdk.DecCoins {
if appOpts == nil {
logger.Error("app options is nil, using empty DecCoins")
return sdk.DecCoins{}
}

minGasPricesStr := cast.ToString(appOpts.Get(sdkserver.FlagMinGasPrices))
minGasPrices, err := sdk.ParseDecCoins(minGasPricesStr)
if err != nil {
Expand All @@ -82,6 +93,11 @@ func GetMinGasPrices(appOpts servertypes.AppOptions, logger log.Logger) sdk.DecC
// GetMinTip reads the min tip from the app options, set from app.toml
// This field is also known as the minimum priority fee
func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int {
if appOpts == nil {
logger.Error("app options is nil, using zero min tip")
return nil
}

minTipUint64 := cast.ToUint64(appOpts.Get(srvflags.EVMMinTip))
minTip := uint256.NewInt(minTipUint64)

Expand All @@ -92,3 +108,46 @@ func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int {
logger.Error("invalid min tip value in app.toml or flag, falling back to nil", "min_tip", minTipUint64)
return nil
}

// GetLegacyPoolConfig reads the legacy pool configuration from appOpts and overrides
// default values with values from app.toml if they exist and are non-zero.
func GetLegacyPoolConfig(appOpts servertypes.AppOptions, logger log.Logger) *legacypool.Config {
if appOpts == nil {
logger.Error("app options is nil, using default mempool config")
return &legacypool.DefaultConfig
}

legacyConfig := legacypool.DefaultConfig
if priceLimit := cast.ToUint64(appOpts.Get(srvflags.EVMMempoolPriceLimit)); priceLimit != 0 {
legacyConfig.PriceLimit = priceLimit
}
if priceBump := cast.ToUint64(appOpts.Get(srvflags.EVMMempoolPriceBump)); priceBump != 0 {
legacyConfig.PriceBump = priceBump
}
if accountSlots := cast.ToUint64(appOpts.Get(srvflags.EVMMempoolAccountSlots)); accountSlots != 0 {
legacyConfig.AccountSlots = accountSlots
}
if globalSlots := cast.ToUint64(appOpts.Get(srvflags.EVMMempoolGlobalSlots)); globalSlots != 0 {
legacyConfig.GlobalSlots = globalSlots
}
if accountQueue := cast.ToUint64(appOpts.Get(srvflags.EVMMempoolAccountQueue)); accountQueue != 0 {
legacyConfig.AccountQueue = accountQueue
}
if globalQueue := cast.ToUint64(appOpts.Get(srvflags.EVMMempoolGlobalQueue)); globalQueue != 0 {
legacyConfig.GlobalQueue = globalQueue
}
if lifetime := cast.ToDuration(appOpts.Get(srvflags.EVMMempoolLifetime)); lifetime != 0 {
legacyConfig.Lifetime = lifetime
}

return &legacyConfig
}

func GetCosmosPoolMaxTx(appOpts servertypes.AppOptions, logger log.Logger) int {
if appOpts == nil {
logger.Error("app options is nil, using default cosmos pool max tx of -1 (no-op)")
return 0
}

return cast.ToInt(appOpts.Get(sdkserver.FlagMempoolMaxTxs))
}
85 changes: 85 additions & 0 deletions docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,79 @@ mempoolConfig.CosmosPoolConfig = &cosmosCfg
mempoolConfig.BroadCastTxFn = func(txs []*ethtypes.Transaction) error { return nil }
```

#### New Configuration Options

PR [#698](https://github.com/cosmos/evm/pull/698) adds new configuration options for the EVM mempool that can be set via `app.toml` or CLI flags. These options allow fine-tuning of the EVM legacy pool behavior.

##### Configuration via `app.toml`

The following mempool configuration options are now available in `app.toml` under the `[evm.mempool]` section:

```toml
[evm.mempool]
# PriceLimit is the minimum gas price to enforce for acceptance into the pool (in wei)
price-limit = 1

# PriceBump is the minimum price bump percentage to replace an already existing transaction (nonce)
price-bump = 10

# AccountSlots is the number of executable transaction slots guaranteed per account
account-slots = 16

# GlobalSlots is the maximum number of executable transaction slots for all accounts
global-slots = 5120

# AccountQueue is the maximum number of non-executable transaction slots permitted per account
account-queue = 64

# GlobalQueue is the maximum number of non-executable transaction slots for all accounts
global-queue = 1024

# Lifetime is the maximum amount of time non-executable transaction are queued
lifetime = "3h0m0s"
```

##### Configuration via CLI Flags

These options can also be set via CLI flags:

- `--evm.mempool.price-limit` (default: 1)
- `--evm.mempool.price-bump` (default: 10)
- `--evm.mempool.account-slots` (default: 16)
- `--evm.mempool.global-slots` (default: 5120)
- `--evm.mempool.account-queue` (default: 64)
- `--evm.mempool.global-queue` (default: 1024)
- `--evm.mempool.lifetime` (default: 3h0m0s)

##### Cosmos Mempool Max Transactions

A new flag `--mempool.max-txs` allows limiting the maximum number of transactions in the Cosmos mempool. Set to 0 or -1 for unbounded (default: 0).

##### Simplified Mempool Setup

The mempool configuration can now be handled by a helper function. If you prefer to use the configuration from `app.toml` and CLI flags, you can refactor your mempool setup:

```go
// Before: Manual configuration in app.go
mempoolConfig := &evmmempool.EVMMempoolConfig{
AnteHandler: app.GetAnteHandler(),
BlockGasLimit: blockGasLimit,
MinTip: minTip,
}
evmMempool := evmmempool.NewExperimentalEVMMempool(
app.CreateQueryContext, logger, app.EVMKeeper, app.FeeMarketKeeper,
app.txConfig, app.clientCtx, mempoolConfig,
)

// After: Using helper function (optional)
// See evmd/mempool.go for reference implementation
if err := app.configureEVMMempool(appOpts, logger); err != nil {
panic(fmt.Sprintf("failed to configure EVM mempool: %s", err.Error()))
}
```

The helper function reads configuration from `appOpts` and applies defaults where needed. Note that `NewExperimentalEVMMempool` now takes an additional `cosmosPoolMaxTx` parameter.

### Default Precompiles

Default precompiles have been moved to `/evm/precompiles/types/defaults.go` and the function name was
Expand Down Expand Up @@ -175,6 +248,18 @@ and moves them to state or genesis.
It is critical to remove any use of EvmAppOptions as calling the configurator will panic the chain
at runtime during startup.

#### EVM Chain ID

The EVM chain ID is now retrieved directly from `appOpts` instead of being passed as a parameter. In `app.go`, the chain ID is obtained using:

```go
evmChainID := cast.ToUint64(appOpts.Get(srvflags.EVMChainID))
```

See `evmd/app.go:216` for the reference implementation.

#### Function Signature Changes

In `app.go`, remove evmChainID and evmAppOptions from the NewApp signature.

```diff
Expand Down
26 changes: 3 additions & 23 deletions evmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,29 +717,9 @@ func NewExampleApp(
app.setAnteHandler(app.txConfig, maxGasWanted)

// set the EVM priority nonce mempool
// If you wish to use the noop mempool, remove this codeblock
if evmtypes.GetChainConfig() != nil {
// Get the block gas limit from genesis file
blockGasLimit := evmconfig.GetBlockGasLimit(appOpts, logger)
// Get GetMinTip from app.toml or cli flag configuration
mipTip := evmconfig.GetMinTip(appOpts, logger)

mempoolConfig := &evmmempool.EVMMempoolConfig{
AnteHandler: app.GetAnteHandler(),
BlockGasLimit: blockGasLimit,
MinTip: mipTip,
}

evmMempool := evmmempool.NewExperimentalEVMMempool(app.CreateQueryContext, logger, app.EVMKeeper, app.FeeMarketKeeper, app.txConfig, app.clientCtx, mempoolConfig)
app.EVMMempool = evmMempool

app.SetMempool(evmMempool)
checkTxHandler := evmmempool.NewCheckTxHandler(evmMempool)
app.SetCheckTxHandler(checkTxHandler)

abciProposalHandler := baseapp.NewDefaultProposalHandler(evmMempool, app)
abciProposalHandler.SetSignerExtractionAdapter(evmmempool.NewEthSignerExtractionAdapter(sdkmempool.NewDefaultSignerExtractionAdapter()))
app.SetPrepareProposal(abciProposalHandler.PrepareProposalHandler())
// if you wish to use the noop mempool, remove this codeblock
if err := app.configureEVMMempool(appOpts, logger); err != nil {
panic(fmt.Sprintf("failed to configure EVM mempool: %s", err.Error()))
}

// In v0.46, the SDK introduces _postHandlers_. PostHandlers are like
Expand Down
65 changes: 65 additions & 0 deletions evmd/mempool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package evmd

import (
"fmt"

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool"

evmconfig "github.com/cosmos/evm/config"
evmmempool "github.com/cosmos/evm/mempool"
evmtypes "github.com/cosmos/evm/x/vm/types"
)

// configureEVMMempool sets up the EVM mempool and related handlers using viper configuration.
func (app *EVMD) configureEVMMempool(appOpts servertypes.AppOptions, logger log.Logger) error {
if evmtypes.GetChainConfig() == nil {
logger.Debug("evm chain config is not set, skipping mempool configuration")
return nil
}

mempoolConfig, err := app.createMempoolConfig(appOpts, logger)
if err != nil {
return fmt.Errorf("failed to get mempool config: %w", err)
}
cosmosPoolMaxTx := evmconfig.GetCosmosPoolMaxTx(appOpts, logger)

evmMempool := evmmempool.NewExperimentalEVMMempool(
app.CreateQueryContext,
logger,
app.EVMKeeper,
app.FeeMarketKeeper,
app.txConfig,
app.clientCtx,
mempoolConfig,
cosmosPoolMaxTx,
)
app.EVMMempool = evmMempool
app.SetMempool(evmMempool)
checkTxHandler := evmmempool.NewCheckTxHandler(evmMempool)
app.SetCheckTxHandler(checkTxHandler)

abciProposalHandler := baseapp.NewDefaultProposalHandler(evmMempool, app)
abciProposalHandler.SetSignerExtractionAdapter(
evmmempool.NewEthSignerExtractionAdapter(
sdkmempool.NewDefaultSignerExtractionAdapter(),
),
)
app.SetPrepareProposal(abciProposalHandler.PrepareProposalHandler())

return nil
}

// createMempoolConfig creates a new EVMMempoolConfig with the default configuration
// and overrides it with values from appOpts if they exist and are non-zero.
func (app *EVMD) createMempoolConfig(appOpts servertypes.AppOptions, logger log.Logger) (*evmmempool.EVMMempoolConfig, error) {
return &evmmempool.EVMMempoolConfig{
AnteHandler: app.GetAnteHandler(),
LegacyPoolConfig: evmconfig.GetLegacyPoolConfig(appOpts, logger),
BlockGasLimit: evmconfig.GetBlockGasLimit(appOpts, logger),
MinTip: evmconfig.GetMinTip(appOpts, logger),
}, nil
}
13 changes: 12 additions & 1 deletion mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ type EVMMempoolConfig struct {
// It initializes both EVM and Cosmos transaction pools, sets up blockchain interfaces,
// and configures fee-based prioritization. The config parameter allows customization
// of pools and verification functions, with sensible defaults created if not provided.
func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sdk.Context, error), logger log.Logger, vmKeeper VMKeeperI, feeMarketKeeper FeeMarketKeeperI, txConfig client.TxConfig, clientCtx client.Context, config *EVMMempoolConfig) *ExperimentalEVMMempool {
func NewExperimentalEVMMempool(
getCtxCallback func(height int64, prove bool) (sdk.Context, error),
logger log.Logger,
vmKeeper VMKeeperI,
feeMarketKeeper FeeMarketKeeperI,
txConfig client.TxConfig,
clientCtx client.Context,
config *EVMMempoolConfig,
cosmosPoolMaxTx int,
) *ExperimentalEVMMempool {
var (
cosmosPool sdkmempool.ExtMempool
blockchain *Blockchain
Expand Down Expand Up @@ -137,6 +146,7 @@ func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sd
panic("tx pool should contain only legacypool")
}

// TODO: move this logic to evmd.createMempoolConfig and set the max tx there
// Create Cosmos Mempool from configuration
cosmosPoolConfig := config.CosmosPoolConfig
if cosmosPoolConfig == nil {
Expand Down Expand Up @@ -166,6 +176,7 @@ func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sd
cosmosPoolConfig = &defaultConfig
}

cosmosPoolConfig.MaxTx = cosmosPoolMaxTx
cosmosPool = sdkmempool.NewPriorityMempool(*cosmosPoolConfig)

evmMempool := &ExperimentalEVMMempool{
Expand Down
Loading
Loading