-
Notifications
You must be signed in to change notification settings - Fork 556
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
Adding upcoming gauges query #1195
Conversation
Nice work! I think the |
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
x/incentives/keeper/grpc_query.go
Outdated
pageRes, err := query.FilteredPaginate(valStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { | ||
upcomingGauges := k.GetUpcomingGauges(ctx) | ||
for _, gauge := range upcomingGauges { | ||
if gauge.DistributeTo.Denom == req.Denom { | ||
gauges = append(gauges, gauge) | ||
} | ||
} | ||
return true, nil | ||
}) | ||
if err != nil { | ||
return nil, status.Error(codes.Internal, err.Error()) | ||
} | ||
|
||
return &types.UpcomingGaugesPerDenomResponse{Data: gauges, Pagination: pageRes}, nil |
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.
On reviewing this PR, I'm realizing that every filtered paginate usage in this package is wrong. I think its fine to merge this as is though, since its not a real performance overhead / can be fixed later. (We should make an issue to track it)
Filtered paginate's method of working is actually pretty awkward / maybe we need to change it at the SDK level. It gives you the value in []bytes
, that this code should then de-marshal, and check if it meets the required constraints. If accumulate is true, only then add it to the gauges result. But this is a high amount of overhead tbh. I think its probably worth getting this refactored in the SDK to be simple, with go 1.18 Generics.
I'll add more detail on this / convert it to an issue, doesn't block this PR!
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 job on your first code change PR!!
LGTM! (It has the same behavior as ActiveGaugesPerDenom)
We should make two follow on issues:
- One brainstorming ways for fixing the erroneous pagination behavior (either we change things directly here, or add better pagination code scaffolding)
- Steps for getting a better table driven test framework here. (We need to make it easy to make upcoming, present, and completed gauges in the test suite)
suite.SetupTest() | ||
|
||
// initial check | ||
res, err := suite.app.IncentivesKeeper.ActiveGaugesPerDenom(sdk.WrapSDKContext(suite.ctx), &types.ActiveGaugesPerDenomRequest{}) |
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.
oh you have to make a querier struct now for this to work now. (An update happened on main.
Change to suite.querier,ActiveGaugesPerDenom
and I think that should work in all places where this is erroring.
Can you run |
Sweet, got you, checking it out!
…On Wed, Apr 6, 2022 at 4:48 PM Dev Ojha ***@***.***> wrote:
Can you run make format to fix the lint errors
—
Reply to this email directly, view it on GitHub
<#1195 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASH4FPWSR4FOUEEVUGTTIA3VDX2AJANCNFSM5STK5W3Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
PR LGTM, its having the liveness test timeout, but this confuses me, since this doesn't even touch the state machine? Any ideas @alexanderbez ? |
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.
Looks great @xBalbinus!
I left some minor feedback. I'm also taking a look at the liveness test.
x/incentives/client/cli/query.go
Outdated
cmd := &cobra.Command{ | ||
Use: "upcoming-gauges-per-denom [denom]", | ||
Short: "Query scheduled gauges per denom", | ||
Long: strings.TrimSpace( |
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.
nit: for concise/straight forward CLI handlers like this, I'd argue Long
is not necessary as it does not offer any additional help or insight.
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.
bump @xBalbinus
Re liveness failures:
Just an FYI, if liveness fails or timesout, you can always run it locally to find out why:
|
proto/osmosis/incentives/query.proto
Outdated
string denom = 1; | ||
cosmos.base.query.v1beta1.PageRequest pagination = 1; |
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.
We gotta be more careful with reviewing proto structs. I missed this too.
string denom = 1; | |
cosmos.base.query.v1beta1.PageRequest pagination = 1; | |
string denom = 1; | |
cosmos.base.query.v1beta1.PageRequest pagination = 2; |
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.
Oop! Updated.
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 your totally right. Is there a way we can lint for this more easily? I don't get why make proto-all even compiled with this as an issue.
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
make proto-format done; changes committed! Thanks @alexanderbez and @ValarDragon for your input & help. |
Codecov Report
@@ Coverage Diff @@
## main #1195 +/- ##
==========================================
- Coverage 20.90% 20.08% -0.83%
==========================================
Files 196 203 +7
Lines 25425 26786 +1361
==========================================
+ Hits 5316 5379 +63
- Misses 19118 20409 +1291
- Partials 991 998 +7
Continue to review full report at Codecov.
|
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'm confused as to how CI is passing. Starport liveness test reports:
|
Should we fix the liveliness tests first before committing? What might be causing this? |
@xBalbinus Yes, we need to fix it. The liveness test does two things primarily -- test the chain builds and runs. The error above tells you:
|
I just pushed out some fixes / changes & make all has been doing well for me (all tests passed). Let me know if the liveliness is still an issue. |
So to fix that liveness error, can you do |
* Add queries for getting Upcoming gauges by denom * rudimentary tests for denomquery * Update proto/osmosis/incentives/query.proto Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> * removed mytestnet * fixed query tests * fixed query tests * Update proto/osmosis/incentives/query.proto pagination number Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update x/incentives/keeper/grpc_query.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * implemented feedback * amended minor bug with prefixStore * investigating BeginDistribution issues * investigating grpc_query_test.go * Fix grpc query test * fixed grpc tests, added nil checks for grpc query, removed long for query.go * additional grpcquery fixes (double if removed) * liveliness error fix * gofmt grpc_query_test.go * liveliness test fixes * liveliness test fixes Co-authored-by: Xiangan He <xiangan@polychain.capital> Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Dev Ojha <dojha@berkeley.edu> (cherry picked from commit eb39af7) # Conflicts: # docs/core/proto-docs.md # go.mod # go.sum # proto/osmosis/gamm/v1beta1/query.proto # x/gamm/types/query.pb.go # x/incentives/client/cli/query.go # x/incentives/keeper/grpc_query.go
* Adding upcoming gauges query (#1195) * Add queries for getting Upcoming gauges by denom * rudimentary tests for denomquery * Update proto/osmosis/incentives/query.proto Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> * removed mytestnet * fixed query tests * fixed query tests * Update proto/osmosis/incentives/query.proto pagination number Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update x/incentives/keeper/grpc_query.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * implemented feedback * amended minor bug with prefixStore * investigating BeginDistribution issues * investigating grpc_query_test.go * Fix grpc query test * fixed grpc tests, added nil checks for grpc query, removed long for query.go * additional grpcquery fixes (double if removed) * liveliness error fix * gofmt grpc_query_test.go * liveliness test fixes * liveliness test fixes Co-authored-by: Xiangan He <xiangan@polychain.capital> Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Dev Ojha <dojha@berkeley.edu> (cherry picked from commit eb39af7) # Conflicts: # docs/core/proto-docs.md # go.mod # go.sum # proto/osmosis/gamm/v1beta1/query.proto # x/gamm/types/query.pb.go # x/incentives/client/cli/query.go # x/incentives/keeper/grpc_query.go * fixing conflicts * Revert "fixing conflicts" This reverts commit 28022f1. * Fix merge conflicts * changed queriers to app.IncentiveKeepers Co-authored-by: Xiangan He <76530366+xBalbinus@users.noreply.github.com> Co-authored-by: Xiangan He <xiangan@polychain.capital> Co-authored-by: Dev Ojha <dojha@berkeley.edu>
Closes: #1158
Description
Added new request definitions in the proto. UpcomingGaugesPerDenom, UpcomingGaugesPerDenomRequest, UpcomingGaugesPerDenomResponse
Made proto-all
Added a keeper method in x/incentives/keeper/grpc_query.go .
Ditto for adding a test for this in grpc_query_test.go: note: I implemented tests as well for querying active upcoming gauges per denom. At the moment, they're not table driven but still diving deeper in and will implement soon.
For contributor use:
docs/
) or specification (x/<module>/spec/
)Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorer