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(transfer): move denom trace to internal folder. #6508

Merged
merged 7 commits into from
Jun 6, 2024

Conversation

DimitrisJim
Copy link
Contributor

@DimitrisJim DimitrisJim commented Jun 5, 2024

Description

Moves the proto gen go file to internal and moves relevant denom trace files there too.

closes: #6454


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • Refactor

    • Updated internal handling of DenomTrace type, replacing custom types with standardized types from the ibc-go repository.
  • Chores

    • Deprecated and removed DenomTrace message from protobuf definitions.
    • Updated documentation to reflect the removal of DenomTrace type in the apps/transfer module.

Copy link
Contributor

coderabbitai bot commented Jun 5, 2024

Walkthrough

The recent changes in the ibc-go repository involve removing the DenomTrace type from the public API and migrating its usage to an internal package. This refactor affects various modules, including transfer, keeper, and simulation, by updating type references and function signatures to use the new internal DenomTrace type. The goal is to streamline internal handling of denomination traces while maintaining backward compatibility.

Changes

File(s) Change Summary
CHANGELOG.md Documented the removal of DenomTrace from the public API.
modules/.../legacy_denomtrace.go, modules/.../legacy_denomtrace_responses.go Replaced custom types with types from internaltypes and marked empty structs for potential removal.
modules/.../export_test.go, modules/.../migrations_test.go, modules/.../decoder_test.go Updated test files to use internaltypes.DenomTrace instead of transfertypes.DenomTrace.
modules/.../migrations.go Updated function parameters and return values to use internaltypes.DenomTrace.
modules/.../decoder.go Updated variable declarations to use internaltypes.DenomTrace.
proto/.../denomtrace.proto Deprecated DenomTrace message and added new fields.
proto/.../transfer.proto Removed DenomTrace message definition.
scripts/protocgen.sh Moved denomtrace.pb.go to the internal/types directory.

Sequence Diagram(s) (Beta)

No sequence diagrams are needed for these changes as they mainly involve refactoring and type updates.

Assessment against linked issues

