-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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(baseapp): correctly set header info time on query ctx #22732
Conversation
📝 WalkthroughWalkthroughThe pull request introduces several modifications to the Changes
Possibly related PRs
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
@damiannolan your pull request is missing a changelog! |
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
🧹 Outside diff range and nitpick comments (4)
baseapp/abci.go (4)
Line range hint
1207-1207
: Handle error returned byCacheContext()
At line 1207, the error returned by
CacheContext()
is ignored. According to the Uber Go Style Guide, errors should not be silently ignored. Ignoring errors can lead to unintended behavior or panics if the context is nil.Apply this diff to handle the error:
func (app *BaseApp) getContextForProposal(ctx sdk.Context, height int64) sdk.Context { if height == app.initialHeight { - ctx, _ = app.finalizeBlockState.Context().CacheContext() + var err error + ctx, err = app.finalizeBlockState.Context().CacheContext() + if err != nil { + app.logger.Error("failed to cache context", "height", height, "err", err) + return ctx + } // clear all context data set during InitChain to avoid inconsistent behavior ctx = ctx.WithHeaderInfo(coreheader.Info{}).WithBlockHeader(cmtproto.Header{}) return ctx } return ctx }
Line range hint
1084-1109
: Potential nil pointer dereference in deferred functionIn the
FinalizeBlock
method, the deferred function may dereference a nilres
if an error occurs beforeres
is assigned. This can lead to a runtime panic.Add a nil check before using
*res
:defer func() { - for _, streamingListener := range app.streamingManager.ABCIListeners { - if err := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); err != nil { - app.logger.Error("ListenFinalizeBlock listening hook failed", "height", req.Height, "err", err) + if res != nil { + for _, streamingListener := range app.streamingManager.ABCIListeners { + if err := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); err != nil { + app.logger.Error("ListenFinalizeBlock listening hook failed", "height", req.Height, "err", err) + } } + } else { + app.logger.Error("FinalizeBlock response is nil", "height", req.Height) } }()
Line range hint
809-817
: Incorrect variable in panic log statementWithin the deferred function in
ExtendVote
, the log statement useserr
instead ofr
to log the panic value. This results in incorrect panic information being logged.Update the log statement to use
r
:defer func() { if r := recover(); r != nil { app.logger.Error( "panic recovered in ExtendVote", "height", req.Height, "hash", fmt.Sprintf("%X", req.Hash), - "panic", err, + "panic", r, ) err = fmt.Errorf("recovered application panic in ExtendVote: %v", r) } }()
Line range hint
903-907
: Include hash in error log for consistencyIn the
VerifyVoteExtension
method, the error log does not include the block hash. Including the hash, as done inExtendVote
, provides better context for debugging.Update the log statement to include the hash:
app.logger.Error("failed to verify vote extension", "height", req.Height, + "hash", fmt.Sprintf("%X", req.Hash), "err", err)
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (1)
baseapp/abci.go
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
baseapp/abci.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Is this also missing from header info in |
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.
utACK
(cherry picked from commit 371e05a)
Description
The diff fixes this failing e2e test: https://github.com/cosmos/ibc-go/actions/runs/12123056947/job/33797953598?pr=7587
Verified on local run. Source of failure: https://github.com/cosmos/ibc-go/blob/main/modules/light-clients/07-tendermint/client_state.go#L97-L100
ctx.BlockTime()
now returnsheaderInfo.Time
which needs to be set for backwards compat when usingUnwrapSDKContext
.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
Bug Fixes