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: migrate to v0.50 #20

Merged
merged 4 commits into from
May 20, 2024
Merged

feat: migrate to v0.50 #20

merged 4 commits into from
May 20, 2024

Conversation

matthiasmatt
Copy link
Contributor

@matthiasmatt matthiasmatt commented May 20, 2024

Summary by CodeRabbit

  • Chores

    • Updated Go version in unit test configuration from 1.19 to 1.21.
  • Refactor

    • Updated import paths for various packages to align with new package structure.
    • Replaced references to sdk with store and math.Legacy across multiple files for consistency.
    • Modified function signatures and types related to key-value store operations.
  • Tests

    • Adjusted test cases to use math.LegacyNewDec and math.LegacyZeroDec for decimal values.

Copy link

coderabbitai bot commented May 20, 2024

Walkthrough

The changes encompass a comprehensive update to import paths and types across various files, transitioning from github.com/cosmos/cosmos-sdk to cosmossdk.io for enhanced compatibility and maintainability. Additionally, the Go version in the CI configuration has been advanced from 1.19 to 1.21, ensuring alignment with the latest library versions.

Changes

Files Change Summary
.github/workflows/unit-tests.yml Updated Go version from 1.19 to 1.21.
collections_test.go Updated import paths, store initialization, and gas metering functions.
examples/1.go, examples/2.go, examples/3.go Updated import paths and function calls to align with new package structures.
indexed_map.go, indexers.go, item.go, sequence.go Changed import paths from github.com/cosmos/cosmos-sdk/store/types to cosmossdk.io/store/types.
iter.go Updated import paths and types for key-value store operations.
keys.go Changed type for encoding keys from sdk.Dec to math.LegacyDec.
keys_test.go Replaced references to sdk.NewDec and sdk.ZeroDec with math.LegacyNewDec and math.LegacyZeroDec.
map.go, map_test.go Updated import paths and return types for GetStore methods.
value_encoder.go, value_encoder_test.go Updated type in DecValueEncoder from sdk.Dec to math.LegacyDec and modified related methods.

🐇
In code's vast and changing sea,
We updated paths for all to see.
From cosmos old to cosmos new,
Our imports now are shiny and true.
With gas metered and keys encoded,
Our Go version's now reloaded.
Hoppity hop, the changes flow,
Through fields of code, we onward go!
🌟


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.

Copy link

@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 UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2216ec8 and 5b090a1.
Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum
Files selected for processing (17)
  • .github/workflows/unit-tests.yml (1 hunks)
  • collections_test.go (1 hunks)
  • examples/1.go (1 hunks)
  • examples/2.go (2 hunks)
  • examples/3.go (2 hunks)
  • indexed_map.go (1 hunks)
  • indexers.go (1 hunks)
  • item.go (1 hunks)
  • iter.go (5 hunks)
  • keys.go (3 hunks)
  • keys_test.go (2 hunks)
  • keyset.go (1 hunks)
  • map.go (3 hunks)
  • map_test.go (2 hunks)
  • sequence.go (1 hunks)
  • value_encoder.go (2 hunks)
  • value_encoder_test.go (2 hunks)
Files skipped from review due to trivial changes (4)
  • .github/workflows/unit-tests.yml
  • indexed_map.go
  • item.go
  • keyset.go
Additional comments not posted (22)
collections_test.go (3)

4-9: Updated import paths to align with new package structures.


16-19: The initialization of NewCommitMultiStore now includes additional parameters for logging and metrics. Ensure that these changes are reflected wherever NewCommitMultiStore is used.

Verification successful

The search results indicate that the only instance of NewCommitMultiStore found is in collections_test.go, and it correctly includes the new parameters for logging and metrics.

  • collections_test.go: ms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())

No other instances were found in the codebase, suggesting that the changes are correctly reflected where NewCommitMultiStore is used.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all instances of `NewCommitMultiStore` include the new parameters.

# Test: Search for the function usage. Expect: All occurrences should include the new parameters.
rg --type python $'NewCommitMultiStore'

Length of output: 69



Script:

#!/bin/bash
# Description: Verify that all instances of `NewCommitMultiStore` include the new parameters.

# Test: Search for the function usage. Expect: All occurrences should include the new parameters.
rg --type go 'NewCommitMultiStore'

Length of output: 137


27-27: Updated WithGasMeter to use storetypes.NewGasMeter. Verify that this change is compatible with the expected behavior in the context where it's used.

Verification successful

The search results show that WithGasMeter is used in the context of setting up a sdk.Context with a MultiStore and a GasMeter in collections_test.go. The storetypes.NewGasMeter function is used to create a new gas meter with a specified limit.

Given this context, the change appears to be compatible with the expected behavior, as storetypes.NewGasMeter is correctly used to initialize the gas meter.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new `NewGasMeter` behaves as expected in all usage contexts.

# Test: Search for the function usage. Expect: All occurrences should be checked for compatibility.
rg --type python $'WithGasMeter'

Length of output: 62



Script:

#!/bin/bash
# Description: Verify that the new `NewGasMeter` behaves as expected in all usage contexts.

# Test: Search for the function usage. Expect: All occurrences should be checked for compatibility.
rg --type go 'WithGasMeter'

Length of output: 103



Script:

#!/bin/bash
# Description: Extract the relevant code block from `collections_test.go` to verify the usage of `storetypes.NewGasMeter`.

# Extract 10 lines before and after the occurrence of `WithGasMeter` for context.
rg --type go -A 10 -B 10 'WithGasMeter' collections_test.go

Length of output: 446

sequence.go (1)

6-6: Updated import path to align with new package structures.

examples/2.go (2)

4-5: Updated import paths to align with new package structures.


32-32: Replaced sdk.MustNewDecFromStr with math.LegacyMustNewDecFromStr to align with the new math package. Ensure that the behavior of LegacyMustNewDecFromStr matches the expectations in this context.

examples/1.go (1)

4-4: Updated import path to align with new package structures.

examples/3.go (2)

4-4: Updated import path to align with new package structures.


59-60: Adjusted the CreateValidator method to convert operator addresses before insertion. Verify that the address conversion and subsequent insertion behave as expected.

keys_test.go (2)

11-11: Updated import path to align with new package structures.


102-106: Replaced references to sdk.NewDec with math.LegacyNewDec and sdk.ZeroDec with math.LegacyZeroDec. Ensure that these replacements are compatible with the expected behavior in the test scenarios.

value_encoder_test.go (3)

93-93: Updated the IntValueEncoder to use math.NewInt. Ensure that the behavior of NewInt matches the expectations in the value encoding and decoding scenarios.


39-39: Replaced sdk.MustNewDecFromStr with math.LegacyMustNewDecFromStr in the test for bijectivity. Verify that the behavior of LegacyMustNewDecFromStr matches the expectations in this test scenario.


63-81: Updated the IntKeyEncoder to use math.NewInt instead of sdk.NewInt. Ensure that the behavior of NewInt matches the expectations in the encoding and decoding scenarios.

value_encoder.go (3)

15-15: Updated DecValueEncoder to use math.LegacyDec. Ensure that the behavior of LegacyDec matches the expectations in the encoding and decoding scenarios.


69-74: Updated the decValueEncoder to return "math.LegacyDec" as its name. Verify that this change is reflected wherever the Name method is used.


52-61: Updated the decValueEncoder methods to handle math.LegacyDec. Ensure that the error handling and data integrity are maintained during the encoding and decoding processes.

Verification successful

The Encode and Decode methods of decValueEncoder have been updated to handle math.LegacyDec and include error handling. Both methods use panic to handle errors, which may not be ideal for all use cases, but they do ensure that errors are not silently ignored.

  • Encode method:

    • Marshals the math.LegacyDec value.
    • Panics with a formatted error message if marshalling fails.
    • Returns the marshalled byte slice.
  • Decode method:

    • Unmarshals the byte slice into a math.LegacyDec value.
    • Panics with a formatted error message if unmarshalling fails.
    • Returns the unmarshalled math.LegacyDec value.

These methods maintain data integrity by ensuring that any errors during encoding or decoding are immediately surfaced.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that error handling and data integrity are maintained during the encoding and decoding processes.

# Test: Search for the function usage. Expect: All occurrences should be checked for compatibility.
rg --type python $'decValueEncoder'

Length of output: 65



Script:

#!/bin/bash
# Description: Verify that error handling and data integrity are maintained during the encoding and decoding processes.

# Test: Search for the function usage. Expect: All occurrences should be checked for compatibility.
rg 'decValueEncoder'

Length of output: 454



Script:

#!/bin/bash
# Description: Extract the full implementation of `decValueEncoder` methods to verify error handling and data integrity.

# Extract the implementation of `decValueEncoder` methods.
ast-grep --lang go --pattern $'type decValueEncoder struct {
  $$$
}
func (d decValueEncoder) Encode(value math.LegacyDec) []byte {
  $$$
}
func (d decValueEncoder) Decode(b []byte) math.LegacyDec {
  $$$
}
func (d decValueEncoder) Stringify(value math.LegacyDec) string {
  $$$
}
func (d decValueEncoder) Name() string {
  $$$
}' value_encoder.go

Length of output: 1069



Script:

#!/bin/bash
# Description: Extract the implementation of `decValueEncoder.Encode` and `decValueEncoder.Decode` methods to verify error handling and data integrity.

# Extract the implementation of `decValueEncoder.Encode` method.
ast-grep --lang go --pattern $'func (d decValueEncoder) Encode(value math.LegacyDec) []byte {
  $$$
}' value_encoder.go

# Extract the implementation of `decValueEncoder.Decode` method.
ast-grep --lang go --pattern $'func (d decValueEncoder) Decode(b []byte) math.LegacyDec {
  $$$
}' value_encoder.go

Length of output: 910

map_test.go (1)

27-27: Update to GetStore method signature aligns with new package structure.

map.go (1)

87-87: Updated GetStore methods in Map and MapTransient use new package structure correctly.

Also applies to: 109-109

indexers.go (1)

4-4: Updated import path aligns with new package structure.

keys.go (1)

130-130: Updated SdkDecKeyEncoder methods use math.LegacyDec correctly.

Also applies to: 132-132, 140-140

iter.go (1)

108-108: Updated iteratorFromRange function uses new package structure correctly.

Also applies to: 136-136, 154-154

@Unique-Divine Unique-Divine merged commit 7689949 into main May 20, 2024
1 check passed
@Unique-Divine Unique-Divine deleted the mat/collection-v0.50 branch May 20, 2024 11:43
Copy link

@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 UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5b090a1 and 7dbc830.
Files selected for processing (10)
  • collections_test.go (1 hunks)
  • examples/1.go (2 hunks)
  • examples/3.go (3 hunks)
  • indexed_map.go (2 hunks)
  • indexers.go (2 hunks)
  • item.go (2 hunks)
  • keyset.go (2 hunks)
  • map.go (5 hunks)
  • sequence.go (2 hunks)
  • value_encoder.go (4 hunks)
Files skipped from review as they are similar to previous changes (10)
  • collections_test.go
  • examples/1.go
  • examples/3.go
  • indexed_map.go
  • indexers.go
  • item.go
  • keyset.go
  • map.go
  • sequence.go
  • value_encoder.go

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.

2 participants