Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: default TimeoutCommit to 3s (allow opt out of default overrides) #7769

Merged
merged 7 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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

czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
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)
Copy link
Member

Choose a reason for hiding this comment

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

AFAIR, there was also a code branch somewhere that would check if the old value is 5 seconds and only then overwrite it. Have we checked/changed that value?

I'm AFK rn but can help with checking this later

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops yeah, I had that change locally when testing but didn't push, great catch

4df1520

Copy link
Member

Choose a reason for hiding this comment

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

Do we have to write ti the file, or can we pass the updated fike to tm? This lgtm!

Maybe worth asking in cometbft issue if we can achieve this w/o writing the file at runtime

This lgtm for this pr, nice job@

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this can be done at the sdk level, I will make an issue and we can look into it at another time.

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