From c13b40f597352483b5d12287e5a65b643db06c94 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:52:46 -0500 Subject: [PATCH] chore: default TimeoutCommit to 3s (allow opt out of default overrides) (backport #7769) (#7781) * chore: default TimeoutCommit to 3s (allow opt out of default overrides) (#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 bf01cf04d2da475029c1c60d671b11fde0eb993f) # Conflicts: # CHANGELOG.md * Update CHANGELOG.md * reject config defaults * reject defaults --------- Co-authored-by: Adam Tucker Co-authored-by: Adam Tucker --- CHANGELOG.md | 11 ++++++++ cmd/osmosisd/cmd/init.go | 7 +++-- cmd/osmosisd/cmd/root.go | 41 +++++++++++++++++------------- tests/e2e/configurer/base.go | 4 +-- tests/e2e/configurer/chain/node.go | 4 +-- tests/e2e/configurer/upgrade.go | 2 +- tests/e2e/containers/containers.go | 9 +++++-- tests/e2e/sync_test.go | 2 +- 8 files changed, 52 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18474df0fbf..9662ddc1781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#7625](https://github.com/osmosis-labs/osmosis/pull/7625) Remove duplicate CL accumulator update logic. * [#7665](https://github.com/osmosis-labs/osmosis/pull/7665) feat(x/protorev): Use Transient store to store swap backruns. * [#7503](https://github.com/osmosis-labs/osmosis/pull/7503) Add IBC wasm light clients module +* [#7689](https://github.com/osmosis-labs/osmosis/pull/7689) Make CL price estimations not cause state writes (speed and gas improvements) +* [#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 ## v23.0.6-iavl-v1 (contains everything in v23.0.6) diff --git a/cmd/osmosisd/cmd/init.go b/cmd/osmosisd/cmd/init.go index 8ab34c355a3..55116d212b1 100644 --- a/cmd/osmosisd/cmd/init.go +++ b/cmd/osmosisd/cmd/init.go @@ -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 { @@ -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) diff --git a/cmd/osmosisd/cmd/root.go b/cmd/osmosisd/cmd/root.go index 8d6081f856d..7028452d041 100644 --- a/cmd/osmosisd/cmd/root.go +++ b/cmd/osmosisd/cmd/root.go @@ -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) { @@ -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 @@ -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 { @@ -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) @@ -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. diff --git a/tests/e2e/configurer/base.go b/tests/e2e/configurer/base.go index e9b399c7001..51f49cd8a64 100644 --- a/tests/e2e/configurer/base.go +++ b/tests/e2e/configurer/base.go @@ -85,8 +85,8 @@ func (bc *baseConfigurer) runValidators(chainConfig *chain.Config) error { // Iterate over each node for _, node := range chainConfig.NodeConfigs { go func(n *chain.NodeConfig) { - defer wg.Done() // Decrement the WaitGroup counter when the goroutine is done - errCh <- n.Run() // Run the node and send any error to the channel + defer wg.Done() // Decrement the WaitGroup counter when the goroutine is done + errCh <- n.Run(false) // Run the node and send any error to the channel }(node) } diff --git a/tests/e2e/configurer/chain/node.go b/tests/e2e/configurer/chain/node.go index 1d66c4b9fde..e9dfb520acb 100644 --- a/tests/e2e/configurer/chain/node.go +++ b/tests/e2e/configurer/chain/node.go @@ -46,13 +46,13 @@ func NewNodeConfig(t *testing.T, initNode *initialization.Node, initConfig *init // Run runs a node container for the given nodeIndex. // The node configuration must be already added to the chain config prior to calling this // method. -func (n *NodeConfig) Run() error { +func (n *NodeConfig) Run(rejectConfigDefaults bool) error { maxRetries := 3 currentRetry := 0 for currentRetry < maxRetries { n.t.Logf("starting node container: %s", n.Name) - resource, err := n.containerManager.RunNodeResource(n.chainId, n.Name, n.ConfigDir) + resource, err := n.containerManager.RunNodeResource(n.chainId, n.Name, n.ConfigDir, rejectConfigDefaults) if err != nil { return err } diff --git a/tests/e2e/configurer/upgrade.go b/tests/e2e/configurer/upgrade.go index 7279cd82867..db0180d0691 100644 --- a/tests/e2e/configurer/upgrade.go +++ b/tests/e2e/configurer/upgrade.go @@ -395,7 +395,7 @@ func (uc *UpgradeConfigurer) upgradeContainers(chainConfig *chain.Config, propHe uc.containerManager.OsmosisTag = containers.CurrentBranchOsmoTag for _, node := range chainConfig.NodeConfigs { - if err := node.Run(); err != nil { + if err := node.Run(true); err != nil { return err } } diff --git a/tests/e2e/containers/containers.go b/tests/e2e/containers/containers.go index 0fb78e66dd3..72617cdd342 100644 --- a/tests/e2e/containers/containers.go +++ b/tests/e2e/containers/containers.go @@ -472,19 +472,24 @@ func (m *Manager) RunHermesResource(chainAID, osmoARelayerNodeName, osmoAValMnem // RunNodeResource runs a node container. Assigns containerName to the container. // Mounts the container on valConfigDir volume on the running host. Returns the container resource and error if any. -func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir string) (*dockertest.Resource, error) { +func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir string, rejectConfigDefaults bool) (*dockertest.Resource, error) { pwd, err := os.Getwd() if err != nil { return nil, err } + cmd := []string{"start"} + if rejectConfigDefaults { + cmd = append(cmd, "--reject-config-defaults=true") + } + runOpts := &dockertest.RunOptions{ Name: containerName, Repository: m.OsmosisRepository, Tag: m.OsmosisTag, NetworkID: m.network.Network.ID, User: "root:root", - Cmd: []string{"start"}, + Cmd: cmd, Mounts: []string{ fmt.Sprintf("%s/:/osmosis/.osmosisd", valCondifDir), fmt.Sprintf("%s/scripts:/osmosis", pwd), diff --git a/tests/e2e/sync_test.go b/tests/e2e/sync_test.go index a90a311f1b5..27677d46268 100644 --- a/tests/e2e/sync_test.go +++ b/tests/e2e/sync_test.go @@ -89,7 +89,7 @@ func (s *IntegrationTestSuite) StateSync() { chainANode.WaitUntil(hasSnapshotsAvailable) // start the state synchin node. - err = stateSynchingNode.Run() + err = stateSynchingNode.Run(true) s.Require().NoError(err) // ensure that the state syncing node cathes up to the running node.