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: remove todo: "abstract out staking message back to staking" #21266

Merged
merged 7 commits into from
Aug 14, 2024

Conversation

zenzenless
Copy link
Contributor

@zenzenless zenzenless commented Aug 13, 2024

Description

this pr removes a todo on CollectTx. It abstract out staking message back to staking


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

  • New Features

    • Introduced a new interface that enhances transaction types with a timeout timestamp, improving transaction management.
    • Added a method to retrieve the validator's moniker in the staking module, aiding in display and validation processes.
  • Bug Fixes

    • Simplified transaction message handling by removing specific dependencies on staking types, resulting in improved processing capabilities.

@zenzenless zenzenless requested a review from a team as a code owner August 13, 2024 09:57
Copy link
Contributor

coderabbitai bot commented Aug 13, 2024

Walkthrough

Walkthrough

The recent changes enhance transaction handling and message processing within the codebase. A new interface TxWithTimeoutTimeStamp has been introduced to allow transactions to specify timeout timestamps, improving transaction management. Additionally, the msgWithMoniker interface has been added, allowing more flexible message handling by decoupling it from specific staking types. Moreover, a new method GetMoniker was added to the MsgCreateValidator struct, facilitating easier access to validator monikers.

Changes

Files Change Summary
types/tx_msg.go Introduced TxWithTimeoutTimeStamp interface, enhancing transaction management by allowing timeout timestamps.
x/genutil/collect.go Added msgWithMoniker interface for flexible message handling, replacing direct dependencies on staking types.
x/staking/types/msg.go Added GetMoniker method to MsgCreateValidator struct to retrieve the validator's moniker, improving access and utility.

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

types/tx_msg.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added C:x/staking C:x/genutil genutil module issues labels Aug 13, 2024
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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 431b523 and 02dd6fd.

Files selected for processing (3)
  • types/tx_msg.go (1 hunks)
  • x/genutil/collect.go (2 hunks)
  • x/staking/types/msg.go (1 hunks)
Additional context used
Path-based instructions (3)
x/genutil/collect.go (1)

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

types/tx_msg.go (1)

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

x/staking/types/msg.go (1)

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

Additional comments not posted (3)
x/genutil/collect.go (1)

122-125: Verify all messages implement sdk.MsgWithMoniker.

The code assumes that all messages in the transaction implement the sdk.MsgWithMoniker interface. Ensure that this assumption holds true, as a failed type assertion will cause a runtime panic.

types/tx_msg.go (1)

83-87: Addition of MsgWithMoniker interface is approved.

The new interface MsgWithMoniker extends Msg with a GetMoniker() method, providing a useful abstraction for messages that include a moniker.

x/staking/types/msg.go (1)

93-96: Addition of GetMoniker method is approved.

The new GetMoniker method in MsgCreateValidator provides direct access to the validator's moniker, enhancing its utility and aligning with the MsgWithMoniker interface.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Aug 13, 2024
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: 1

Outside diff range, codebase verification and nitpick comments (1)
types/tx_msg.go (1)

83-83: File is not gci-ed.

The file is not formatted with gci, which is a tool for sorting and formatting imports according to the specified order.

Consider running gci to format the imports.

# Example command to format imports
gci write --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) types/tx_msg.go
Tools
golangci-lint

83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 02dd6fd and 75b339c.

Files selected for processing (2)
  • types/tx_msg.go (1 hunks)
  • x/genutil/collect.go (3 hunks)
Additional context used
Path-based instructions (2)
x/genutil/collect.go (1)

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

types/tx_msg.go (1)

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

golangci-lint
types/tx_msg.go

83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

Additional comments not posted (2)
x/genutil/collect.go (1)

122-125: Ensure type assertion safety.

The type assertion msg := msgs[0].(MsgWithMoniker) assumes that every message in msgs implements MsgWithMoniker. This could lead to a runtime panic if the assumption is incorrect.

Consider adding a type assertion check to handle cases where the assertion might fail.

-		msg := msgs[0].(MsgWithMoniker)
+		msg, ok := msgs[0].(MsgWithMoniker)
+		if !ok {
+			return appGenTxs, persistentPeers, fmt.Errorf("expected MsgWithMoniker, got %T", msgs[0])
+		}
types/tx_msg.go (1)

Line range hint 83-91:
Ensure interface consistency.

The TxWithTimeoutTimeStamp interface introduces a method GetTimeoutTimeStamp(). Ensure that all implementations of this interface are updated to include this method.

Check if there are existing implementations of the Tx interface that need to be updated.

Tools
golangci-lint

83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

x/genutil/collect.go Outdated Show resolved Hide resolved
zenzenless and others added 2 commits August 14, 2024 14:11
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 1

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75b339c and a58560b.

Files selected for processing (1)
  • x/genutil/collect.go (3 hunks)
Additional context used
Path-based instructions (1)
x/genutil/collect.go (1)

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

Additional comments not posted (1)
x/genutil/collect.go (1)

136-139: Adherence to best practices: Unexported interface.

The msgWithMoniker interface is unexported, aligning with best practices for encapsulation when the interface is only used within this package.

x/genutil/collect.go Outdated Show resolved Hide resolved
@zenzenless
Copy link
Contributor Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits

Files that changed from the base of the PR and between 67ed23b and e5a887d.

Files selected for processing (3)
  • types/tx_msg.go (1 hunks)
  • x/genutil/collect.go (3 hunks)
  • x/staking/types/msg.go (1 hunks)
_____________________________________________________________________________________________________________
< Abstraction is not about vagueness, it is about being precise at a new semantic level. - Edsger W. Dijkstra >
-------------------------------------------------------------------------------------------------------------
 \
  \   (\__/)
      (•ㅅ•)
      /   づ

Tip

CodeRabbit can enforce grammar and style rules using `languagetool`.

Configure languagetool in your project's settings in CodeRabbit enable/disable rules and categories. Refer to the LanguageTool Community to learn more.


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 Configuration 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
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, codebase verification and nitpick comments (1)
types/tx_msg.go (1)

83-83: LGTM! Interface TxWithTimeoutTimeStamp is correctly defined.

The TxWithTimeoutTimeStamp interface extends the Tx interface with a timeout timestamp capability, enhancing transaction management.

Consider ordering imports according to gci standards.

The static analysis tool suggests the file is not ordered according to gci standards. Consider using gci to order the imports.

# Command to order imports using gci
gci -w --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) types/tx_msg.go
Tools
golangci-lint

83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 67ed23b and e5a887d.

Files selected for processing (3)
  • types/tx_msg.go (1 hunks)
  • x/genutil/collect.go (3 hunks)
  • x/staking/types/msg.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/staking/types/msg.go
Additional context used
Path-based instructions (2)
x/genutil/collect.go (1)

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

types/tx_msg.go (1)

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

golangci-lint
types/tx_msg.go

83-83: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

Additional comments not posted (2)
x/genutil/collect.go (2)

122-125: LGTM! Type assertion with a check is used correctly.

The type assertion for msgWithMoniker is handled properly, preventing potential runtime panics.


138-141: LGTM! Interface msgWithMoniker is correctly defined and unexported.

The msgWithMoniker interface is properly defined with the GetMoniker() method and is unexported as suggested in previous reviews.

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.

Great! Thanks!

You'll need to run make lint-fix.

@julienrbrt julienrbrt added this pull request to the merge queue Aug 14, 2024
Merged via the queue into cosmos:main with commit ec17e1e Aug 14, 2024
71 of 72 checks passed
mergify bot pushed a commit that referenced this pull request Aug 14, 2024
…21266)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit ec17e1e)
julienrbrt pushed a commit that referenced this pull request Aug 14, 2024
…ackport #21266) (#21299)

Co-authored-by: james.zhang <68689915+zenzenless@users.noreply.github.com>
alpe added a commit that referenced this pull request Aug 19, 2024
* main: (76 commits)
  docs: more app v2 renaming (#21336)
  chore: update link in disclaimer (#21339)
  refactor(x/distribution): audit QA (#21316)
  docs: rename app v2 to app di when talking about runtime v0 (#21329)
  feat(schema): specify JSON mapping (#21243)
  fix(x/authz): bring back msg response in `DispatchActions` (#21044)
  chore: fix all lint issue since golangci-lint bump (#21326)
  refactor(x/mint): v0.52 audit x/mint (#21301)
  chore: fix spelling errors (#21327)
  feat: export genesis in simapp v2 (#21199)
  fix(baseapp)!: Halt at height now does not produce the halt height block (#21256)
  refactor(scripts): remove unused variable (#21320)
  chore(schema/testing): upgrade to go 1.23 iterators (#21282)
  chore: readmes + upgrading docs (#21271)
  feat(client): add auto cli for node service (#21074)
  ci: fix github workflow vulnerable to script injection (#21304)
  build(deps): Bump github.com/prometheus/client_golang from 1.19.1 to 1.20.0 (#21307)
  build(deps): use Go 1.23 instead of Go 1.22 (#21280)
  refactor(x/auth): audit x/auth changes (#21146)
  chore: remove todo: "abstract out staking message back to staking" (#21266)
  ...
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/genutil genutil module issues C:x/staking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants