-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(client,server): consistently set env prefix between client/server #18345
Conversation
WalkthroughThe changes primarily focus on improving the configuration and environment variable handling in the client and server. The Viper prefix is now consistently set to the binary name in both client and server, and hardcoded gRPC address to localhost in the server has been removed. Fixes were also made to the slashing and governance modules. Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 32c8ab9 and 53b6188ac0f5d0f8c703185830c35216ac7a7b23.Files selected for processing (4)
- CHANGELOG.md (1 hunks)
- client/context.go (1 hunks)
- client/tx/factory.go (2 hunks)
- server/start.go (1 hunks)
Files skipped from review due to trivial changes (2)
- client/context.go
- client/tx/factory.go
Additional comments: 4
CHANGELOG.md (1)
- 75-78: The changes in the
CHANGELOG.md
accurately reflect the changes made in the pull request. The links to the pull requests provide a good reference for further details.server/start.go (3)
147-159: The
PreRunE
function has been removed and its logic has been moved to theRunE
function. This change affects the execution flow of the code. Ensure that the removal ofPreRunE
does not affect other parts of the code that might be relying on it. Also, verify that the error handling and return statements in theRunE
function are correctly implemented after the change.151-155: The
GetPruningOptionsFromFlags
function is now called directly within theRunE
function. Ensure that the function is correctly handling the returned error.157-159: The
GetClientQueryContext
function is also called within theRunE
function. Ensure that the function is correctly handling the returned error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 53b6188ac0f5d0f8c703185830c35216ac7a7b23 and f90d7e145594fef96e8092d2dcf4b625b12ebf8b.Files selected for processing (2)
- client/context.go (2 hunks)
- client/tx/factory.go (2 hunks)
Files skipped from review due to trivial changes (1)
- client/context.go
Additional comments: 2
client/tx/factory.go (2)
8-13: The removal of the import statement for "github.com/spf13/viper" is not reflected in this hunk. Please verify if this is the correct hunk.
49-55: The change from
clientCtx.Viper
toclientCtx.WithViper("")
is a good practice as it ensures thatclientCtx
has a non-nilViper
instance. This prevents potential nil pointer dereference errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @julienrbrt, just one question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between f90d7e145594fef96e8092d2dcf4b625b12ebf8b and 396fc2b97bdfc07f4f5dbbddfc123866d370451d.Files selected for processing (3)
- client/config/config_test.go (7 hunks)
- client/context.go (2 hunks)
- server/util.go (1 hunks)
Files skipped from review due to trivial changes (2)
- client/context.go
- server/util.go
Additional comments: 4
client/config/config_test.go (4)
18-24: The
nodeEnv
constant has been updated to"CONFIG.TEST_NODE"
. Ensure that this change doesn't break any other parts of the code that might be using the old value"NODE"
.44-55: The
initClientContextWithTemplate
function now unsets thenodeEnv
environment variable in the cleanup function. This is a good practice as it ensures that the environment variable doesn't affect other tests.124-129: The
TestCustomTemplateAndConfig
,TestConfigCmdEnvFlag
test functions have been modified to remove the call toos.Unsetenv(nodeEnv)
in the cleanup function. This is because the cleanup is now handled in theinitClientContextWithTemplate
function.164-167: The
TestConfigCmdEnvFlag
test function now uses theinitClientContext
function to set up the client context. This is a good change as it simplifies the test setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 396fc2b97bdfc07f4f5dbbddfc123866d370451d and 0dadebedea3154c1a5c25a52adb9575fd0ce36b2.Files selected for processing (2)
- simapp/simd/cmd/root.go (1 hunks)
- simapp/simd/cmd/root_v2.go (1 hunks)
Files skipped from review due to trivial changes (2)
- simapp/simd/cmd/root.go
- simapp/simd/cmd/root_v2.go
00bec62
to
828e689
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 0dadebedea3154c1a5c25a52adb9575fd0ce36b2 and 00bec626efa6b733e751c5994f44d3a9674330d2.Files selected for processing (2)
- client/config/config_test.go (7 hunks)
- client/context.go (2 hunks)
Files skipped from review due to trivial changes (2)
- client/config/config_test.go
- client/context.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (7)
- CHANGELOG.md (1 hunks)
- client/config/config_test.go (7 hunks)
- client/context.go (2 hunks)
- client/tx/factory.go (2 hunks)
- server/start.go (1 hunks)
- simapp/simd/cmd/root.go (1 hunks)
- simapp/simd/cmd/root_v2.go (1 hunks)
Files skipped from review due to trivial changes (4)
- client/config/config_test.go
- client/context.go
- simapp/simd/cmd/root.go
- simapp/simd/cmd/root_v2.go
Additional comments: 4
CHANGELOG.md (1)
- 75-78: The changes in the changelog are well documented and provide clear information about the bug fixes. No issues found.
client/tx/factory.go (1)
- 49-55: The change to the
NewFactoryCLI
function is correct and improves the initialization of theclientCtx
object. The use ofclientCtx.WithViper("")
ensures that theclientCtx
object has a Viper instance even if none was provided, which is a good practice for avoiding null pointer exceptions. The error handling forclientCtx.Viper.BindPFlags(flagSet)
is also correctly implemented.server/start.go (2)
- 147-159: The
GetPruningOptionsFromFlags
function is called but the result is not used anywhere. If the function has side effects, it's fine. Otherwise, it's unnecessary to call it. Also, error handling is good here.- _, err := GetPruningOptionsFromFlags(serverCtx.Viper) + pruningOptions, err := GetPruningOptionsFromFlags(serverCtx.Viper)
- 150-159: The
GetClientQueryContext
function is called and the result is used. Error handling is also done correctly.
Now that v0.50 is released, I am not sure we can backport this as it will be a behavior change (even though a correct one). |
@julienrbrt Setting the Viper prefix doesn't work properly right now on 0.50.x. I cannot set |
Yeah that's unfortunate, you indeed cannot use a prefix consistently in that version. I still stand to my first point that we unfortunately cannot backport this. |
Description
Closes: #18332
The client and server both have a viper instance, but they did not use the same prefix.
Server was always setting the binary name as env prefix, while for the client it was left to the user.
This brings consistency and happens to resolve the issue.
I will only backport this to v0.50 but not patch releases, just in case chains rely on the buggy behavior.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit