Skip to content

Commit

Permalink
imp(cmd): update default Tendermint config (#696)
Browse files Browse the repository at this point in the history
* imp(cmd): update default Tendermint config

* c++
  • Loading branch information
ranupthestairs committed Jun 16, 2022
1 parent 208d0b6 commit 70c3214
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

- (fees) [\#691](https://github.com/tharsis/evmos/pull/691) Internal Api audit.
- (fees) [\#691](https://github.com/tharsis/evmos/pull/691) Internal API audit.

### Improvements

- (cmd) [\#696](https://github.com/tharsis/evmos/pull/696) Set a custom tendermint node configuration on initialization.
- (fees) [\#685](https://github.com/tharsis/evmos/pull/685) Internal Specification audit.

## [v5.0.0] - 2022-06-14
Expand Down
24 changes: 23 additions & 1 deletion cmd/evmosd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"io"
"os"
"path/filepath"
"time"

"github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/snapshots"

"github.com/spf13/cast"
"github.com/spf13/cobra"

tmcfg "github.com/tendermint/tendermint/config"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
Expand Down Expand Up @@ -91,9 +93,20 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return err
}

// override the app and tendermint configuration
customAppTemplate, customAppConfig := initAppConfig()
customTMConfig := initTendermintConfig()

return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
err = sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
if err != nil {
return err
}

// TODO: remove the lines below once Cosmos SDK v0.46 is released
serverCtx := sdkserver.GetServerContextFromCmd(cmd)
serverCtx.Config = customTMConfig

return sdkserver.SetCmdServerContext(cmd, serverCtx)
},
}

Expand Down Expand Up @@ -206,6 +219,15 @@ func initAppConfig() (string, interface{}) {
return customAppTemplate, srvCfg
}

// initTendermintConfig overrides the default Tendermint Config values.
// It sets the timeout commit default to "1s" in order to get ~2s block times
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()

cfg.Consensus.TimeoutCommit = time.Second
return cfg
}

type appCreator struct {
encCfg params.EncodingConfig
}
Expand Down

0 comments on commit 70c3214

Please sign in to comment.