-
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
feat: adds error handling for out-of-gas panics in grpc query handlers. #20945
feat: adds error handling for out-of-gas panics in grpc query handlers. #20945
Conversation
WalkthroughWalkthroughThe recent changes introduce error handling for out-of-gas panics in gRPC query handlers within the Cosmos SDK. This enhancement allows the system to catch Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant gRPCServer
participant QueryHandler
participant ErrorInterceptor
Client->>gRPCServer: Execute gRPC Query
gRPCServer->>QueryHandler: Forward Query
QueryHandler-->>gRPCServer: Return OutOfGasPanic
gRPCServer->>ErrorInterceptor: Handle Panic
ErrorInterceptor-->>gRPCServer: Return Error Message
gRPCServer-->>Client: Return gRPC Response with Error Message
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- CHANGELOG.md (1 hunks)
- baseapp/grpcserver.go (2 hunks)
Additional context used
Path-based instructions (2)
baseapp/grpcserver.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.CHANGELOG.md (1)
Pattern
**/*.md
: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
golangci-lint
baseapp/grpcserver.go
84-84: naked return in func
RegisterGRPCServer.<func():28>
with 57 lines of code(nakedret)
GitHub Check: golangci-lint
baseapp/grpcserver.go
[failure] 84-84:
naked return in funcRegisterGRPCServer.<func():28>
with 57 lines of code (nakedret)
Additional comments not posted (3)
baseapp/grpcserver.go (2)
17-17
: LGTM!The import statement for
storetypes
is necessary for handlingOutOfGasPanic
.
71-81
: LGTM!The
defer
block effectively catches and handlesOutOfGasPanic
by wrapping it with an error message. This improves error handling for out-of-gas scenarios during gRPC queries.CHANGELOG.md (1)
106-106
: Ensure consistency with existing entries.The changelog entry is accurate and grammatically correct. Ensure that it is consistent with the format and style of the existing entries.
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- baseapp/grpcserver.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- baseapp/grpcserver.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.
thank you for the addition,could you add a test case showing this working correctly please
Found the place, but not sure this is best way to add test case. |
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Additional context used
Path-based instructions (1)
CHANGELOG.md (1)
Pattern
**/*.md
: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
Additional comments not posted (1)
CHANGELOG.md (1)
105-105
: LGTM!The changelog entry is correctly formatted and consistent with the rest of the document.
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- tests/integration/server/grpc/out_of_gas_test.go (1 hunks)
- testutil/network/network.go (2 hunks)
Additional context used
Path-based instructions (2)
tests/integration/server/grpc/out_of_gas_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"testutil/network/network.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (6)
tests/integration/server/grpc/out_of_gas_test.go (5)
35-64
: Setup function looks good.The
SetupSuite
function correctly sets up the integration test environment.
66-70
: Teardown function looks good.The
TearDownSuite
function correctly tears down the integration test environment.
72-78
: Basic gRPC query test looks good.The
TestGRPCServer_TestService
function correctly tests a basic gRPC query.
80-94
: Out-of-gas error handling test looks good.The
TestGRPCServer_BankBalance_OutOfGas
function correctly tests the out-of-gas error handling mechanism.
96-98
: Integration test suite runner looks good.The
TestIntegrationTestOutOfGasSuite
function correctly runs the integration test suite.testutil/network/network.go (1)
Line range hint
170-228
: New configuration function looks good.The
DefaultConfigWithAppConfigWithQueryGasLimit
function correctly configures the network with a query gas limit.
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!
Description
Closes: #20944
Catch out-of-gas panic and return proper error message.
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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Tests