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: remove comet dep in modules (1/n) #20270

Merged
merged 5 commits into from May 6, 2024
Merged

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented May 3, 2024

Description

ref #17425

this pr aims to cleanup comet as a dependency in a few locations in modules.


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

  • Refactor

    • Simplified handling of cryptographic operations across various modules by standardizing function calls and reducing external dependencies.
  • Bug Fixes

    • Updated event handling in the banking module to align with newer core event management standards.
  • Tests

    • Enhanced testing frameworks to better simulate environment settings and utilize secure random byte generation for benchmarks.

Copy link
Contributor

coderabbitai bot commented May 3, 2024

Walkthrough

Walkthrough

This update primarily focuses on decoupling the Cosmos SDK from the Comet dependencies across various modules, introducing new utility functions for cryptographic operations, and refining event management by replacing deprecated functions with updated equivalents from new packages.

Changes

Files Change Summary
x/auth/ante/setup_test.go, x/auth/ante/sigverify_benchmark_test.go, x/auth/types/account.go, x/auth/types/address.go, x/slashing/keeper/hooks.go Decoupling from Comet dependencies, introduction of new cryptographic utility functions.
x/bank/keeper/keeper_test.go Updated event management functions to use new package imports.
x/evidence/types/evidence.go Switched from Comet's cryptographic hash function to standard sha256.

Possibly related issues


Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 14f3ca0 and c530914.
Files ignored due to path filters (2)
  • x/evidence/go.mod is excluded by !**/*.mod
  • x/slashing/go.mod is excluded by !**/*.mod
Files selected for processing (7)
  • x/auth/ante/setup_test.go (2 hunks)
  • x/auth/ante/sigverify_benchmark_test.go (3 hunks)
  • x/auth/types/account.go (2 hunks)
  • x/auth/types/address.go (1 hunks)
  • x/bank/keeper/keeper_test.go (3 hunks)
  • x/evidence/types/evidence.go (2 hunks)
  • x/slashing/keeper/hooks.go (2 hunks)
Additional Context Used
Path-based Instructions (7)
x/auth/types/address.go (1)

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

x/auth/ante/sigverify_benchmark_test.go (2)

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


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

x/evidence/types/evidence.go (1)

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

x/slashing/keeper/hooks.go (1)

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

x/auth/ante/setup_test.go (2)

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


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

x/auth/types/account.go (1)

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

x/bank/keeper/keeper_test.go (2)

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


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

Learnings (1)
x/slashing/keeper/hooks.go (1)
User: atheeshp
PR: cosmos/cosmos-sdk#18236
File: x/slashing/keeper/hooks.go:104-113
Timestamp: 2023-11-21T11:45:40.885Z
Learning: The `AfterConsensusPubKeyUpdate` function in `x/slashing/keeper/hooks.go` is part of an interface and requires a parameter for coins, as clarified by the user atheeshp. This parameter is to be kept even if it's not currently used within the function, to maintain interface consistency and support future use cases.
Additional comments not posted (11)
x/auth/types/address.go (2)

11-13: Function AddressHash is well-implemented and documented.


22-25: Function SumTruncated is correctly implemented and documented.

x/auth/ante/sigverify_benchmark_test.go (2)

46-57: Function randBytes is correctly implemented and documented.


59-62: Function cRandBytes is correctly implemented and documented.

x/evidence/types/evidence.go (1)

30-32: Function Hash is correctly implemented and documented.

x/slashing/keeper/hooks.go (1)

51-51: Function AfterValidatorRemoved is correctly implemented and documented.

x/auth/ante/setup_test.go (1)

41-41: Function TestSetupDecorator_BlockMaxGas is correctly implemented and documented.

x/auth/types/account.go (1)

223-223: Function Validate in ModuleAccount is correctly implemented and documented.

x/bank/keeper/keeper_test.go (3)

16-16: Replace sdk.Event with coreevent.Event and abci.EventAttribute with coreevent.Attribute.

This change aligns with the PR's objective to remove dependencies on the Comet library by replacing them with core Cosmos SDK components.


1375-1400: Ensure correct event attributes after refactoring.

Verification successful

The verification process has confirmed that the old event attribute usage (sdk.EventAttribute) has been completely removed from the codebase, as no matches were found. Additionally, the new event attribute usage (coreevent.Attribute) is correctly implemented in the x/bank/keeper/keeper_test.go file, as evidenced by multiple matches.

This confirms that the refactoring from sdk.Event to coreevent.Event has been successfully implemented in the specified file with the correct attribute usage. No issues were found regarding the transition to the new event system.

  • File: x/bank/keeper/keeper_test.go
    • Correct usage of coreevent.Attribute in multiple instances.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the event attributes are correctly set after replacing `sdk.Event` with `coreevent.Event`.

# Test: Search for the old event attribute usage to find omissions. Expect: No matches.
rg --lang go --pattern 'sdk.EventAttribute'
# Test: Search for the new event attribute usage to validate usage. Expect: Matches.
rg --lang go --pattern 'coreevent.Attribute'

Length of output: 906



Script:

#!/bin/bash
# Description: Verify that the event attributes are correctly set after replacing `sdk.Event` with `coreevent.Event`.

# Test: Search for the old event attribute usage to find omissions. Expect: No matches.
rg 'sdk.EventAttribute'

# Test: Search for the new event attribute usage to validate usage. Expect: Matches.
rg 'coreevent.Attribute'

Length of output: 1011


1460-1493: Ensure correct event attributes after refactoring in multi-send events.

Verification successful

The verification process has successfully confirmed that the old event attribute usage (sdk.EventAttribute) is no longer present in the codebase, and the new event attribute usage (coreevent.Attribute) is correctly implemented in the specified file x/bank/keeper/keeper_test.go. This aligns with the changes described in the review comment, ensuring that the event attributes are correctly set after the refactoring in multi-send events.

  • File: x/bank/keeper/keeper_test.go
    • Usage of coreevent.Attribute is confirmed in multiple lines, indicating proper implementation of the new event system.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the event attributes are correctly set after replacing `sdk.Event` with `coreevent.Event` in multi-send events.

# Test: Search for the old event attribute usage to find omissions. Expect: No matches.
rg --lang go --pattern 'sdk.EventAttribute'
# Test: Search for the new event attribute usage to validate usage. Expect: Matches.
rg --lang go --pattern 'coreevent.Attribute'

Length of output: 906



Script:

#!/bin/bash
# Description: Verify that the event attributes are correctly set after replacing `sdk.Event` with `coreevent.Event` in multi-send events.

# Test: Search for the old event attribute usage to find omissions. Expect: No matches.
rg --pattern 'sdk.EventAttribute'
# Test: Search for the new event attribute usage to validate usage. Expect: Matches.
rg --pattern 'coreevent.Attribute'

Length of output: 892



Script:

#!/bin/bash
# Description: Verify that the event attributes are correctly set after replacing `sdk.Event` with `coreevent.Event` in multi-send events.

# Test: Search for the old event attribute usage to find omissions. Expect: No matches.
rg 'sdk.EventAttribute'
# Test: Search for the new event attribute usage to validate usage. Expect: Matches.
rg 'coreevent.Attribute'

Length of output: 1011


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 3, 2024 16:21
@tac0turtle tac0turtle requested a review from a team as a code owner May 3, 2024 16:21
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

lgtm

@julienrbrt julienrbrt changed the title chore: remove comet dep in modules (1/n) refactor: remove comet dep in modules (1/n) May 6, 2024
@julienrbrt julienrbrt added this pull request to the merge queue May 6, 2024
Merged via the queue into main with commit ca15c9d May 6, 2024
66 checks passed
@julienrbrt julienrbrt deleted the marko/comet_dep branch May 6, 2024 13:17
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.

None yet

5 participants