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: add back scaling factor choice #7951

Merged
merged 6 commits into from
Apr 5, 2024

Conversation

PaddyMc
Copy link
Contributor

@PaddyMc PaddyMc commented Apr 3, 2024

What is the purpose of the change

This PR migrates the selected cl pool incentives to the new scaling factor, in this PR we add back in the code path choice for selected pool scaling factors

currently the pool added to this migration are:

// MigratedIncentiveAccumulatorPoolIDsV24 is a map that defines pools to migrate to the latest scalingFactor for v24.
var MigratedIncentiveAccumulatorPoolIDsV24 = map[uint64]struct{}{
	// token0 eth
	// token1 uosmo
	// liquidity 272k
	1281: {},
	// token0 usdt
	// token1 dia
	// liquidity 500
	1276: {},
	// token0 usdc
	// token1 dai
	// liqudity 1.55k
	1275: {},
	// token0 usdc
	// token1 dai
	// liqudity 52.9k
	1260: {},
}

How to test

To test this PR you need to use the in-place-testnet

Download the latest snapshot and genesis

OSMOSIS_HOME=$HOME/.osmosisd

SNAPSHOT_URL=$(curl -sL https://snapshots.osmosis.zone/latest)
RPC_URL=https://rpc.osmosis.zone
ADDRBOOK_URL="https://rpc.osmosis.zone/addrbook"
GENESIS_URL=https://github.com/osmosis-labs/osmosis/raw/main/networks/osmosis-1/genesis.json

rm -rf $HOME/.osmosisd/

osmosisd init test --chain-id testing --home=$HOME/.osmosisd

# Copy genesis
echo -e "\nDownloading genesis file..."
wget $GENESIS_URL -O $OSMOSIS_HOME/config/genesis.json
echo ✅ Genesis file downloaded successfully.

# Download latest snapshot
echo -e "\nDownloading latest snapshot..."
wget -O - $SNAPSHOT_URL | lz4 -d | tar -C $OSMOSIS_HOME/ -xf -
echo -e ✅ Snapshot downloaded successfully.

# Run the node
osmosisd start --home=$HOME/.osmosisd

You need to install v23.0.8 to run the following command

osmosisd in-place-testnet edgenet osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj --trigger-testnet-upgrade v24

Wait until the node stops, build this branch and run

osmosisd start

This will run the v24 migration and migrate selected CL pool incentive accumlators

How to test manually:

  • Create an incentive for a pool
  • Create a CL position in a tight range
  • Swap tokens
  • Check that rewards have been distributed

Summary by CodeRabbit

  • New Features

    • Introduced functionality to selectively migrate CL incentives, enhancing the migration process.
    • Added a feature to retrieve and apply incentive scaling factors for pools, improving the accuracy of incentive calculations.
  • Refactor

    • Updated references and variable names related to migrated incentive accumulator pool IDs across multiple upgrade paths.
    • Adjusted logic for managing pool IDs during migration to ensure compatibility with new incentive scaling features.
  • Tests

    • Added and updated tests to verify the correct application of incentive scaling factors and the selective migration of incentives.

@PaddyMc PaddyMc added the V:state/breaking State machine breaking PR label Apr 4, 2024
@PaddyMc PaddyMc marked this pull request as ready for review April 4, 2024 14:08
Copy link
Contributor

coderabbitai bot commented Apr 4, 2024

Walkthrough

This update refines the migration process for claimable incentives, enabling the selective migration of specific incentives. It includes changes across various files to support this functionality, such as adjustments in constants, upgrades logic, and tests. Additionally, a new feature for calculating incentive scaling factors based on pool IDs has been introduced, enhancing the precision of incentive calculations.

Changes

Files Change Summary
CHANGELOG.md Added functionality to only migrate selected cl incentives.
app/upgrades/v23/constants.go Removed initialization of MigratedIncentiveAccumulatorPoolIDs map.
app/upgrades/v23/upgrades.go, app/upgrades/v23/upgrades_test.go, app/upgrades/v24/upgrades.go, app/upgrades/v24/upgrades_test.go Updated to use concentratedtypes.MigratedIncentiveAccumulatorPoolIDs; adjusted migration and test logic.
x/concentrated-liquidity/export_test.go, x/concentrated-liquidity/incentives.go, x/concentrated-liquidity/incentives_test.go Added and modified logic for incentive scaling factors; added new tests.
x/concentrated-liquidity/types/migration.go Introduced maps defining pools to migrate for different versions.

🐰✨

In the digital field, where code does leap,
A change was made, not shallow but deep.
With careful thought and precision so rare,
Incentives migrate, from here to there.

So hop with joy, for progress we cheer,
CodeRabbit's work, forever sincere. 🌟🐇

🥕🎉

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/coderabbit-overrides.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.

}

// If the given pool ID is in the migrated incentive accumulator pool IDs (v24), we return the perUnitLiqScalingFactor.
_, isMigrated = types.MigratedIncentiveAccumulatorPoolIDsV24[poolID]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the most important line of this PR IMO, now we have a second check to return scaling factors depending on the v24 migration map

CHANGELOG.md Show resolved Hide resolved
x/concentrated-liquidity/incentives.go Show resolved Hide resolved
x/concentrated-liquidity/incentives.go Show resolved Hide resolved
x/concentrated-liquidity/incentives.go Show resolved Hide resolved
x/concentrated-liquidity/types/migration.go Outdated Show resolved Hide resolved
@PaddyMc PaddyMc added the A:backport/v24.x backport patches to v24.x branch label Apr 4, 2024
Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

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

This LGTM, but certainly should have a second ACK given how serious the effects of implementing this wrong would be

@p0mvn
Copy link
Member

p0mvn commented Apr 5, 2024

How long did migration take now?

@PaddyMc
Copy link
Contributor Author

PaddyMc commented Apr 5, 2024

How long did migration take now?

less than 10 seconds, posted a video internally in slack

@PaddyMc PaddyMc merged commit f110508 into main Apr 5, 2024
1 check passed
@PaddyMc PaddyMc deleted the chore/reduce-migration-time-for-cl-pools branch April 5, 2024 13:20
mergify bot pushed a commit that referenced this pull request Apr 5, 2024
* chore: add back scaling factor choice

* chore: add more pools and test

* chore: add changelog

* chore: fix typo and test

* chore: remove old changelog entry

(cherry picked from commit f110508)

# Conflicts:
#	CHANGELOG.md
PaddyMc added a commit that referenced this pull request Apr 5, 2024
* chore: add back scaling factor choice (#7951)

* chore: add back scaling factor choice

* chore: add more pools and test

* chore: add changelog

* chore: fix typo and test

* chore: remove old changelog entry

(cherry picked from commit f110508)

# Conflicts:
#	CHANGELOG.md

* chore: fix CHANGELOG.md

---------

Co-authored-by: PaddyMc <[email protected]>
@github-actions github-actions bot mentioned this pull request Aug 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:app-wiring Changes to the app folder C:x/concentrated-liquidity V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants