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: allow gov module account to transfer any CL position #7768

Merged
merged 5 commits into from
Mar 22, 2024

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Mar 18, 2024

Closes: #7329

What is the purpose of the change

Adds logic to allow the governance module account to transfer any position.

Testing and Verifying

Gotest added.

Summary by CodeRabbit

  • New Features
    • Enhanced the concentrated liquidity functionality to allow the governance module account to transfer liquidity positions, improving system flexibility and control.
  • Tests
    • Updated tests to support the new feature of governance account transfers.

@czarcas7ic czarcas7ic added V:state/breaking State machine breaking PR A:backport/v24.x backport patches to v24.x branch labels Mar 18, 2024
Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Walkthrough

The recent updates focus on empowering the Governance module to manage Concentrated Liquidity positions by allowing transfers from the Community Pool to specified addresses. These changes involve validating the sender as the governance module account, adjusting incentives and rewards handling, and ensuring proper position deletion during transfers. The testing framework has also been updated to support these modifications.

Changes

Files Change Summary
x/concentrated-liquidity/position.go, x/concentrated-liquidity/position_test.go - Updated functionality for transferring positions to allow the governance module account as the sender.
- Added verification for the sender as the governance module account.
- Adjusted handling of incentives, rewards, and position deletion during transfer.
- Added a boolean field isGovAddress in test cases for transferring positions.

Assessment against linked issues

Objective Addressed Explanation
Enable the Governance module to transfer liquidity positions from the Community Pool [#7329]
Implement a new message type MsgTransferCommunityPositions similar to MsgCommunityPoolSpend The changes imply the functionality but do not explicitly mention the new message type implementation.
Use of an authority account as the signer for proposals [#7329]
Ensure that the proposed design aligns with the requirement to transfer positions [#7329]
Enable recovery and adjustment of liquidity positions previously transferred to the Community Pool by Governance [#7329]

🐇🌼📜
In the realm of code, where liquidity flows,
A governance hand, with power it shows.
From pool to pool, positions do glide,
Under watchful eyes, no secrets to hide.
With each line woven, a new path is set,
In the ledger's tale, a future well met.
🌱🐾

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@czarcas7ic czarcas7ic changed the title feat: allow gov module account to transfer any position feat: allow gov module account to transfer any CL position Mar 18, 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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between be76d37 and 46421f1.
Files selected for processing (2)
  • x/concentrated-liquidity/position.go (4 hunks)
  • x/concentrated-liquidity/position_test.go (4 hunks)
Additional comments: 2
x/concentrated-liquidity/position.go (1)
  • 709-729: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [673-726]

The implementation of transferPositions function correctly introduces the ability for the governance module account to transfer positions. However, there are several areas that could be improved or require clarification:

  1. Security and Correctness: The check for unique position IDs (osmoassert.Uint64ArrayValuesAreUnique(positionIds)) is crucial to prevent duplicate processing. This is a good practice and helps ensure that the function behaves as expected without unintended side effects.

  2. Governance Module Check: The addition of a check to determine if the sender is the governance module account (isGovModuleSender) aligns with the PR's objectives. This allows the governance module to transfer positions without being the direct owner, enhancing its capabilities for managing community resources.

  3. Error Handling and Clarity: The function handles various error scenarios, such as position owner mismatches and active underlying locks, which is essential for robustness. However, the error messages and handling could be more descriptive to aid in debugging and operational monitoring. For example, including more context in errors related to position transfers could help administrators and developers diagnose issues more efficiently.

  4. Performance Considerations: The function iterates over each position ID and performs several operations, including reward collection and position deletion. While this is necessary for the functionality, it's important to consider the gas consumption and potential performance impacts, especially for large batches of position transfers. The initial gas consumption calculation (ctx.GasMeter().ConsumeGas(...)) is a good practice, but further optimizations or limits on the number of positions transferred in a single call might be necessary to prevent excessive resource usage.

  5. Maintainability and Extensibility: The function's structure and logic are generally clear, but as the system evolves, consider how this functionality might need to change. For instance, if additional conditions or steps are required for transferring positions in the future, ensure that the code is structured in a way that makes such extensions straightforward.

Overall, the implementation meets the PR's objectives but could benefit from enhanced error handling and clarity, as well as considerations for performance and future extensibility.

Consider enhancing error messages and handling for greater clarity and operational efficiency. Additionally, evaluate the function's performance for large batches of position transfers and consider implementing optimizations or limits as necessary.

x/concentrated-liquidity/position_test.go (1)
  • 2399-2403: The logic to determine the caller of the TransferPositions function based on isGovAddress is present, but there's no visible implementation or condition in the TransferPositions function itself that differentiates behavior based on whether the caller is a governance address or a regular user address.

Ensure that the intended behavior for transfers initiated by governance addresses is correctly implemented and tested. If specific governance-related checks or logic are required, they should be explicitly handled within the TransferPositions function or the test setup.

x/concentrated-liquidity/position_test.go Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 46421f1 and e3c456a.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 70-70: The changelog entry for version v23.0.7-iavl-v1 accurately documents the new feature allowing the governance module account to transfer any CL position, aligning with the PR objectives and AI-generated summary.

x/concentrated-liquidity/position_test.go Outdated Show resolved Hide resolved
@ValarDragon
Copy link
Member

I don't really like this, though it does solve the immediate problem.

I think its ok to ship this, but we need to add an issue to correct the ownership structure of this. (Community pool gov module gets direct control of all accounts it controls, e.g. via smart accounts like logic)

@czarcas7ic
Copy link
Member Author

I don't really like this, though it does solve the immediate problem.

I think its ok to ship this, but we need to add an issue to correct the ownership structure of this. (Community pool gov module gets direct control of all accounts it controls, e.g. via smart accounts like logic)

It feels like it is a safe assumption that all gov account actions must be dictated by governance. Therefore, the governance module has potential ownership of whatever it interacts with.

IMO the abstraction should instead be at an even higher level, where this whitelist of gov module should just be expected on every action

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e3c456a and 015a2c4.
Files selected for processing (1)
  • x/concentrated-liquidity/position_test.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/concentrated-liquidity/position_test.go

@czarcas7ic
Copy link
Member Author

Added issue #7778, will likely merge soon

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 015a2c4 and c697ff5.
Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/concentrated-liquidity/position.go (4 hunks)
  • x/concentrated-liquidity/position_test.go (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • CHANGELOG.md
  • x/concentrated-liquidity/position.go
  • x/concentrated-liquidity/position_test.go

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c697ff5 and 2f92e32.
Files selected for processing (1)
  • x/concentrated-liquidity/position_test.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/concentrated-liquidity/position_test.go

@czarcas7ic czarcas7ic merged commit e3f0689 into main Mar 22, 2024
1 check passed
@czarcas7ic czarcas7ic deleted the adam/allow-transfer-of-positions-by-gov-module-acc branch March 22, 2024 04:52
mergify bot pushed a commit that referenced this pull request Mar 22, 2024
* allow gov module account to transfer any position

* add changlelog

* Update position_test.go

* fix test

(cherry picked from commit e3f0689)

# Conflicts:
#	CHANGELOG.md
#	x/concentrated-liquidity/position.go
PaddyMc added a commit that referenced this pull request Mar 22, 2024
…7768) (#7801)

* feat: allow gov module account to transfer any CL position (#7768)

* allow gov module account to transfer any position

* add changlelog

* Update position_test.go

* fix test

(cherry picked from commit e3f0689)

# Conflicts:
#	CHANGELOG.md
#	x/concentrated-liquidity/position.go

* fix conflicts

---------

Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: PaddyMc <[email protected]>
@github-actions github-actions bot mentioned this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v24.x backport patches to v24.x branch C:x/concentrated-liquidity V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Governance module permission to move CL positions from Community Pool
4 participants