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

fix: do not overwrite comet config when set in InterceptConfigsPreRunHandler #16395

Merged
merged 4 commits into from
Jun 1, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (server) [#16395](https://github.com/cosmos/cosmos-sdk/pull/16395) Do not override some Comet config is purposely set differently in `InterceptConfigsPreRunHandler`.
* (types) [#16076](https://github.com/cosmos/cosmos-sdk/pull/16076) Optimize `ChainAnteDecorators`/`ChainPostDecorators` to instantiate the functions once instead of on every invocation of the returned `AnteHandler`/`PostHandler`.
* (client) [#16075](https://github.com/cosmos/cosmos-sdk/pull/16075) Partly revert [#15953](https://github.com/cosmos/cosmos-sdk/issues/15953) and `factory.Prepare` does nothing in offline mode.
* (server) [#16071](https://github.com/cosmos/cosmos-sdk/pull/16071) When `mempool.max-txs` is set to a negative value, use a no-op mempool (effectively disable the app mempool).
Expand Down
14 changes: 10 additions & 4 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,16 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo
return nil, fmt.Errorf("error in config file: %w", err)
}

conf.RPC.PprofListenAddress = "localhost:6060"
conf.P2P.RecvRate = 5120000
conf.P2P.SendRate = 5120000
conf.Consensus.TimeoutCommit = 5 * time.Second
defaultCometCfg := cmtcfg.DefaultConfig()
// The SDK is opinionated about those comet values, so we set them here.
// We verify first that the user has not changed them for not overriding them.
if conf.Consensus.TimeoutCommit == defaultCometCfg.Consensus.TimeoutCommit {
conf.Consensus.TimeoutCommit = 5 * time.Second
}
Comment on lines +253 to +255
Copy link
Member

Choose a reason for hiding this comment

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

I don't fully understand this. This is what it's doing:

if conf.Consensus.TimeoutCommit == 1s {
    conf.Consensus.TimeoutCommit = 5s
}

This other seems unnecessary because that's the default value for RecvRate, so it's ineffective:

if conf.P2P.RecvRate == defaultCometCfg.P2P.RecvRate {
			conf.P2P.RecvRate = 5120000
}

Is that expected?

Copy link
Member Author

@julienrbrt julienrbrt Jun 1, 2023

Choose a reason for hiding this comment

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

Well this is what it was always doing, so I kept the same behavior.

The issue is when you purposely change the timeout config in intercept pre handler, then it was getting overwritten here.
Making the override made by the app dev useless.
So this just checks if you didn't change the config before, so the SDK stays opinionated if the app dev hasn't changed that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the unnecessary override and added a comment.

if conf.RPC.PprofListenAddress == defaultCometCfg.RPC.PprofListenAddress {
conf.RPC.PprofListenAddress = "localhost:6060"
}

cmtcfg.WriteConfigFile(cmtCfgFile, conf)

case err != nil:
Expand Down