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

epoching: range query for epochs #289

Merged
merged 8 commits into from
Jan 24, 2023
Merged

Conversation

SebastianElvis
Copy link
Member

Fixes BM-459

This PR adds a range query for epochs in order to support the epoch table in the explorer. This PR also has a fuzz test for it.

Copy link
Contributor

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

Lgtm! Only a minor suggestion. One question about the usage of this API: what's the frequency of this API being called? I was asking because if this API is called upon every epoch, it does not seem very efficient as it returns all the epochs upon each call. Maybe a more efficient approach is to return recent epochs specified by a parameter and the caller can accumulate historical results.

@@ -21,6 +21,11 @@ service Query {
option (google.api.http).get = "/babylon/epoching/v1/epochs/{epoch_num=*}";
}

// EpochsInfo range-queries the information of epochs
Copy link
Contributor

Choose a reason for hiding this comment

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

imo range-query usually queries stuff in a range, which is specified by the parameter. But this API seems to return all the epoch information up to the latest.

Suggested change
// EpochsInfo range-queries the information of epochs
// EpochsInfo returns information of epochs from epoch 0 to the latest epoch

Copy link
Member Author

Choose a reason for hiding this comment

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

It's paginated so will only return a limited number of epochs, depending on the pagination request. The main use case would be querying the latest X epochs in time order. Updated the comments to reflect this 👍

@SebastianElvis
Copy link
Member Author

SebastianElvis commented Jan 24, 2023

Lgtm! Only a minor suggestion. One question about the usage of this API: what's the frequency of this API being called? I was asking because if this API is called upon every epoch, it does not seem very efficient as it returns all the epochs upon each call. Maybe a more efficient approach is to return recent epochs specified by a parameter and the caller can accumulate historical results.

It's called only once for the explorer's epochs page. Specifically, the API backend will call this API to get metadata of a number of epochs, then get corresponding BTC checkpoint and finalisation status of them.

@SebastianElvis SebastianElvis merged commit e9e8de0 into dev Jan 24, 2023
@SebastianElvis SebastianElvis deleted the epoching-epochs-range-query branch January 24, 2023 03:08
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.

2 participants