Skip to content

Commit

Permalink
feat: query earliest attestation nonce (#2724)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

So that the orchestartor is able to query the earliest attestation nonce
and sign up to it.

This change is not breaking and is just adding a new API endpoint.

PS: I originally thought that this was already implemented. But sadly,
we didn't.

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords

---------

Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
rach-id and rootulp authored Oct 20, 2023
1 parent fc348bf commit a3e1da0
Show file tree
Hide file tree
Showing 5 changed files with 476 additions and 65 deletions.
10 changes: 10 additions & 0 deletions app/test/qgb_rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ func TestBlobstreamRPCQueries(t *testing.T) {
return err
},
},
{
name: "earliest attestation nonce",
req: func() error {
_, err := queryClient.EarliestAttestationNonce(
context.Background(),
&types.QueryEarliestAttestationNonceRequest{},
)
return err
},
},
{
name: "data commitment range for height",
req: func() error {
Expand Down
10 changes: 10 additions & 0 deletions proto/celestia/qgb/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ service Query {
returns (QueryLatestAttestationNonceResponse) {
option (google.api.http).get = "/qgb/v1/attestations/nonce/latest";
}
// EarliestAttestationNonce queries the earliest attestation nonce.
rpc EarliestAttestationNonce(QueryEarliestAttestationNonceRequest)
returns (QueryEarliestAttestationNonceResponse) {
option (google.api.http).get = "/qgb/v1/attestations/nonce/earliest";
}
// LatestValsetRequestBeforeNonce Queries latest Valset request before nonce.
// And, even if the current nonce is a valset, it will return the previous
// one.
Expand Down Expand Up @@ -92,6 +97,11 @@ message QueryLatestAttestationNonceRequest {}
// QueryLatestAttestationNonceResponse latest attestation nonce response
message QueryLatestAttestationNonceResponse { uint64 nonce = 1; }

// QueryEarliestAttestationNonceRequest earliest attestation nonce request
message QueryEarliestAttestationNonceRequest {}
// QueryEarliestAttestationNonceResponse earliest attestation nonce response
message QueryEarliestAttestationNonceResponse { uint64 nonce = 1; }

// QueryLatestValsetRequestBeforeNonceRequest latest Valset request before
// universal nonce request
message QueryLatestValsetRequestBeforeNonceRequest { uint64 nonce = 1; }
Expand Down
10 changes: 10 additions & 0 deletions x/blobstream/keeper/query_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ func (k Keeper) LatestUnbondingHeight(
}, nil
}

// EarliestAttestationNonce queries the earliest attestation nonce.
func (k Keeper) EarliestAttestationNonce(
c context.Context,
_ *types.QueryEarliestAttestationNonceRequest,
) (*types.QueryEarliestAttestationNonceResponse, error) {
return &types.QueryEarliestAttestationNonceResponse{
Nonce: k.GetEarliestAvailableAttestationNonce(sdk.UnwrapSDKContext(c)),
}, nil
}

func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
params := k.GetParams(sdk.UnwrapSDKContext(c))
return &types.QueryParamsResponse{
Expand Down
Loading

0 comments on commit a3e1da0

Please sign in to comment.