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: bugfix of LatestEpochMsgs API #140

Merged
merged 2 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proto/babylon/epoching/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ message QueryEpochMsgsResponse {
}

// QueryLatestEpochMsgsRequest is request type for the Query/LatestEpochMsgs RPC method
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// QueryLatestEpochMsgsRequest is request type for the Query/LatestEpochMsgs RPC method
// QueryLatestEpochMsgsRequest is the request type for the Query/LatestEpochMsgs RPC method

// it returns epoch msgs within epoch [min(1, end_epoch-epoch_count+1), end_epoch]
// it returns epoch msgs within epoch [max(1, end_epoch-epoch_count+1), end_epoch]
message QueryLatestEpochMsgsRequest {
// end_epoch is the number of the last epoch to query
uint64 end_epoch = 1;
Expand Down
13 changes: 6 additions & 7 deletions x/epoching/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,16 @@ func (k Keeper) LatestEpochMsgs(c context.Context, req *types.QueryLatestEpochMs
)
}

// the API will return epoch msgs between [min(1, end_epoch-epoch_count+1), end_epoch].
// NOTE:
// - epoch 0 does not have any queued msg
// - if not specified, endEpoch will be the current epoch
// the API will return epoch msgs between [max(1, end_epoch-epoch_count+1), end_epoch].
// NOTE: epoch 0 does not have any queued msg
endEpoch := req.EndEpoch
// If not specified, endEpoch will be the current epoch
if endEpoch == 0 {
endEpoch = k.GetEpoch(ctx).EpochNumber
}
beginEpoch := endEpoch - req.EpochCount + 1
if beginEpoch <= 1 {
beginEpoch = 1
beginEpoch := uint64(1)
if req.EpochCount < endEpoch { // i.e., 1 < endEpoch - req.EpochCount + 1
beginEpoch = endEpoch - req.EpochCount + 1
}

latestEpochMsgs := []*types.QueuedMessageList{}
Expand Down
2 changes: 1 addition & 1 deletion x/epoching/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.