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: query earliest attestation nonce #2724

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
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";
Copy link
Collaborator

Choose a reason for hiding this comment

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

[question] did the rename PR not include a rename to the endpoint?

I would expect /blockstream/v1 and not `/qgb/v1/

Copy link
Member Author

Choose a reason for hiding this comment

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

that would be breaking, we wanted to keep that until v2

Copy link
Member

Choose a reason for hiding this comment

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

to clarify the smallest bit, we want to add the consensus breaking things, but we first need the infra to be able to test the upgrade/migrations

Also, if we don't already have an issue for that, can we get one?

Copy link
Member Author

Choose a reason for hiding this comment

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

}
// 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
Loading