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: update tagged submodules for v27 #8801

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

@crnbarr93 crnbarr93 added V:state/breaking State machine breaking PR A:backport/v27.x backport patches to v27.x branch labels Nov 4, 2024
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

The pull request includes updates to the CHANGELOG.md file, adding entries for state-breaking changes, state-compatible bug fixes, and enhancements. Notable modifications were made to the x/tokenfactory module, specifically in the keeper package, where variable names were clarified, and error handling was improved in the forceTransfer method. Additionally, the NewKeeper function was updated to ensure proper initialization of the permAddrMap field in the Keeper struct.

Changes

File Change Summary
CHANGELOG.md Updated with new entries under "Unreleased" for state breaking and state compatible categories. Added entry for updating tagged submodules for version 27 and documented various bug fixes and enhancements.
x/tokenfactory/keeper/bankactions.go Modified forceTransfer method: renamed fromAcc to fromSdkAddr, added toSdkAddr, enhanced error handling for module account transfers, and removed redundant conversion of fromAddr.
x/tokenfactory/keeper/keeper.go Updated NewKeeper function to include initialization of permAddrMap in the Keeper struct. No changes to method signatures or public interfaces.
x/tokenfactory/keeper/before_send_test.go Modified TestBeforeSendHook to expect no error when minting tokens, altering the test's control flow.

Possibly related PRs

Suggested labels

V:state/compatible/backport

Suggested reviewers

  • mattverse
  • czarcas7ic
  • PaddyMc
  • nicolaslara

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c7708cb and 5cbe3e7.

📒 Files selected for processing (1)
  • x/tokenfactory/keeper/before_send_test.go (1 hunks)
🔇 Additional comments (1)
x/tokenfactory/keeper/before_send_test.go (1)

134-134: ⚠️ Potential issue

Verify the change in error expectation for minting 100 tokens.

The test expectation has been changed to expect no error when minting 100 tokens of the factory denomination. This is a significant behavioral change that needs verification:

  1. Previously, the test expected an error when minting 100 tokens
  2. Now, it expects the minting to succeed

Let's verify if this change is consistent with the module's behavior:

Please confirm:

  1. Is this a deliberate change in the module's behavior regarding minting 100 tokens?
  2. Should we update the test description to reflect this change in behavior?
  3. Are there other test cases that need similar updates for consistency?

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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 bot commented Nov 4, 2024

Walkthrough

The pull request includes updates to the CHANGELOG.md file, adding entries under "Unreleased" for state-breaking, configuration, and state-compatible changes, including a notable entry for updating tagged submodules for version 27. Additionally, modifications were made to the forceTransfer method in x/tokenfactory/keeper/bankactions.go, enhancing error handling and renaming variables for clarity. The NewKeeper function in x/tokenfactory/keeper/keeper.go was also updated to include a new permAddrMap field, improving state management without altering existing method signatures.

Changes

File Change Summary
CHANGELOG.md Updated with new entries under "Unreleased" for state-breaking, config, and state-compatible changes; added entry for tagged submodules update #8801.
x/tokenfactory/keeper/bankactions.go Modified forceTransfer method: renamed variables, enhanced error handling to prevent sending to module accounts, and streamlined address checks.
x/tokenfactory/keeper/keeper.go Updated NewKeeper function to include permAddrMap in Keeper struct initialization, enhancing state management capabilities.

Possibly related PRs

Suggested labels

A:no-changelog, V:state/compatible/backport

Suggested reviewers

  • czarcas7ic
  • PaddyMc
  • nicolaslara

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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 and nitpick comments (3)
x/tokenfactory/keeper/bankactions.go (1)

91-97: Consider standardizing error messages for consistency.

While the validation logic is correct, the error messages could be more consistent:

  • Line 91: "send from module acc not available"
  • Line 96: "send to module acc not available"

Consider standardizing the messages:

-			return status.Errorf(codes.Internal, "send from module acc not available")
+			return status.Errorf(codes.Internal, "sending from module account is not allowed")

-			return status.Errorf(codes.Internal, "send to module acc not available")
+			return status.Errorf(codes.Internal, "sending to module account is not allowed")
x/tokenfactory/keeper/keeper.go (1)

Line range hint 19-29: LGTM! Consider adding documentation for permAddrMap

The addition of permAddrMap is a good optimization for permission lookups. However, it would be helpful to add documentation explaining its purpose and relationship with permAddrs.

Add a comment above the Keeper struct or the field:

 type (
	Keeper struct {
		storeKey    storetypes.StoreKey
		permAddrs   map[string]authtypes.PermissionsForAddress
+		// permAddrMap provides O(1) lookup for checking if an address has any permissions
+		// This is an optimization to avoid iterating through permAddrs
		permAddrMap map[string]bool
CHANGELOG.md (1)

53-53: LGTM with suggestion to add more details.

The changelog entry accurately reflects that this PR updates tagged submodules for v27. However, consider adding more details about the specific submodule versions being updated:

-* [#8801](https://github.com/osmosis-labs/osmosis/pull/8801) chore: update tagged submodules for v27
+* [#8801](https://github.com/osmosis-labs/osmosis/pull/8801) chore: update tagged submodules for v27:
+  * x/ibc-hooks: v0.0.17
+  * x/epochs: v0.0.11
+  * osmoutils: v0.0.15
+  * osmomath: v0.0.15
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bc20f90 and c7708cb.

⛔ Files ignored due to path filters (3)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
  • go.work is excluded by !**/*.work, !**/*.work
📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/tokenfactory/keeper/bankactions.go (2 hunks)
  • x/tokenfactory/keeper/keeper.go (1 hunks)
🔇 Additional comments (5)
x/tokenfactory/keeper/bankactions.go (2)

69-74: LGTM! Improved variable naming and error handling.

The variable renaming from fromAddr to fromSdkAddr better indicates the type, and early initialization of toSdkAddr follows good error handling practices.


91-97: Verify similar validation patterns across the codebase.

Let's ensure this validation pattern is consistently applied across other token transfer functions in the codebase.

✅ Verification successful

Based on the search results, I can now generate the final response:

Module account validation is unique to tokenfactory's bankactions

The validation pattern for preventing transfers to/from module accounts appears to be specific to the tokenfactory module's bankactions. While there are numerous instances of SendCoinsFromModuleToAccount and similar bank operations across the codebase, none of them implement the same validation pattern. This is expected as different modules have different requirements for module account interactions.

  • The tokenfactory module's strict validation is intentional and doesn't need to be replicated elsewhere
  • Other modules like superfluid, mint, and lockup handle module account transfers differently based on their specific use cases
  • No inconsistencies found in the validation patterns across the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar token transfer functions and their validation patterns
rg -A 5 "SendCoins.*ModuleName" --type go

# Look for other module account validation patterns
ast-grep --pattern 'if $_.GetAddress().Equals($_) {
  return status.Errorf($_)
}'

Length of output: 10656

x/tokenfactory/keeper/keeper.go (3)

Line range hint 42-52: LGTM! Initialization is correct and consistent

The initialization of permAddrMap is properly synchronized with permAddrs, ensuring consistency in permission tracking.


57-60: LGTM! Proper initialization of all fields

The Keeper struct initialization correctly includes the new permAddrMap field while maintaining proper alignment and structure.


Line range hint 19-29: Verify the usage of permAddrMap across the codebase

Let's ensure this new field is being utilized effectively in the codebase.

✅ Verification successful

Let me gather more context about the permission checking methods to ensure we have a complete picture.


Let me try one more search pattern to find all permission-related functionality.


permAddrMap is properly implemented and used for module account verification

The new permAddrMap field is being used effectively in the IsModuleAcc method to efficiently check if an address is a restricted module account. The implementation shows:

  • Initialization in the keeper constructor where it's populated from module permissions
  • Used in IsModuleAcc method for O(1) lookups of restricted addresses
  • Serves as a performance optimization over iterating through permAddrs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential usages of the new permAddrMap field
rg -A 3 "permAddrMap" ./x/tokenfactory/

# Look for any permission checking methods that might need to be updated
ast-grep --pattern 'func ($receiver *Keeper) $method($ctx sdk.Context, $addr string) bool {
  $$$
}'

Length of output: 1282


Script:

#!/bin/bash
# Search for methods that check permissions in bankactions.go
rg -A 5 "func \(\*Keeper\) .*Permission" ./x/tokenfactory/

# Look for any other methods that might be using the permAddrMap
ast-grep --pattern 'func ($receiver *Keeper) $method($params) $return {
  $$$
  $receiver.permAddrMap
  $$$
}'

Length of output: 173


Script:

#!/bin/bash
# Search for any permission-related code and methods
rg -A 5 "HasPermission|CheckPermission|IsPermission" ./x/tokenfactory/

# Also look for the specific method using permAddrMap we found earlier
rg -A 10 -B 5 "return k.permAddrMap\[addr.String\(\)\]" ./x/tokenfactory/

Length of output: 673

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 and nitpick comments (3)
x/tokenfactory/keeper/keeper.go (2)

Line range hint 19-31: LGTM! Good performance optimization.

The addition of permAddrMap as a boolean lookup map is a good optimization for permission checks. It provides O(1) lookup time and avoids repeated address string conversions that would be needed when using only the permAddrs map.

Consider documenting the relationship between permAddrs and permAddrMap in comments, as they serve complementary purposes:

  • permAddrs: Stores detailed permissions
  • permAddrMap: Provides fast lookup for permission checks

57-60: Consider pre-allocating map capacity.

The initialization and population of permAddrMap is correct, but we can optimize it further by pre-allocating the map capacity since we know the size from maccPerms.

-	permAddrMap := make(map[string]bool)
+	permAddrMap := make(map[string]bool, len(maccPerms))
CHANGELOG.md (1)

53-53: Consider documenting additional v27 changes.

The PR objectives indicate this is for v27 but currently only submodule updates are documented. Consider adding entries for any other changes that will be included in the v27 release.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bc20f90 and c7708cb.

⛔ Files ignored due to path filters (3)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
  • go.work is excluded by !**/*.work, !**/*.work
📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/tokenfactory/keeper/bankactions.go (2 hunks)
  • x/tokenfactory/keeper/keeper.go (1 hunks)
🔇 Additional comments (4)
x/tokenfactory/keeper/bankactions.go (3)

69-74: LGTM! Improved variable naming and consistent error handling.

The variable renaming from fromAcc to fromSdkAddr and the introduction of toSdkAddr enhance code clarity by explicitly indicating the SDK address type. The error handling is consistent for both address conversions.


Line range hint 69-97: LGTM! Solid implementation with proper validations.

The overall implementation is well-structured with:

  • Proper validation of token factory denominations
  • Consistent error handling for address conversions
  • Deterministic processing through sorted iteration of module accounts
  • Clear separation of validation steps

91-97: Verify impact of new module account transfer restriction.

While the added validation for preventing transfers to module accounts is good, we should verify this doesn't break existing functionality. Also, consider making the error messages consistent between the "from" and "to" validations.

Let's verify the module account transfer usage:

Consider making the error messages consistent:

-			return status.Errorf(codes.Internal, "send from module acc not available")
+			return status.Errorf(codes.Internal, "transfer from module account not allowed")
-			return status.Errorf(codes.Internal, "send to module acc not available")
+			return status.Errorf(codes.Internal, "transfer to module account not allowed")
✅ Verification successful

Based on the search results, I can now generate the final response:

Module account transfer restriction is correctly implemented

The added validation preventing transfers to module accounts is safe and doesn't break existing functionality because:

  • All existing module account transfers in the codebase use specialized methods like SendCoinsFromModuleToAccount and SendCoinsFromAccountToModule
  • The new validation in bankactions.go only affects the tokenfactory's force transfer functionality
  • Test coverage (TestForceTransfer) exists and can verify this behavior

The error message consistency suggestion remains valid:

-			return status.Errorf(codes.Internal, "send from module acc not available")
+			return status.Errorf(codes.Internal, "transfer from module account not allowed")
-			return status.Errorf(codes.Internal, "send to module acc not available")
+			return status.Errorf(codes.Internal, "transfer to module account not allowed")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any existing tokenfactory transfer calls to module accounts
rg -A 5 'forceTransfer.*ModuleName|SendCoins.*ModuleName' --type go

# Search for tests that might be affected
rg -A 5 'TestForceTransfer' --type go

Length of output: 11483

CHANGELOG.md (1)

53-53: LGTM on the submodule updates for v27.

The submodule version updates look correct and match the PR objectives:

  • x/ibc-hooks: v0.0.17
  • x/epochs: v0.0.11
  • osmoutils: v0.0.15
  • osmomath: v0.0.15

@PaddyMc PaddyMc merged commit 9e46748 into main Nov 4, 2024
1 check passed
@PaddyMc PaddyMc deleted the chore/update-to-tagged-submodules-v27 branch November 4, 2024 15:37
mergify bot pushed a commit that referenced this pull request Nov 4, 2024
* chore: update tagged submodules for v27

* chore: changelog

* test: fix before_send_test TestBeforeSendHook

(cherry picked from commit 9e46748)
crnbarr93 added a commit that referenced this pull request Nov 4, 2024
* chore: update tagged submodules for v27

* chore: changelog

* test: fix before_send_test TestBeforeSendHook

(cherry picked from commit 9e46748)

Co-authored-by: Connor Barr <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Nov 6, 2024
6 tasks
@coderabbitai coderabbitai bot mentioned this pull request Dec 10, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v27.x backport patches to v27.x branch C:x/tokenfactory V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants