-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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!: update ABCI query to use request height #9879
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2e4932d
fix, update ABCI query to use request height
colin-axner 15c2270
add changelog
colin-axner cf002dc
Merge branch 'master' into colin/9433-abci-query-fix
alexanderbez a385b75
Update client/query_test.go
colin-axner e4f28fd
fix tests
colin-axner f376a83
Merge branch 'master' into colin/9433-abci-query-fix
colin-axner 860572c
apply review suggestions from Bez
colin-axner e534ec3
Merge branch 'colin/9433-abci-query-fix' of github.com:cosmos/cosmos-…
colin-axner ac4edc5
update tests
colin-axner aa76452
update changelog and fix merge conflicts
colin-axner 2139665
remove unnecessary changelog entry
colin-axner 55fa25a
Merge branch 'master' into colin/9433-abci-query-fix
alexanderbez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// +build norace | ||
|
||
package client_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
) | ||
|
||
func (s *IntegrationTestSuite) TestQueryABCIHeight() { | ||
// test ABCI query uses request height argument | ||
// instead of client context height | ||
contextHeight := 1 // query at height 1 or 2 would cause an error | ||
reqHeight := int64(10) | ||
|
||
val := s.network.Validators[0] | ||
clientCtx := val.ClientCtx | ||
clientCtx = clientCtx.WithHeight(contextHeight) | ||
|
||
req := abci.RequestQuery{ | ||
Path: fmt.Sprintf("store/%s/key", banktypes.StoreKey), | ||
Height: reqHeight, | ||
Data: banktypes.CreateAccountBalancesPrefix(val.Address), | ||
Prove: true, | ||
} | ||
|
||
res, err := clientCtx.QueryABCI(req) | ||
s.Require().NoError(err) | ||
|
||
s.Require().Equal(reqHeight, res.Height) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In CLI (with --height) and grpc queries (with the height header), iirc we populate the client ctx.Height. So I think we should use req.Height if that's set, or fallback to ctx.Height.
I believe that's the cause of all failing tests
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.
That makes sense. Is there a reason we don't populate the
req
in CLI and API pathways, instead ofctx
? Just curious.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.
Yeah that could work too, where do you see this logic happening?
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.
So
Context#queryABCI
gets call from 2-3 places, one of which doesn't have a height to provide, so we cannot solely rely onreq.Height
.I would do two things:
RunGRPCQuery
to setHeight
inabciReq
.ctx.Height
ifreq.Height
is zero.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.
SGTM!