feat(server/v2/cometbft): wire mempool config (#21741)

This commit is contained in:
Julien Robert
2024-09-16 18:45:21 +00:00
committed by GitHub
parent f348d84c1a
commit 52ba264c80
9 changed files with 80 additions and 27 deletions
+5 -1
View File
@@ -74,7 +74,11 @@ func initRootCmd[T transaction.Tx](
newApp,
logger,
initServerConfig(),
cometbft.New(&genericTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()),
cometbft.New(
&genericTxDecoder[T]{txConfig},
initCometOptions[T](),
initCometConfig(),
),
grpc.New[T](),
store.New[T](newApp),
); err != nil {
+38
View File
@@ -2,8 +2,13 @@ package cmd
import (
"strings"
"time"
cmtcfg "github.com/cometbft/cometbft/config"
"cosmossdk.io/core/transaction"
serverv2 "cosmossdk.io/server/v2"
"cosmossdk.io/server/v2/cometbft"
clientconfig "github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
@@ -68,3 +73,36 @@ func initServerConfig() serverv2.ServerConfig {
return serverCfg
}
// initCometConfig helps to override default comet config template and configs.
func initCometConfig() cometbft.CfgOption {
cfg := cmtcfg.DefaultConfig()
// display only warn logs by default except for p2p and state
cfg.LogLevel = "*:warn,p2p:info,state:info"
// increase block timeout
cfg.Consensus.TimeoutCommit = 5 * time.Second
// overwrite default pprof listen address
cfg.RPC.PprofListenAddress = "localhost:6060"
return cometbft.OverwriteDefaultConfigTomlConfig(cfg)
}
func initCometOptions[T transaction.Tx]() cometbft.ServerOptions[T] {
serverOptions := cometbft.DefaultServerOptions[T]()
// TODO mempool interface doesn't match!
// overwrite app mempool, using max-txs option
// serverOptions.Mempool = func(cfg map[string]any) mempool.Mempool[T] {
// if maxTxs := cast.ToInt(cfg[cometbft.FlagMempoolMaxTxs]); maxTxs >= 0 {
// return mempool.NewSenderNonceMempool(
// mempool.SenderNonceMaxTxOpt(maxTxs),
// )
// }
// return mempool.NoOpMempool[T]{}
// }
return serverOptions
}