Skip to content

Commit

Permalink
feat: query earliest attestation nonce (backport celestiaorg#2724) (c…
Browse files Browse the repository at this point in the history
…elestiaorg#2734)

This is an automatic backport of pull request celestiaorg#2724 done by
[Mergify](https://mergify.com).
Cherry-pick of a3e1da0 has failed:
```
On branch mergify/bp/v1.x/pr-2724
Your branch is up to date with 'origin/v1.x'.

You are currently cherry-picking commit a3e1da0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   app/test/qgb_rpc_test.go
	modified:   proto/celestia/qgb/v1/query.proto
	modified:   x/qgb/keeper/query_general.go
	modified:   x/qgb/types/query.pb.gw.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   x/qgb/types/query.pb.go

```


To fix up this pull request, you can check it out locally. See
documentation:
https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the
[documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on
`<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you
can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>

---------

Co-authored-by: CHAMI Rachid <[email protected]>
  • Loading branch information
mergify[bot] and rach-id authored Oct 20, 2023
1 parent c79fb45 commit ce375c7
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 66 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 @@ -50,6 +50,16 @@ func TestQGBRPCQueries(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 @@ -31,6 +31,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 @@ -93,6 +98,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/qgb/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 ce375c7

Please sign in to comment.