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

chore: align events naming #199

Merged
merged 4 commits into from
Jun 12, 2024
Merged

chore: align events naming #199

merged 4 commits into from
Jun 12, 2024

Conversation

mbreithecker
Copy link
Member

@mbreithecker mbreithecker commented Jun 12, 2024

Summary by CodeRabbit

  • Refactor

    • Simplified various event messages by converting repeated fields to singular string fields for easier handling and consistency.
  • Documentation

    • Updated event documentation to reflect changes in field types and new field additions.
  • Chores

    • Removed unnecessary imports to streamline and optimize codebase.

Copy link

coderabbitai bot commented Jun 12, 2024

Warning

Rate limit exceeded

@mbreithecker has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 37 minutes and 16 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between f1d95f6 and fa8cd5b.

Walkthrough

The changes primarily involve converting repeated fields and structured data types to simple string fields across various protocol buffer files and related Go logic. This simplification affects event messages and field assignments in multiple modules, including bundles, delegation, funders, and stakers. The goal is to streamline data handling and improve code maintainability by using string representations instead of complex types.

Changes

Files/Paths Change Summary
proto/kyve/bundles/v1beta1/events.proto Replaced repeated fields with string fields for various payout and reward fields.
proto/kyve/delegation/v1beta1/events.proto Removed imports and changed EventWithdrawRewards field to a string.
proto/kyve/funders/v1beta1/events.proto Simplified amounts and amounts_per_bundle fields to strings.
proto/kyve/stakers/v1beta1/events.proto Removed imports and changed EventClaimCommissionRewards field to a string.
x/bundles/keeper/logic_bundles.go Converted struct fields to strings in finalizeCurrentBundleProposal function.
x/bundles/spec/06_events.md Converted numeric fields to strings and added new fields in EventBundleFinalized message.
x/delegation/keeper/logic_delegation.go Changed Amount field to Amounts and assigned string representation in performWithdrawal.
x/delegation/spec/05_events.md Renamed and converted amount field to amounts in EventWithdrawRewards message.
x/funders/keeper/logic_funders.go Accessed Amounts field as a string in ensureFreeSlot function.
x/funders/keeper/msg_server_defund_pool.go Changed Amounts field assignment to string in DefundPool function.
x/funders/keeper/msg_server_fund_pool.go Converted Amounts and AmountsPerBundle fields to strings in FundPool function.
x/funders/spec/05_events.md Converted repeated fields to singular string fields in EventFundPool and EventDefundPool.
x/stakers/keeper/msg_server_claim_commission_rewards.go Changed Amount field to Amounts and converted to string in ClaimCommissionRewards function.
x/stakers/spec/05_events.md Replaced repeated field with a singular string field in EventClaimCommissionRewards message.

Poem

In the land of code, a change so bright,
Strings replace the fields, a simpler sight.
From bundles to stakers, the updates flow,
Easier paths for data to go.
With every line, a cleaner way,
Hopping through code, we cheer today! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@troykessler troykessler left a comment

Choose a reason for hiding this comment

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

Also please change amount to amounts in proto/kyve/stakers/v1beta1/tx.proto MsgClaimCommissionRewards

x/bundles/keeper/logic_bundles.go Outdated Show resolved Hide resolved
Copy link

@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.

Actionable comments posted: 1

Outside diff range and nitpick comments (2)
x/bundles/spec/06_events.md (1)

Line range hint 243-243: Remove the extra blank line to adhere to Markdown best practices.

- 
x/bundles/keeper/logic_bundles.go (1)

Line range hint 238-238: Consider refactoring the calculatePayouts and tallyBundleProposal functions to reduce their complexity and improve maintainability.

- // Consider breaking down this function into smaller, more manageable functions.
- // Consider breaking down this function into smaller, more manageable functions.

Also applies to: 566-566

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c27d840 and f1d95f6.

Files ignored due to path filters (4)
  • x/bundles/types/events.pb.go is excluded by !**/*.pb.go
  • x/delegation/types/events.pb.go is excluded by !**/*.pb.go
  • x/funders/types/events.pb.go is excluded by !**/*.pb.go
  • x/stakers/types/events.pb.go is excluded by !**/*.pb.go
Files selected for processing (14)
  • proto/kyve/bundles/v1beta1/events.proto (2 hunks)
  • proto/kyve/delegation/v1beta1/events.proto (2 hunks)
  • proto/kyve/funders/v1beta1/events.proto (3 hunks)
  • proto/kyve/stakers/v1beta1/events.proto (2 hunks)
  • x/bundles/keeper/logic_bundles.go (1 hunks)
  • x/bundles/spec/06_events.md (1 hunks)
  • x/delegation/keeper/logic_delegation.go (1 hunks)
  • x/delegation/spec/05_events.md (1 hunks)
  • x/funders/keeper/logic_funders.go (1 hunks)
  • x/funders/keeper/msg_server_defund_pool.go (1 hunks)
  • x/funders/keeper/msg_server_fund_pool.go (1 hunks)
  • x/funders/spec/05_events.md (2 hunks)
  • x/stakers/keeper/msg_server_claim_commission_rewards.go (1 hunks)
  • x/stakers/spec/05_events.md (1 hunks)
Files skipped from review due to trivial changes (3)
  • proto/kyve/delegation/v1beta1/events.proto
  • proto/kyve/stakers/v1beta1/events.proto
  • x/delegation/spec/05_events.md
Additional context used
Markdownlint
x/stakers/spec/05_events.md

153-153: null (MD047, single-trailing-newline)
Files should end with a single newline character

x/bundles/spec/06_events.md

243-243: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines

golangci-lint
x/bundles/keeper/logic_bundles.go

238-238: Function 'calculatePayouts' is too long (88 > 60) (funlen)


566-566: Function 'tallyBundleProposal' is too long (87 > 60) (funlen)

Additional comments not posted (10)
x/stakers/keeper/msg_server_claim_commission_rewards.go (1)

39-40: The change to use string representation for amounts aligns with the PR objectives. Ensure the string conversion handles all edge cases correctly.

x/funders/keeper/msg_server_defund_pool.go (1)

64-64: The change to use string representation for amounts aligns with the PR objectives. Ensure the string conversion handles all edge cases correctly.

x/funders/spec/05_events.md (1)

76-78: The documentation updates accurately reflect the changes to the event structures. Ensure that the documentation is clear and accessible to developers.

Also applies to: 99-99

proto/kyve/funders/v1beta1/events.proto (1)

63-65: The changes to use string fields for amounts are correctly implemented in the proto definitions. Ensure that these changes are reflected correctly in all related systems.

Also applies to: 76-76

Verification successful

The changes to use string fields for amounts and amounts_per_bundle are correctly implemented in the proto definitions and are reflected in multiple files. Ensure that these changes are correctly integrated into all related systems.

  • Instances found:
    • string amounts = 2;
    • string amounts = 3;
    • string amounts_per_bundle = 4;
    • string amounts = 3;
    • string amounts = 3;
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the proto definitions are correctly implemented in all related systems.

# Test: Search for the proto usage. Expect: Only occurances of the new definitions.
rg --type proto $'string amounts'

Length of output: 64



Script:

#!/bin/bash
# Description: Verify that the proto definitions are correctly implemented in all related systems.

# Find all .proto files and search for the new definitions
fd -e proto -x rg 'string amounts' {}

Length of output: 162

x/delegation/keeper/logic_delegation.go (1)

76-76: The conversion of reward to a string in the EventWithdrawRewards is consistent with the PR's objective. Ensure that the reward.String() method correctly formats the data as expected in all contexts where it's used.

x/stakers/spec/05_events.md (1)

102-102: The update to the amounts field in the EventClaimCommissionRewards documentation reflects the changes made in the codebase. This should help maintain clarity and consistency in the documentation.

proto/kyve/bundles/v1beta1/events.proto (1)

91-113: The conversion of various reward fields to string types in the EventBundleFinalized message aligns with the PR's objective to simplify data structures. This should make the data easier to handle and potentially improve performance. Ensure that all systems consuming these events can correctly parse and handle the string data.

Verification successful

The search results indicate that EventBundleFinalized is referenced in several files. To ensure that the changes to the protobuf definitions are correctly handled, we need to review the relevant sections of the code.

  • x/bundles/keeper/logic_bundles.go
  • x/bundles/types/events.pb.go

Let's verify if the string fields in EventBundleFinalized are correctly parsed and handled in these files.


The search results show that the EventBundleFinalized event is correctly referenced and handled in the codebase, particularly in x/bundles/keeper/logic_bundles.go and x/bundles/types/events.pb.go. The fields that were changed to string types are being correctly parsed and handled.

  • In x/bundles/keeper/logic_bundles.go, the fields like FundersPayout, RewardTreasury, and others are being set as strings.
  • In x/bundles/types/events.pb.go, the getters for these fields return string values, ensuring that the changes are consistent.

This confirms that the changes to the protobuf definitions are correctly implemented and handled in the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all systems consuming `EventBundleFinalized` can correctly parse and handle string data.

# Test: Search for event consumption. Expect: Correct parsing and handling of string data.
rg --type proto $'EventBundleFinalized'

Length of output: 68



Script:

#!/bin/bash
# Description: Verify that all systems consuming `EventBundleFinalized` can correctly parse and handle string data.

# Test: Search for event consumption. Expect: Correct parsing and handling of string data.
rg 'EventBundleFinalized'

Length of output: 4400



Script:

#!/bin/bash
# Description: Verify that the changes to `EventBundleFinalized` are correctly handled in the code.

# Test: Review the relevant sections of `x/bundles/keeper/logic_bundles.go` and `x/bundles/types/events.pb.go`.

# Extract relevant lines from `x/bundles/keeper/logic_bundles.go`
rg -A 10 -B 10 'EventBundleFinalized' x/bundles/keeper/logic_bundles.go

# Extract relevant lines from `x/bundles/types/events.pb.go`
rg -A 10 -B 10 'EventBundleFinalized' x/bundles/types/events.pb.go

Length of output: 10377

x/bundles/spec/06_events.md (1)

97-120: The conversion of numeric fields to strings in EventBundleFinalized is consistent with the PR's objective to simplify data structures. Ensure that all systems consuming these events can handle string types for these fields.

x/funders/keeper/logic_funders.go (1)

234-234: The conversion of Amounts to a string in the EventDefundPool is consistent with the PR's objective. Ensure that all systems consuming this event can handle string types for the Amounts field.

x/bundles/keeper/logic_bundles.go (1)

422-428: The conversion of various reward fields to strings in EventBundleFinalized is consistent with the PR's objective. Ensure that all systems consuming this event can handle string types for these fields.

x/funders/keeper/msg_server_fund_pool.go Show resolved Hide resolved
@mbreithecker mbreithecker changed the title chore: align event naming chore: align events naming Jun 12, 2024
@mbreithecker mbreithecker merged commit 78890ff into main Jun 12, 2024
5 checks passed
@mbreithecker mbreithecker deleted the mbreithecker/fixup-events branch June 12, 2024 08:20
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.

2 participants