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(epochs): add wrapper of epoch getter #22068

Merged
merged 5 commits into from
Oct 4, 2024

Conversation

Narangde
Copy link

@Narangde Narangde commented Oct 3, 2024

Description

Closes: #22041

Added simple wrapper for getting epoch info by identifier in epochs module.


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, you can find examples of the prefixes below:
  • confirmed ! in 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
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • 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.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Documentation

    • Comprehensive updates to the x/epochs module documentation, clarifying functionality and structure.
    • Detailed descriptions of epochs, state management, events, and interaction with other modules.
    • Enhanced sections on panic isolation and available RPC queries for epoch information.
  • New Features

    • Introduced a method to retrieve epoch information by identifier.
    • Added hook functions for events at the start and end of epochs.
    • Implemented a query service for accessing current epoch details and epoch information.

Sorry, something went wrong.

@Narangde Narangde requested review from alpe, facundomedica and a team as code owners October 3, 2024 08:59
Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request focus on enhancing the documentation and functionality of the x/epochs module. Key updates include a comprehensive documentation overhaul that clarifies the module's purpose, the state management of epochs, event handling, and interaction with other modules. Additionally, a new GetEpochInfo method has been introduced in the Keeper struct to retrieve epoch information by identifier. The changes also include new hook function signatures and a query service for epoch-related queries.

Changes

File Path Change Summary
x/epochs/README.md Comprehensive documentation update for the x/epochs module, detailing functionality, state, events, keeper functions, hooks, and queries.
x/epochs/keeper/epoch.go Added GetEpochInfo method to the Keeper struct for retrieving epoch information by identifier; updated imports for sdk.Context.
tests/integration/tx/context_test.go Cleaned up duplicate import for require, maintaining existing test functionality.
tests/integration/tx/internal/util.go Integrated gogoproto package for improved message handling in SigningFixture methods.

Assessment against linked issues

Objective Addressed Explanation
Add GetEpochInfo to get Epoch Info by identifier (#22041)

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@Narangde Narangde force-pushed the feat/implement-get-epoch branch from ed386fa to 914ae57 Compare October 3, 2024 09:03
@Narangde
Copy link
Author

Narangde commented Oct 3, 2024

@julienrbrt This is the PR of adding simple wrapper for epoch getter.

@Narangde Narangde force-pushed the feat/implement-get-epoch branch from 914ae57 to 23805df Compare October 3, 2024 09:07
@Narangde Narangde force-pushed the feat/implement-get-epoch branch from 23805df to 3cca8e7 Compare October 3, 2024 09:10
@Narangde Narangde requested a review from julienrbrt October 3, 2024 09:11
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

ACK, thank you!

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Oct 3, 2024
@Narangde Narangde force-pushed the feat/implement-get-epoch branch from 3cca8e7 to 8000432 Compare October 3, 2024 09:25
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
x/epochs/keeper/epoch.go (1)

11-14: LGTM: The GetEpochInfo function is well-implemented.

The function signature and implementation are correct and align with the PR objectives. It follows Go conventions and the Uber Go Style Guide.

Consider adding a check for an empty identifier and returning a meaningful error in that case:

func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (types.EpochInfo, error) {
	if identifier == "" {
		return types.EpochInfo{}, fmt.Errorf("empty identifier provided")
	}
	return k.EpochInfo.Get(ctx, identifier)
}

This would improve error handling and make the function more robust.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 947ffe0 and 8000432f0a25a34c7d9d0a9004a200f23eb764a1.

📒 Files selected for processing (2)
  • x/epochs/README.md (0 hunks)
  • x/epochs/keeper/epoch.go (1 hunks)
💤 Files with no reviewable changes (1)
  • x/epochs/README.md
🧰 Additional context used
📓 Path-based instructions (1)
x/epochs/keeper/epoch.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

🔇 Additional comments (1)
x/epochs/keeper/epoch.go (1)

6-6: LGTM: Import statement is correct and necessary.

The import of the sdk package is required for the new GetEpochInfo function and follows the Uber Go Style Guide for third-party package imports.

@julienrbrt
Copy link
Member

Could you run make lint-fix btw?

@Narangde Narangde force-pushed the feat/implement-get-epoch branch from 8000432 to b648983 Compare October 3, 2024 13:35
Narangde and others added 3 commits October 3, 2024 23:26

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
tests/integration/tx/internal/util.go (2)

Line range hint 134-139: LGTM: Improved message name retrieval.

The change to use gogoproto.MessageName(msg) is a good improvement. It provides a more standard and reliable way to get the full name of a protobuf message, especially when dealing with gogo/protobuf messages.

Consider adding a comment explaining why this change was made, to provide context for future maintainers.

// Use gogoproto.MessageName to ensure compatibility with gogo/protobuf messages
typeName := gogoproto.MessageName(msg)

Line range hint 141-151: LGTM: Consistent use of gogoproto for marshaling.

The change to use gogoproto.Marshal(msg) is consistent with the previous change and improves compatibility with gogo/protobuf messages. The existing comment provides good context for the method's purpose.

For consistency with the MessageDescriptor method, consider adding a brief comment explaining the use of gogoproto.Marshal.

// Use gogoproto.Marshal to ensure compatibility with gogo/protobuf messages
protoBz, err := gogoproto.Marshal(msg)
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b648983 and 5b7a2ec.

📒 Files selected for processing (3)
  • tests/integration/tx/context_test.go (1 hunks)
  • tests/integration/tx/internal/util.go (1 hunks)
  • x/epochs/keeper/epoch.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/integration/tx/context_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • x/epochs/keeper/epoch.go
🧰 Additional context used
📓 Path-based instructions (1)
tests/integration/tx/internal/util.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

🔇 Additional comments (2)
tests/integration/tx/internal/util.go (2)

9-9: LGTM: Import statement added correctly.

The addition of the gogoproto import is appropriate and follows Go conventions. This import is necessary for the changes made in the MessageDescriptor and DynamicMessage methods.


Line range hint 1-232: Overall assessment: Improved protobuf compatibility in test utilities.

The changes in this file enhance the test utilities to work more effectively with gogo/protobuf messages. The consistent use of gogoproto for message name retrieval and marshaling improves compatibility and reliability when dealing with protobuf messages in tests.

These modifications align well with the PR objectives and contribute to a more robust testing framework for the epoch information retrieval functionality.

@tac0turtle tac0turtle added this pull request to the merge queue Oct 4, 2024
Merged via the queue into cosmos:main with commit dc14960 Oct 4, 2024
68 of 72 checks passed
mergify bot pushed a commit that referenced this pull request Oct 4, 2024
(cherry picked from commit dc14960)
julienrbrt added a commit that referenced this pull request Oct 4, 2024
Co-authored-by: Narangde <hansol.lee@storyprotocol.xyz>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@coderabbitai coderabbitai bot mentioned this pull request Oct 4, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:x/epochs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: add GetEpochInfo to get Epoch Info by identifier
7 participants