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(proto): Add proto messages for x/protocolpool Funds Handling #18427

Merged
merged 16 commits into from
Nov 14, 2023

Conversation

likhita-809
Copy link
Contributor

@likhita-809 likhita-809 commented Nov 10, 2023

Description

ref: #18374


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • New Features

    • Introduced new RPC methods for continuous fund management, including the ability to add funds, propose fund dispensation, and cancel fund proposals.
    • Expanded system capabilities to handle continuous fund operations and proposal management.
  • Documentation

    • Updated message field capitalization for consistency and clarity in communication protocols.
  • Refactor

    • Enhanced existing message types with additional fields such as percentage, cap, and expiry to support new functionality.

Copy link
Contributor

coderabbitai bot commented Nov 10, 2023

Walkthrough
<details>
<summary>Walkthrough</summary>

## Walkthrough

The updates expand the functionality of the system by introducing new RPC methods and message types to manage continuous funds. These changes enable the creation, funding, claiming, and cancellation of continuous funds, along with a proposal mechanism. Additionally, there's a minor update to the casing of fields in an existing message type.

## Changes

| File Path | Change Summary |
|-----------|----------------|
| `proto/cosmos/protocolpool/v1/tx.proto` | Introduced new RPC methods, message types, and updated field casing. |
| `x/protocolpool/keeper/msg_server.go` | Added new methods to handle continuous fund operations. |

</details>

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

@likhita-809 likhita-809 marked this pull request as ready for review November 10, 2023 10:04
@likhita-809 likhita-809 requested a review from a team as a code owner November 10, 2023 10:04
@github-prbot github-prbot requested review from a team, facundomedica and testinginprod and removed request for a team November 10, 2023 10:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7208905 and b71a0f6.
Files ignored due to filter (2)
  • api/cosmos/protocolpool/v1/tx_grpc.pb.go
  • x/protocolpool/types/tx.pb.go
Files selected for processing (2)
  • proto/cosmos/protocolpool/v1/tx.proto (2 hunks)
  • x/protocolpool/keeper/msg_server.go (1 hunks)
Additional comments: 4
proto/cosmos/protocolpool/v1/tx.proto (4)
  • 29-41: The new RPC methods AddContinuousFunds, FundDispensationProposal, and CancelContinuousFundProposal have been added to the Msg service. Ensure that these methods are implemented in the MsgServer struct in x/protocolpool/keeper/msg_server.go.

  • 114-136: The MsgAddContinuousFunds message has been defined with fields for title, description, recipient address, metadata, percentage, and expiry. Ensure that the percentage field is validated to be within the range of 0 to 100.

  • 142-154: The MsgFundDispensationProposal message has been defined with fields for authority, recipient address, percentage, cap, and expiration. Ensure that the percentage field is validated to be within the range of 0 to 100.

  • 160-168: The MsgCancelContinuousFundProposal message has been defined with fields for authority and recipient address. Ensure that the recipient address is validated to exist in the list of continuous fund recipients.

x/protocolpool/keeper/msg_server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 your pull request is missing a changelog!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b71a0f6 and 385562b.
Files ignored due to filter (2)
  • api/cosmos/protocolpool/v1/tx_grpc.pb.go
  • x/protocolpool/types/tx.pb.go
Files selected for processing (1)
  • proto/cosmos/protocolpool/v1/tx.proto (2 hunks)
Additional comments: 2
proto/cosmos/protocolpool/v1/tx.proto (2)
  • 29-38: The new RPC methods AddContinuousFunds and CancelContinuousFundProposal are added correctly to the Msg service. Ensure that these methods are implemented in the corresponding server code.

  • 155-160: The MsgCancelContinuousFundProposalResponse message is well defined. The canceled_time and canceled_height fields provide useful information about when and at what block height the cancellation occurred.

proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 385562b and 08cab60.
Files selected for processing (1)
  • x/protocolpool/keeper/msg_server.go (1 hunks)

x/protocolpool/keeper/msg_server.go Outdated Show resolved Hide resolved
proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
proto/cosmos/protocolpool/v1/tx.proto Show resolved Hide resolved
proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Thanks @likhita-809! Just some comments that we should capitalize the field names in the comments so that they'll match the generated field names.

proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 08cab60 and 340db83.
Files ignored due to filter (2)
  • api/cosmos/protocolpool/v1/tx_grpc.pb.go
  • x/protocolpool/types/tx.pb.go
Files selected for processing (1)
  • proto/cosmos/protocolpool/v1/tx.proto (4 hunks)
Additional comments: 3
proto/cosmos/protocolpool/v1/tx.proto (3)
  • 34-38: The method names CreateContinuousFund and CancelContinuousFundProposal are repeated in the comments, which might be a copy-paste error. Verify if the second method should be FundDispensationProposal as per the summary provided.

  • 152-152: The concern raised by anilCSE about not being able to have two funds streaming for the same address at a time is addressed by tac0turtle, stating that this is expected behavior. However, it's important to ensure that this limitation is clearly documented and understood by users of the protocol to avoid confusion.

  • 157-163: The response message MsgCancelContinuousFundProposalResponse includes a recipient_address field (line 163). This aligns with anilCSE's suggestion to include fund details in the response. Ensure that the implementation of the server-side logic populates this field correctly.

proto/cosmos/protocolpool/v1/tx.proto Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 340db83 and 7b3fbd9.
Files selected for processing (1)
  • x/protocolpool/keeper/msg_server.go (1 hunks)
Additional comments: 3
x/protocolpool/keeper/msg_server.go (3)
  • 106-107: The CreateContinuousFund function currently returns an empty response without performing any operations. This should be implemented to handle the creation of continuous funds as described in the pull request summary.

  • 110-111: Similarly, the CancelContinuousFundProposal function returns an empty response without any logic. This function should be implemented to handle the cancellation of continuous fund proposals.

  • 114-116: The validateAuthority function checks if the provided authority address is valid and matches the expected authority. This is a good security practice to ensure that only authorized entities can perform certain actions.

The rest of the code in the provided hunk seems to be handling various other fund-related operations and includes proper validation and error handling.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7b3fbd9 and 6d3fe1e.
Files ignored due to filter (1)
  • x/protocolpool/types/tx.pb.go
Files selected for processing (1)
  • proto/cosmos/protocolpool/v1/tx.proto (4 hunks)
Additional comments: 5
proto/cosmos/protocolpool/v1/tx.proto (5)
  • 29-38: The addition of CreateContinuousFund and CancelContinuousFundProposal RPC methods expands the functionality of the protocol pool module. Ensure that corresponding server-side implementations and client-side usage are updated to handle these new methods.

  • 111-138: The MsgCreateContinuousFund message is well-defined with clear fields for title, description, authority, recipient, metadata, percentage, cap, and expiry. The use of cosmossdk.io/math.LegacyDec for the percentage field is appropriate for representing decimal values. Ensure that the handling of this custom type is consistent across the system.

  • 145-163: The MsgCancelContinuousFundProposal message includes necessary fields for cancellation such as authority and recipient_address. The response message includes a timestamp and block height which are good for tracking the cancellation event. Ensure that the cancellation logic is robust and handles edge cases, such as attempting to cancel a non-existent or already completed fund.

  • 152-152: The previous comment by anilCSE suggests that there should be a unique key for each fund to allow for individual fund management. The response by tac0turtle indicates that this is not necessary as the design expects one fund stream per address. This design decision should be clearly documented and communicated to users to avoid confusion.

  • 157-157: The suggestion by anilCSE to add fund details to the response message is valid. Including the recipient_address in the MsgCancelContinuousFundProposalResponse message would provide clarity on which fund was cancelled. This could be considered for future iterations if it aligns with the design goals.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6d3fe1e and 2d958e3.
Files ignored due to filter (2)
  • api/cosmos/protocolpool/v1/tx_grpc.pb.go
  • x/protocolpool/types/tx.pb.go
Files selected for processing (1)
  • proto/cosmos/protocolpool/v1/tx.proto (4 hunks)
Additional comments: 2
proto/cosmos/protocolpool/v1/tx.proto (2)
  • 29-38: The addition of CreateContinuousFund and CancelContinuousFund RPC methods is a significant enhancement to the protocol pool functionality. Ensure that corresponding backend logic and validation are implemented to handle these new requests.

  • 111-137: The MsgCreateContinuousFund message includes a comprehensive set of fields for fund management. Ensure that the percentage field is correctly handled as a decimal and that the cap and expiry fields are validated to prevent misuse or errors in fund creation.

proto/cosmos/protocolpool/v1/tx.proto Show resolved Hide resolved
proto/cosmos/protocolpool/v1/tx.proto Show resolved Hide resolved
x/protocolpool/keeper/msg_server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2d958e3 and 21eb88a.
Files selected for processing (1)
  • x/protocolpool/keeper/msg_server.go (1 hunks)
Additional comments: 1
x/protocolpool/keeper/msg_server.go (1)
  • 114-116: The validateAuthority function checks if the provided authority address is valid but does not seem to check if the authority has the required permissions to perform the action. Ensure that the necessary permission checks are in place.

The check against k.authority in the subsequent lines (not shown in the hunk) should be reviewed to ensure that k.authority is being set correctly elsewhere in the code, as it is being used to validate the authority here.

x/protocolpool/keeper/msg_server.go Show resolved Hide resolved
x/protocolpool/keeper/msg_server.go Show resolved Hide resolved
@tac0turtle tac0turtle added this pull request to the merge queue Nov 14, 2023
Merged via the queue into main with commit e269c6d Nov 14, 2023
64 of 65 checks passed
@tac0turtle tac0turtle deleted the likhita/18374-proto branch November 14, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants