-
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
Paginate supply queries #8798
Paginate supply queries #8798
Conversation
This pull request introduces 1 alert when merging baef976 into 6520997 - view on LGTM.com new alerts:
|
Hey @sahith-narahari, any progress on this PR? Is this r4r (even in draft)? |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=7c5e50db17a14f90ad450c503db5a33b |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=97c9c4403580fd2777b8d65ba76b3258cc76ed18 |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=e352f58ac45ac3b7707e7c74261532da7d6972ac |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=5efecf3e96c13733884ee7f79c24cbf20b3fd985 |
Benchmark beginning. Status page: https://github.orijtech.com/benchmark/status?commit=5340037a9938f06249e74ce861ecff504321290f |
x/bank/keeper/invariants.go
Outdated
@@ -50,7 +51,11 @@ func NonnegativeBalanceInvariant(k ViewKeeper) sdk.Invariant { | |||
func TotalSupply(k Keeper) sdk.Invariant { | |||
return func(ctx sdk.Context) (string, bool) { | |||
expectedTotal := sdk.Coins{} | |||
supply := k.GetTotalSupply(ctx) | |||
supply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) |
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.
@AmauryM do you think we should have empty page request or use alternative defaults
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.
i think we can keep calling GetTotalSupply
, no?
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.
I feel it's better not to expose the method, not a strong opinion though. wdyt?
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.
I feel it's better not to expose the method
Not sure I understand. GetTotalSupply
still exists in the keeper. Should we actually remove it?
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.
yes, I'm in favour of removing it.
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 overall!
x/bank/keeper/invariants.go
Outdated
@@ -50,7 +51,11 @@ func NonnegativeBalanceInvariant(k ViewKeeper) sdk.Invariant { | |||
func TotalSupply(k Keeper) sdk.Invariant { | |||
return func(ctx sdk.Context) (string, bool) { | |||
expectedTotal := sdk.Coins{} | |||
supply := k.GetTotalSupply(ctx) | |||
supply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) |
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.
i think we can keep calling GetTotalSupply
, no?
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, changelog is missing
@aaronc if we use paginations for internal queries, I feel we're increasing complexity as the number of iterations for the pagination increase. Whereas using GetTotalSupply fetches values in one interation over the store. Is there any particular case you see where pagination helps even for internal functions? |
Benchmark finished. See the result: https://github.orijtech.com/benchmark/result?id=be7b307d49a84526b4a17e6165e7a6a9 |
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.
if we use paginations for internal queries, I feel we're increasing complexity as the number of iterations for the pagination increase. Whereas using GetTotalSupply fetches values in one interation over the store.
From my understanding, GetTotalSupply
== GetPaginatedTotalSupply(PageRequest{Limit: max_uint64})
. If that's correct, then I think we can keep GetTotalSupply deleted.
Blocking because @jgimeno's comment needs to be fixed #8798 (comment)
… into sahith/paginate-supply
x/bank/keeper/keeper.go
Outdated
supply := sdk.NewCoins() | ||
|
||
pageRes, err := query.Paginate(supplyStore, pagination, func(key, value []byte) error { | ||
amount, ok := sdk.NewIntFromString(string(value)) |
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.
?? why the amount is stored as a string??
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.
fwiu it's because sdk.Int
doesn't implement proto message. @jgimeno should know better
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.
but it has Bytes()
tho
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.
true, opened a pr for this #9051
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, except that we should probably wait for #9051, right? (ref: #8798 (comment))
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.
nice 🎉
Description
ref: #8761
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.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes