Skip to content

Commit

Permalink
chore: default TimeoutCommit to 3s (allow opt out of default override…
Browse files Browse the repository at this point in the history
…s) (#7769)

* overwrite with defaults flag

* add logic gate for overriding

* add log line

* make verbiage clearer

* add changelog

* dont check for specific value

* unused var

(cherry picked from commit bf01cf0)
  • Loading branch information
czarcas7ic authored and mergify[bot] committed Mar 20, 2024
1 parent 658c42a commit c6f5d34
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7745](https://github.com/osmosis-labs/osmosis/pull/7745) Add gauge id query to stargate whitelist
* [#7747](https://github.com/osmosis-labs/osmosis/pull/7747) Remove redundant call to incentive collection in CL position withdrawal logic

## v23.0.8-iavl-v1 & v23.0.8

* [#7769](https://github.com/osmosis-labs/osmosis/pull/7769) Set and default timeout commit to 3s. Add flag to prevent custom overrides if not desired.

## v23.0.7-iavl-v1

* [#7750](https://github.com/osmosis-labs/osmosis/pull/7750) IAVL bump to improve pruning
Expand Down
7 changes: 5 additions & 2 deletions cmd/osmosisd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const (

// FlagSetEnv defines a flag to create environment file & save current home directory into it.
FlagSetEnv = "set-env"

// FlagRejectConfigDefaults defines a flag to reject some select defaults that override what is in the config file.
FlagRejectConfigDefaults = "reject-config-defaults"
)

type printInfo struct {
Expand Down Expand Up @@ -109,8 +112,8 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
config.StateSync.TrustPeriod = 112 * time.Hour

// The original default is 5s and is set in Cosmos SDK.
// We lower it to 4s for faster block times.
config.Consensus.TimeoutCommit = 4 * time.Second
// We lower it to 3s for faster block times.
config.Consensus.TimeoutCommit = 3 * time.Second

config.SetRoot(clientCtx.HomeDir)

Expand Down
41 changes: 23 additions & 18 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ const (

var (
//go:embed "osmosis-1-assetlist.json" "osmo-test-5-assetlist.json"
assetFS embed.FS
mainnetId = "osmosis-1"
testnetId = "osmo-test-5"
fiveSecondsString = (5 * time.Second).String()
assetFS embed.FS
mainnetId = "osmosis-1"
testnetId = "osmo-test-5"
)

func loadAssetList(initClientCtx client.Context, cmd *cobra.Command, basedenomToIBC, IBCtoBasedenom bool) (map[string]DenomUnitMap, map[string]string) {
Expand Down Expand Up @@ -440,7 +439,7 @@ func overwriteConfigTomlValues(serverCtx *server.Context) error {
// It does not exist, so we update the default config.toml to update
// We modify the default config.toml to have faster block times
// It will be written by server.InterceptConfigsPreRunHandler
tmcConfig.Consensus.TimeoutCommit = 4 * time.Second
tmcConfig.Consensus.TimeoutCommit = 3 * time.Second
} else {
// config.toml exists

Expand All @@ -466,10 +465,8 @@ func overwriteConfigTomlValues(serverCtx *server.Context) error {
}

// The original default is 5s and is set in Cosmos SDK.
// We lower it to 4s for faster block times.
if timeoutCommitValue == fiveSecondsString {
serverCtx.Config.Consensus.TimeoutCommit = 4 * time.Second
}
// We lower it to 3s for faster block times.
serverCtx.Config.Consensus.TimeoutCommit = 3 * time.Second

defer func() {
if err := recover(); err != nil {
Expand Down Expand Up @@ -700,16 +697,23 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
cmd.RunE = func(cmd *cobra.Command, args []string) error {
serverCtx := server.GetServerContextFromCmd(cmd)

// overwrite config.toml values
err := overwriteConfigTomlValues(serverCtx)
if err != nil {
return err
}
// Get flag value for rejecting config defaults
rejectConfigDefaults := serverCtx.Viper.GetBool(FlagRejectConfigDefaults)

// overwrite app.toml values
err = overwriteAppTomlValues(serverCtx)
if err != nil {
return err
// overwrite config.toml and app.toml values, if rejectConfigDefaults is false
if !rejectConfigDefaults {
// Add ctx logger line to indicate that config.toml and app.toml values are being overwritten
serverCtx.Logger.Info("Overwriting config.toml and app.toml values with some recommended defaults. To prevent this, set the --reject-config-defaults flag to true.")

err := overwriteConfigTomlValues(serverCtx)
if err != nil {
return err
}

err = overwriteAppTomlValues(serverCtx)
if err != nil {
return err
}
}

return startRunE(cmd, args)
Expand All @@ -734,6 +738,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
wasm.AddModuleInitFlags(startCmd)
startCmd.Flags().Bool(FlagRejectConfigDefaults, false, "Reject some select recommended default values from being automatically set in the config.toml and app.toml")
}

// queryCommand adds transaction and account querying commands.
Expand Down

0 comments on commit c6f5d34

Please sign in to comment.