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

refactor(errors)!: remove grpc from errors #20402

Merged
merged 6 commits into from
May 21, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented May 15, 2024

Description

this is a proposal to remove grpc as a dep in the errors package. opening to see what others think


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

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

    • Streamlined error handling by removing Grpc error codes, enhancing system efficiency and maintenance.
  • Chores

    • Updated dependencies to latest versions for improved stability and performance.
  • Documentation

    • Revised changelog to reflect the elimination of Grpc error codes from the error package.

Copy link
Contributor

coderabbitai bot commented May 15, 2024

Walkthrough

Walkthrough

The changes aimed to streamline error handling by removing the RegisterWithGRPCCode function and the grpcCode field from the Error struct, simplifying error registration and status retrieval. Additionally, related tests and imports were adjusted accordingly. Dependencies in simapp/gomod2nix.toml were updated to newer versions, ensuring compatibility and improved functionality.

Changes

File Path Change Summary
errors/errors.go Removed RegisterWithGRPCCode function, grpcCode field from Error struct, updated GRPCStatus function.
errors/errors_test.go Removed imports of grpc/codes and grpc/status, deleted TestGRPCStatus function, removed ErrConflict, ErrNotSupported, and ErrNotFound declarations.
simapp/gomod2nix.toml Updated versions and hashes for several dependencies including cometbft, gogo-proto, color, go-plugin, genproto, and grpc.

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.

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

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.

@tac0turtle tac0turtle marked this pull request as ready for review May 17, 2024 10:20
@tac0turtle tac0turtle requested a review from a team as a code owner May 17, 2024 10:20
@@ -5,18 +5,13 @@ go 1.20
require (
github.com/pkg/errors v0.9.1
Copy link
Member Author

Choose a reason for hiding this comment

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

I would also propose removing the errors pkg here as it's only needed for stack traces. Then we would make stack tracers via a build flag and only at the core layer. There isn't a need for all errors to have stack traces here

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 92dafe6 and 9f5d783.
Files ignored due to path filters (2)
  • errors/go.mod is excluded by !**/*.mod
  • errors/go.sum is excluded by !**/*.sum
Files selected for processing (3)
  • errors/errors.go (5 hunks)
  • errors/errors_test.go (3 hunks)
  • simapp/gomod2nix.toml (4 hunks)
Files skipped from review due to trivial changes (1)
  • errors/errors_test.go
Additional Context Used
Path-based Instructions (1)
errors/errors.go (1)

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

Additional comments not posted (10)
errors/errors.go (4)

35-35: The implementation of the Register function looks good and adheres to the expected behavior of preventing code reuse.


35-35: The changes to the Error struct, including the removal of the grpcCode field, align with the PR's objectives and are implemented correctly.


35-35: The Wrap and Wrapf functions are implemented correctly, handling nil errors appropriately and ensuring that stack trace information is attached correctly.


35-35: The Recover function is well-implemented, correctly capturing panics and transforming them into manageable errors, which enhances the robustness of the error handling system.

simapp/gomod2nix.toml (6)

5-6: Updated version and hash for buf.build/gen/go/cometbft/cometbft/protocolbuffers/go.

Ensure that the new version is compatible with the rest of the project and does not introduce breaking changes.


8-9: Updated version and hash for buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go.

Verify the compatibility of this updated dependency with existing project modules.


174-175: Updated version and hash for github.com/fatih/color.

Check if the new version introduces any changes that might affect the visual aspects of the project.


285-286: Updated version and hash for github.com/hashicorp/go-plugin.

Confirm that the updated plugin system continues to function correctly with the new version.


556-557: Updated version and hash for google.golang.org/genproto/googleapis/rpc.

Ensure that the updated RPC interfaces are fully compatible with the project's requirements.


559-560: Updated version and hash for google.golang.org/grpc.

Given the PR's focus on removing gRPC from errors, ensure that this update does not reintroduce any unwanted gRPC dependencies.

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 9f5d783 and 8df9935.
Files selected for processing (1)
  • errors/CHANGELOG.md (1 hunks)
Additional Context Used
LanguageTool (1)
errors/CHANGELOG.md (1)

Near line 36: Consider a shorter alternative to avoid wordiness.
Context: ...es from the error package. This is done in order to keep the dependency graph of errors min...

Path-based Instructions (1)
errors/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Comment on lines +36 to +37
* [#20402](https://github.com/cosmos/cosmos-sdk/pull/20402) Remove Grpc error codes from the error package. This is done in order to keep the dependency graph of errors minimal

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider revising the entry for conciseness.

- * [#20402](https://github.com/cosmos/cosmos-sdk/pull/20402) Remove Grpc error codes from the error package. This is done in order to keep the dependency graph of errors minimal
+ * [#20402](https://github.com/cosmos/cosmos-sdk/pull/20402) Removed gRPC error codes from the error package to simplify the dependency graph.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* [#20402](https://github.com/cosmos/cosmos-sdk/pull/20402) Remove Grpc error codes from the error package. This is done in order to keep the dependency graph of errors minimal
* [#20402](https://github.com/cosmos/cosmos-sdk/pull/20402) Removed gRPC error codes from the error package to simplify the dependency graph.

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

Nice 💪

@@ -154,10 +142,6 @@ func (e *Error) Wrap(desc string) error { return Wrap(e, desc) }
// It's a handy function to call Wrapf with sdk errors.
func (e *Error) Wrapf(desc string, args ...interface{}) error { return Wrapf(e, desc, args...) }

func (e *Error) GRPCStatus() *grpcstatus.Status {
Copy link
Contributor

Choose a reason for hiding this comment

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

This was never called? 🙈

@julienrbrt
Copy link
Member

What's the release strategy of this given that we have a v1.
Do we follow our semver?

@julienrbrt julienrbrt changed the title chore: remove grpc from errors refactor(errors)!: remove grpc from errors May 21, 2024
@tac0turtle
Copy link
Member Author

What's the release strategy of this given that we have a v1. Do we follow our semver?

should we do v1.1 since our semvar is consensus breaking as major?

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 8df9935 and 3c8fadf.
Files selected for processing (1)
  • simapp/gomod2nix.toml (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • simapp/gomod2nix.toml

@tac0turtle tac0turtle added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit b17ccd8 May 21, 2024
68 checks passed
@tac0turtle tac0turtle deleted the marko/propose_grpc_removal_errors branch May 21, 2024 17:35
@aaronc
Copy link
Member

aaronc commented May 21, 2024

should we do v1.1 since our semvar is consensus breaking as major?

I agree with the decision to make this change but 1) we discussed in a previous call that consensus breaking as major is not a great policy and 2) I thought that policy only applied to modules not libraries. If this is a v1 library then I really think we should follow semver and this should be bumped to v2. The downstream side of effects of not following this could be pretty frustrating for some users.

@tac0turtle
Copy link
Member Author

Makes sense. I would make a few more changes if we go to v2 then.

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.

None yet

5 participants