Objective Addressed Explanation
Remove DenomTrace from public API (#6454)
Migrate internal storage of trace string to array of trace info (#6221) The changes focus on moving DenomTrace to internal types, but it's unclear if the internal storage has been migrated to an array format.

Possibly related issues


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
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

🚀


// TODO: https://github.com/cosmos/ibc-go/issues/6421#issuecomment-2137516426
Copy link
Contributor Author

Choose a reason for hiding this comment

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

had to move out as these are the types interchaintest still requires (left comment on slack on the current pain point on this)

@DimitrisJim DimitrisJim marked this pull request as ready for review June 5, 2024 14:57
@DimitrisJim
Copy link
Contributor Author

oh note: need changelog on this

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: 4

Outside diff range and nitpick comments (1)
scripts/protocgen.sh (1)

Line range hint 8-8: Address the unassigned variable usage.

The variable $file is used but not defined in the script. Ensure that it is assigned appropriately or removed if not needed.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 14cfc6d and a516e36.

Files ignored due to path filters (2)
  • modules/apps/transfer/internal/types/denomtrace.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
  • modules/apps/transfer/types/transfer.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (12)
  • CHANGELOG.md (1 hunks)
  • modules/apps/transfer/internal/types/legacy_denomtrace.go (2 hunks)
  • modules/apps/transfer/internal/types/legacy_denomtrace_test.go (1 hunks)
  • modules/apps/transfer/keeper/export_test.go (1 hunks)
  • modules/apps/transfer/keeper/migrations.go (5 hunks)
  • modules/apps/transfer/keeper/migrations_test.go (15 hunks)
  • modules/apps/transfer/simulation/decoder.go (2 hunks)
  • modules/apps/transfer/simulation/decoder_test.go (1 hunks)
  • modules/apps/transfer/types/legacy_denomtrace_responses.go (1 hunks)
  • proto/ibc/applications/transfer/v1/denomtrace.proto (1 hunks)
  • proto/ibc/applications/transfer/v1/transfer.proto (1 hunks)
  • scripts/protocgen.sh (1 hunks)
Files skipped from review due to trivial changes (3)
  • modules/apps/transfer/internal/types/legacy_denomtrace_test.go
  • modules/apps/transfer/types/legacy_denomtrace_responses.go
  • proto/ibc/applications/transfer/v1/transfer.proto
Additional context used
Path-based instructions (7)
modules/apps/transfer/simulation/decoder.go (1)

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

modules/apps/transfer/internal/types/legacy_denomtrace.go (1)

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

modules/apps/transfer/simulation/decoder_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"

modules/apps/transfer/keeper/export_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"

modules/apps/transfer/keeper/migrations.go (1)

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

modules/apps/transfer/keeper/migrations_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"

CHANGELOG.md (1)

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

Shellcheck
scripts/protocgen.sh

[warning] 8-8: file is referenced but not assigned (for output from commands, use "$(file ...)" ). (SC2154)


[info] 8-8: Double quote to prevent globbing and word splitting. (SC2086)

Markdownlint
CHANGELOG.md

222-222: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


272-272: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


207-207: null (MD034, no-bare-urls)
Bare URL used

Additional comments not posted (12)
proto/ibc/applications/transfer/v1/denomtrace.proto (1)

9-16: Marking DenomTrace as deprecated is well-handled.

The addition of the deprecated option to the DenomTrace message is a clear and effective way to signal the future removal of this feature to developers.

modules/apps/transfer/simulation/decoder.go (1)

22-22: Ensure proper error handling in decoding operations.

Consider adding error handling for the MustUnmarshal calls to prevent runtime panics in case of malformed data:

- types.ModuleCdc.MustUnmarshal(kvA.Value, &denomTraceA)
- types.ModuleCdc.MustUnmarshal(kvB.Value, &denomTraceB)
+ err := types.ModuleCdc.Unmarshal(kvA.Value, &denomTraceA)
+ if err != nil {
+     return fmt.Sprintf("Error unmarshalling DenomTrace A: %v", err)
+ }
+ err = types.ModuleCdc.Unmarshal(kvB.Value, &denomTraceB)
+ if err != nil {
+     return fmt.Sprintf("Error unmarshalling DenomTrace B: %v", err)
+ }
modules/apps/transfer/internal/types/legacy_denomtrace.go (1)

29-29: Correctly utilize the types.DenomPrefix for formatting the IBC denomination.

The use of types.DenomPrefix in the IBCDenom method ensures consistency with the expected format across different modules.

modules/apps/transfer/simulation/decoder_test.go (1)

19-19: Proper instantiation and usage of internaltypes.DenomTrace in unit tests.

The test setup correctly initializes DenomTrace instances with appropriate values, ensuring that the decoder functionality is thoroughly tested.

modules/apps/transfer/keeper/export_test.go (1)

11-11: Ensure the internal API changes are reflected in the test helpers.

The modifications in the test helper functions to use internaltypes.DenomTrace instead of types.DenomTrace align with the internalization of the DenomTrace type, maintaining encapsulation and modularity.

Also applies to: 16-16, 21-23

modules/apps/transfer/keeper/migrations.go (2)

13-13: Ensure the new import alias internaltypes is consistently used throughout the file to avoid confusion with similar types.


116-116: The functions setDenomTrace, deleteDenomTrace, iterateDenomTraces, and setDenomMetadataWithDenomTrace are correctly updated to use the internal types. This aligns with the PR's goal of making DenomTrace internal.

Also applies to: 124-124, 131-131, 147-147

modules/apps/transfer/keeper/migrations_test.go (5)

12-12: The import alias internaltransfertypes is correctly used to reflect the internal scope of DenomTrace. This change is consistent with the modifications in the main codebase.


63-63: The test cases in TestMigratorMigrateDenomTraceToDenom are well-structured to cover various scenarios including no trace, single trace, multiple traces, and complex paths. This ensures comprehensive testing of the migration logic.

Also applies to: 76-76, 89-89, 102-102, 107-107, 112-112, 117-117, 134-134, 147-147, 160-160


186-186: The test for ensuring no leftover DenomTrace keys exist after migration is a good practice to ensure data integrity and cleanliness post-migration.


198-198: The corruption detection tests in TestMigratorMigrateDenomTraceToDenomCorruptionDetection are crucial for ensuring the robustness of the migration logic against invalid or corrupted data.

Also applies to: 202-202, 209-209


309-309: The tests in TestMigratorMigrateMetadata are comprehensive, covering various scenarios to ensure that metadata migration handles different denom trace configurations correctly. This is essential for maintaining accurate and consistent metadata across token denominations.

Also applies to: 320-320, 347-347, 374-374, 418-418

CHANGELOG.md Outdated Show resolved Hide resolved
scripts/protocgen.sh Show resolved Hide resolved
modules/apps/transfer/keeper/migrations.go Show resolved Hide resolved
modules/apps/transfer/keeper/migrations.go Show resolved Hide resolved
@colin-axner colin-axner added the priority PRs that need prompt reviews label Jun 5, 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 a516e36 and 2843f30.

Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional context used
Path-based instructions (1)
CHANGELOG.md (1)

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

Markdownlint
CHANGELOG.md

222-222: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


272-272: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


207-207: null (MD034, no-bare-urls)
Bare URL used

Additional comments not posted (1)
CHANGELOG.md (1)

60-60: Add a changelog entry for the removal of DenomTrace.

The changelog correctly documents the removal of the DenomTrace type as part of the PR changes. This aligns with the PR's objective to remove DenomTrace from the public API, ensuring that the documentation is consistent with the codebase changes.

Copy link

sonarcloud bot commented Jun 6, 2024

Quality Gate Passed Quality Gate passed for 'ibc-go'

Issues
11 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM!

@DimitrisJim DimitrisJim merged commit d95e24e into main Jun 6, 2024
78 checks passed
@DimitrisJim DimitrisJim deleted the jim/move-denomtrace-to-internal branch June 6, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove DenomTrace from public API
4 participants