Skip to content
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: switch the client for alerts from rpc to grpc for new kava version #72

Merged
merged 16 commits into from
Sep 26, 2024

Conversation

boodyvo
Copy link
Contributor

@boodyvo boodyvo commented Sep 23, 2024

No description provided.

Copy link
Member

@karzak karzak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits, otherwise LGTM

// Create codec for messages
encodingConfig := kava.MakeEncodingConfig()

pruningGRPCClient, err := kavagrpc.NewClient("https://grpc.kava.io:443")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for writing tests!

In general, I would prefer not to have tests depend on live infra, as it's a bit brittle. However, I'll take it over no tests! I think the best approach would be to use mocks and store the example responses as files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw such type of tests in other repos and like that because it helps to validate that it will work on mainnet at least. Yeh, agree that it is brittle as depends on external things, but we always can test it live. We can put it behind "non short" or something like that.

Alternatively, I can implement the some kind of VCR or other stubs to substitute server (not sure, if it works for grpc).

alerts/auctions/grpc_client.go Outdated Show resolved Hide resolved
@@ -0,0 +1,21 @@
package auctions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a readme to this folder?

Auction alerts tracks ongoing auctions on the Kava Chain and alerts for:

  • Total value of auctions above configured value
  • Percentage price deviation of auction clearing price above configured value
  • Price deviation of USDX below configured value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to the module README.md as those alerts you described are actually 2 different services (one for auctions and one for usdx)

alerts/go.mod Outdated Show resolved Hide resolved
require.Len(t, markets, 10)
}

func TestGrpcGetMoneyMarkets(t *testing.T) {
Copy link
Member

@drklee3 drklee3 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems to be failing - should have 29 item(s), but has 16

There's currently no CI workflow that runs these tests, would be great to add one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. The thing I noticed is that auction-audit test failed. At the moment removed them from CI (to not block this one) and investigating what happen there


// GrpcAuctionClient defines a client for interacting with auctions via rpc
type GrpcAuctionClient struct {
conn *grpc.ClientConn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused field

Suggested change
conn *grpc.ClientConn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange that it was not caught up by the linter. Should we add flags to set it up to catch such misses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated a lint, but still it doesn't catch such cases 😱 And we have lots of lint errors with hard-keeper-bot, so added at the moment that as a TODO for lint and update and created ticket for that (as not directly related to this update): https://app.shortcut.com/kava-labs/story/14431

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Yeah definitely room for improvement with the CI - ideally we have a set of consistent workflows for all repos that need it, following the main ones we use in Kava repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I picked up from kava repo, as I remember we discussed them and reviewed appropriately.

Copy link
Member

@drklee3 drklee3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some minor things but otherwise looks great 😄

alerts/config/rpc.go Outdated Show resolved Hide resolved
alerts/auctions/grpc_client.go Outdated Show resolved Hide resolved
alerts/cmd/auctions.go Outdated Show resolved Hide resolved
@boodyvo boodyvo merged commit 126760f into master Sep 26, 2024
3 checks passed
@boodyvo boodyvo deleted the update-alert-auction-to-grpc branch September 26, 2024 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants