Skip to content

PSE Allocation Schedule Query#28

Merged
TxCorpi0x merged 8 commits into
masterfrom
mehdi/pse-query-allocation-schedule
Nov 24, 2025
Merged

PSE Allocation Schedule Query#28
TxCorpi0x merged 8 commits into
masterfrom
mehdi/pse-query-allocation-schedule

Conversation

@TxCorpi0x

@TxCorpi0x TxCorpi0x commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Description

This pull request introduces a new gRPC query endpoint for retrieving all future allocation schedules in the PSE module. The changes add protocol definitions, server and client implementations, documentation, and comprehensive tests to ensure the schedules are correctly returned and sorted.

API additions

  • Added new gRPC query AllocationSchedule to the service definition in query.proto, including its request and response messages. The response contains all future distribution schedules sorted by timestamp.
  • Updated API documentation (docs/api.md) to describe the new request/response types and the REST endpoint /tx/pse/v1/allocation_schedule.

Server and client implementation

  • Implemented the AllocationSchedule query handler in the keeper (x/pse/keeper/grpc.go), which returns all future schedules using the keeper's GetAllocationSchedule method.
  • Added gateway and handler logic in query.pb.gw.go to support both server-side and client-side HTTP requests for the new endpoint.

Testing

  • Introduced extensive tests for the new query in grpc_query_test.go, covering empty schedules, multiple schedules, multiple allocations, and correct sorting by timestamp.

Internal documentation

  • Clarified in the keeper and proto comments that only future schedules are returned (past schedules are removed after processing).

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@TxCorpi0x TxCorpi0x requested review from a team, masihyeganeh, miladz68 and ysv and removed request for a team November 17, 2025 15:05
@TxCorpi0x TxCorpi0x requested a review from a team as a code owner November 17, 2025 15:05
Copilot AI review requested due to automatic review settings November 17, 2025 15:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new gRPC query endpoint AllocationSchedule to the PSE module that allows clients to retrieve all future allocation schedules sorted by timestamp. The implementation includes protocol buffer definitions, server/client implementations, comprehensive tests, and updated documentation.

  • Added gRPC query AllocationSchedule with request/response types to retrieve future distribution schedules
  • Implemented query handler that returns sorted schedules using the existing keeper method GetAllocationSchedule
  • Added extensive test coverage for empty schedules, multiple schedules, multiple allocations, and timestamp sorting

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
proto/tx/pse/v1/query.proto Defines new QueryAllocationScheduleRequest and QueryAllocationScheduleResponse messages and adds RPC endpoint
x/pse/types/query.pb.go Auto-generated protobuf Go code for new query types, client/server interfaces, and marshaling logic
x/pse/types/query.pb.gw.go Auto-generated gRPC-gateway HTTP handlers for the new query endpoint
x/pse/keeper/grpc.go Implements AllocationSchedule query handler that returns schedules from keeper
x/pse/keeper/distribution.go Adds documentation comment clarifying that only future schedules are returned
x/pse/keeper/grpc_query_test.go Adds comprehensive tests covering empty schedules, multiple schedules, allocations, and sorting
docs/api.md Updates API documentation with new query request/response types and REST endpoint

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ysv reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @miladz68)


proto/tx/pse/v1/query.proto line 70 at r1 (raw file):

  // schedules contains all future distribution schedules sorted by timestamp in ascending order.
  // Past schedules are automatically removed after processing, so all returned schedules are future schedules.
  repeated ScheduledDistribution schedules = 1 [

I think it should be schedule (singular).
I

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh, @miladz68, and @ysv)


proto/tx/pse/v1/query.proto line 70 at r1 (raw file):

Previously, ysv (Yaroslav Savchuk) wrote…

I think it should be schedule (singular).
I

Done

ysv
ysv previously approved these changes Nov 18, 2025

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ysv reviewed 5 of 5 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh and @miladz68)

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@miladz68 reviewed 2 of 7 files at r1, 4 of 5 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @masihyeganeh)


proto/tx/pse/v1/query.proto line 68 at r2 (raw file):

// QueryAllocationScheduleResponse defines the response type for querying future allocation schedules.
message QueryAllocationScheduleResponse {
  // schedules contains all future distribution schedules sorted by timestamp in ascending order.

plural is left in the comment.


proto/tx/pse/v1/query.proto line 72 at r2 (raw file):

  repeated ScheduledDistribution schedule = 1 [
    (gogoproto.nullable) = false,
    (gogoproto.moretags) = "yaml:\"schedules\""

plural is left in yaml.

@TxCorpi0x TxCorpi0x force-pushed the mehdi/pse-query-allocation-schedule branch from fbe93a5 to 28e38e0 Compare November 19, 2025 06:52

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewable status: 1 of 7 files reviewed, 2 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @ysv)


proto/tx/pse/v1/query.proto line 68 at r2 (raw file):

Previously, miladz68 (milad) wrote…

plural is left in the comment.

Done


proto/tx/pse/v1/query.proto line 72 at r2 (raw file):

Previously, miladz68 (milad) wrote…

plural is left in yaml.

Done

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ysv The suggested renaming comments in the query (in other PR) has been addressed here

Reviewable status: 0 of 11 files reviewed, 2 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @ysv)

miladz68
miladz68 previously approved these changes Nov 19, 2025

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@miladz68 reviewed 11 of 11 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

ysv
ysv previously approved these changes Nov 19, 2025

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ysv reviewed 11 of 11 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@TxCorpi0x TxCorpi0x dismissed stale reviews from ysv and miladz68 via 3e1924d November 20, 2025 07:36

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@miladz68 reviewed 10 of 10 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh)


proto/tx/pse/v1/query.proto line 29 at r5 (raw file):

  // ScheduledDistributions queries all future scheduled distributions.
  rpc ScheduledDistributions(QueryScheduledDistributionsRequest) returns (QueryScheduledDistributionsResponse) {
    option (cosmos.query.v1.module_query_safe) = true;

can we remove the safe query, just as a pre-caution ?

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @miladz68)


proto/tx/pse/v1/query.proto line 29 at r5 (raw file):

Previously, miladz68 (milad) wrote…

can we remove the safe query, just as a pre-caution ?

Don't we need it to be queried cross-module? Or from Wasm smart contracts?

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewable status: 9 of 11 files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @miladz68)


proto/tx/pse/v1/query.proto line 29 at r5 (raw file):

Previously, TxCorpi0x wrote…

Don't we need it to be queried cross-module? Or from Wasm smart contracts?

As decided in the call, it has been removed

@miladz68 miladz68 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@miladz68 reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ysv reviewed 8 of 10 files at r5, 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)

@TxCorpi0x TxCorpi0x merged commit 3f99e64 into master Nov 24, 2025
9 checks passed
@ysv ysv deleted the mehdi/pse-query-allocation-schedule branch December 19, 2025 14:40
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.

4 participants