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

Create pre-upgrade command. Fix minimum-gas-prices repacking unset. #1594

Merged
merged 33 commits into from
Jun 20, 2023

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Jun 15, 2023

Description

This PR:

  1. Creates the provenanced pre-upgrade command as outlined by cosmovisor documentation. It will update the config files to the new formats and set consensus.timeout_commit to 5 seconds.
  2. Adds an error message to the log if the consensus.timeout_commit is too low.
  3. Fixes an issue where the minimum-gas-prices value was being set to "" when either rewriting a packed config or calling provenanced config pack on an already packed config.
  4. Fixes the provenanced debug pubkey-raw command that was trying to add a flag with a -t shorthand that conflicted with the --testnet/-t persistent flag on the root command.

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

…it also set the commit timeout if needed. Make it so that stuff that uses the global viper also gets everything that's needed.
…we can run it multiple times, e.g. from unit tests. Also, add extra handling of ErrorCodes to main since it's sometimes a pointer and sometimes not.
…that it happens before the config files are loaded or any defaults are requested.
…ght need to can do so), and use a temp directory instead of the default.
@SpicyLemon SpicyLemon requested a review from a team as a code owner June 15, 2023 21:04
CHANGELOG.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Merging #1594 (287956d) into main (a6317a2) will increase coverage by 0.03%.
The diff coverage is 74.32%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1594      +/-   ##
==========================================
+ Coverage   63.52%   63.55%   +0.03%     
==========================================
  Files         222      223       +1     
  Lines       28243    28362     +119     
==========================================
+ Hits        17940    18026      +86     
- Misses       9122     9149      +27     
- Partials     1181     1187       +6     
Impacted Files Coverage Δ
cmd/provenanced/config/interceptor.go 0.00% <0.00%> (ø)
cmd/provenanced/cmd/root.go 65.93% <64.51%> (+0.19%) ⬆️
cmd/provenanced/cmd/init.go 69.10% <77.77%> (-0.62%) ⬇️
cmd/provenanced/cmd/pre_upgrade.go 82.35% <82.35%> (ø)
cmd/provenanced/config/manager.go 57.87% <86.95%> (+0.79%) ⬆️

@iramiller
Copy link
Member

General comments re: 5s values and floors...

While 5 is what the SDK has used ... Tendermint recommends 1s ... and we have had some success with this lower value. I wouldn't want to enforce something higher unless we have to. There is a strong possibility of networks running on a private intranet which might want to leverage the lower value to improve the network performance for low latency workloads.

With this in mind it seems we should take a middle ground here and boost the value to 5 seconds for our public main net ... but preserve the ability to run the lower values (perhaps with a warning (edit: info? given the SDK has removed warn from the logger).

@SpicyLemon
Copy link
Contributor Author

SpicyLemon commented Jun 16, 2023

General comments re: 5s values and floors...

While 5 is what the SDK has used ... Tendermint recommends 1s ... and we have had some success with this lower value. I wouldn't want to enforce something higher unless we have to. There is a strong possibility of networks running on a private intranet which might want to leverage the lower value to improve the network performance for low latency workloads.

With this in mind it seems we should take a middle ground here and boost the value to 5 seconds for our public main net ... but preserve the ability to run the lower values (perhaps with a warning (edit: info? given the SDK has removed warn from the logger).

I tweaked the PR a bit. It now only shows the error/warning if it's a mainnet node. It also only shows it if it's less than 2500ms. Also, during pre-upgrade, it'll only get updated under the same circumstances.

I put the log message at the Error level since there's no Warn level and the SDK seems to use Error for lots of things that I'd consider warnings. Also, that way, it's more likely to be seen.

During provenanced init, you can now provide the desired timeout commit. If it's not provided, and it's for a mainnet or testnet node, it'll default to 5s, otherwise 1s.

Basically, all our local chains should still use 1s, but a fresh mainnet or testnet node will get 5s. And only pio-mainnet-1 nodes will see the warning or get their value updated from the pre-upgrade command.

Unrelated to this PR: The default timeout commit used for the integration test networks (e.g. CLI tests) is 2s. I recently changed that to 500ms in our stuff (in another PR), though, which cut the unit test github action run time from 13ish minutes to 7ish.

…'t used before this PR and it wasn't really worthwhile even after setting it due to the package it's in.
@SpicyLemon SpicyLemon merged commit 959b0d8 into main Jun 20, 2023
40 checks passed
@SpicyLemon SpicyLemon deleted the dwedul/1.16-pre-upgrade-cmd branch June 20, 2023 20:50
SpicyLemon added a commit that referenced this pull request Jun 20, 2023
…1594)

* Create a new pre_upgrade command that updates the config files. Make it also set the commit timeout if needed. Make it so that stuff that uses the global viper also gets everything that's needed.

* Force the timeout commit to 5s in all cases. Add some comments and info about what cosmovisor expects.

* Undo the PersistentPreRunE extraction change since I ended up not needing it for the unit tests.

* Fix the existing LogIfError functions.

* Tweak errors returned from pre-upgrade to contain more context and still be indicate the desired exit code.

* Allow creation of the root command that won't seal the app config so we can run it multiple times, e.g. from unit tests. Also, add extra handling of ErrorCodes to main since it's sometimes a pointer and sometimes not.

* Add unit tests on the pre-upgrade command.

* Add a unit test for when the config can't be written.

* Add newline to end of success message.

* Move the global min-gas-prices setting stuff into the interceptor so that it happens before the config files are loaded or any defaults are requested.

* For the init cmd test, don't seal the config (so other things that might need to can do so), and use a temp directory instead of the default.

* Update some tests that started failing because the default timeout_commit changed.

* Just pass sealConfig into the SetConfig function instead of optionally calling it.

* For the pre-unpgrade tests, just add the home dir as a flag for the command.

* Add temporary changelog entries.

* Remove some lines added just for debugging.

* When starting a node with a timeout_commit of less than 4 seconds, output a message stating that it should be set to 5s.

* Update the initialization script to put the timeout_commit back to 1s so that make run cuts blocks faster.

* Only issue low timeout_commit warning on mainnet.

* Replace some deprecated stuff and fix some receivers.

* During pre-upgrae Only update the configured value if it's lower than half the default.

* Only log the warning on mainnet and only if it's less than half the default.

* Add the --timeout-commit flag to the init command. If provided, use that. Otherwise, if something other than mainnet or testnet, use 1s. Otherwise, use whatever was previously in their config or the default if it's brand new.

* Update the initialize script to provide the --timeout-commit to init instead of setting it using the config command at the end.

* Upper-case the first letter of all commmand and flag usage strings. Fix the debug pubkey-raw command that had a conflicting shorthand flag being added.

* Fix the --help flag capitalization.

* Undo the usage capitalization stuff. That's a bit too off-topic for this PR.

* In the pre-upgrade command only change the timeout_commit for mainnet nodes.

* Get rid of the global ChainID variable (in cmd/root.go) since it wasn't used before this PR and it wasn't really worthwhile even after setting it due to the package it's in.
SpicyLemon added a commit that referenced this pull request Jun 20, 2023
…1594) (#1599)

* Create a new pre_upgrade command that updates the config files. Make it also set the commit timeout if needed. Make it so that stuff that uses the global viper also gets everything that's needed.

* Force the timeout commit to 5s in all cases. Add some comments and info about what cosmovisor expects.

* Undo the PersistentPreRunE extraction change since I ended up not needing it for the unit tests.

* Fix the existing LogIfError functions.

* Tweak errors returned from pre-upgrade to contain more context and still be indicate the desired exit code.

* Allow creation of the root command that won't seal the app config so we can run it multiple times, e.g. from unit tests. Also, add extra handling of ErrorCodes to main since it's sometimes a pointer and sometimes not.

* Add unit tests on the pre-upgrade command.

* Add a unit test for when the config can't be written.

* Add newline to end of success message.

* Move the global min-gas-prices setting stuff into the interceptor so that it happens before the config files are loaded or any defaults are requested.

* For the init cmd test, don't seal the config (so other things that might need to can do so), and use a temp directory instead of the default.

* Update some tests that started failing because the default timeout_commit changed.

* Just pass sealConfig into the SetConfig function instead of optionally calling it.

* For the pre-unpgrade tests, just add the home dir as a flag for the command.

* Add temporary changelog entries.

* Remove some lines added just for debugging.

* When starting a node with a timeout_commit of less than 4 seconds, output a message stating that it should be set to 5s.

* Update the initialization script to put the timeout_commit back to 1s so that make run cuts blocks faster.

* Only issue low timeout_commit warning on mainnet.

* Replace some deprecated stuff and fix some receivers.

* During pre-upgrae Only update the configured value if it's lower than half the default.

* Only log the warning on mainnet and only if it's less than half the default.

* Add the --timeout-commit flag to the init command. If provided, use that. Otherwise, if something other than mainnet or testnet, use 1s. Otherwise, use whatever was previously in their config or the default if it's brand new.

* Update the initialize script to provide the --timeout-commit to init instead of setting it using the config command at the end.

* Upper-case the first letter of all commmand and flag usage strings. Fix the debug pubkey-raw command that had a conflicting shorthand flag being added.

* Fix the --help flag capitalization.

* Undo the usage capitalization stuff. That's a bit too off-topic for this PR.

* In the pre-upgrade command only change the timeout_commit for mainnet nodes.

* Get rid of the global ChainID variable (in cmd/root.go) since it wasn't used before this PR and it wasn't really worthwhile even after setting it due to the package it's in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants