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: import cycle resolution with migration records #5596

Merged
merged 17 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Types of changes (Stanzas):
"Bug Fixes" for any bug fixes.
"Client Breaking" for breaking CLI commands and REST routes used by end-users.
"API Breaking" for breaking exported APIs used by developers building on SDK.
"State Machine Breaking" for any changes that result in a different AppState
"State Machine Breaking" for any changes that result in a different AppState
given same genesisState and txList.
Ref: https://keepachangelog.com/en/1.0.0/
-->
Expand Down Expand Up @@ -61,8 +61,8 @@ ProtoRev Changes (x/protorev):
- Modifies the payment schedule for the dev account from weekly to after every trade.
- Triggers backruns, joinPool, and exitPool using hooks.

TokenFactory before send hooks (x/tokenfactory):
- This enhancement allows for executing custom logic before sending tokens, providing more flexibility
TokenFactory before send hooks (x/tokenfactory):
- This enhancement allows for executing custom logic before sending tokens, providing more flexibility
and control over token transfers.


Expand Down Expand Up @@ -100,7 +100,7 @@ and control over token transfers.
## State Breaking
* [#5380](https://github.com/osmosis-labs/osmosis/pull/5380) feat: add ica authorized messages in upgrade handler
* [#5363](https://github.com/osmosis-labs/osmosis/pull/5363) fix: twap record upgrade handler
* [#5265](https://github.com/osmosis-labs/osmosis/pull/5265) fix: expect single synthetic lock per native lock ID
* [#5265](https://github.com/osmosis-labs/osmosis/pull/5265) fix: expect single synthetic lock per native lock ID
* [#4983](https://github.com/osmosis-labs/osmosis/pull/4983) implement gas consume on denom creation
* [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Scale gas costs by denoms in gauge (AddToGaugeReward)
* [#5511](https://github.com/osmosis-labs/osmosis/pull/5511) Scale gas costs by denoms in gauge (CreateGauge)
Expand All @@ -111,12 +111,11 @@ and control over token transfers.
* [#5468](https://github.com/osmosis-labs/osmosis/pull/5468) fix: Reduce tokenfactory denom creation gas fee to 1_000_000

## Dependencies
* [#4783](https://github.com/osmosis-labs/osmosis/pull/4783) Update wasmd to 0.31
* [#5404](https://github.com/osmosis-labs/osmosis/pull/5404) Cosmwasm Cherry security patch
* [#4783](https://github.com/osmosis-labs/osmosis/pull/4783) Update wasmd to 0.31
* [#5404](https://github.com/osmosis-labs/osmosis/pull/5404) Cosmwasm Cherry security patch
* [#5320](https://github.com/osmosis-labs/osmosis/pull/5320) minor: huckleberry ibc patch

### Misc Improvements

* [#5356](https://github.com/osmosis-labs/osmosis/pull/5356) Fix wrong restHandler for ReplaceMigrationRecordsProposal
* [#5020](https://github.com/osmosis-labs/osmosis/pull/5020) Add gas config to the client.toml
* [#5105](https://github.com/osmosis-labs/osmosis/pull/5105) Lint stableswap in the same manner as all of Osmosis
Expand All @@ -136,11 +135,12 @@ and control over token transfers.
* [#5239](https://github.com/osmosis-labs/osmosis/pull/5239) Implement `GetTotalPoolShares` public keeper function for GAMM.
* [#5261](https://github.com/osmosis-labs/osmosis/pull/5261) Allows `UpdateFeeTokenProposal` to take in multiple fee tokens instead of just one.
* [#5265](https://github.com/osmosis-labs/osmosis/pull/5265) Ensure a lock cannot point to multiple synthetic locks. Deprecates `SyntheticLockupsByLockupID` in favor of `SyntheticLockupByLockupID`.
* [#4950] (https://github.com/osmosis-labs/osmosis/pull/4950) Add in/out tokens to Concentrated Liquidity's AfterConcentratedPoolSwap hook
* [#4950](https://github.com/osmosis-labs/osmosis/pull/4950) Add in/out tokens to Concentrated Liquidity's AfterConcentratedPoolSwap hook
* [#4629](https://github.com/osmosis-labs/osmosis/pull/4629) Add amino proto annotations
* [#4830](https://github.com/osmosis-labs/osmosis/pull/4830) Add gas cost when we AddToGaugeRewards, linearly increase with coins to add
* [#5000](https://github.com/osmosis-labs/osmosis/pull/5000) osmomath.Power panics for base < 1 to temporarily restrict broken logic for such base.
* [#4336](https://github.com/osmosis-labs/osmosis/pull/4336) Move epochs module into its own go.mod
* [#5589](https://github.com/osmosis-labs/osmosis/pull/5589) Include linked balancer pool in incentivized pools query



Expand Down
1 change: 1 addition & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.DistrKeeper,
appKeepers.PoolManagerKeeper,
appKeepers.EpochsKeeper,
appKeepers.GAMMKeeper,
)
appKeepers.PoolIncentivesKeeper = &poolIncentivesKeeper
appKeepers.PoolManagerKeeper.SetPoolIncentivesKeeper(appKeepers.PoolIncentivesKeeper)
Expand Down
6 changes: 3 additions & 3 deletions app/upgrades/v16/concentrated_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/osmosis-labs/osmosis/v16/app/keepers"
clmodel "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/model"
gammkeeper "github.com/osmosis-labs/osmosis/v16/x/gamm/keeper"
gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
"github.com/osmosis-labs/osmosis/v16/x/poolmanager"
poolmanagertypes "github.com/osmosis-labs/osmosis/v16/x/poolmanager/types"
)
Expand Down Expand Up @@ -70,8 +70,8 @@ func createCanonicalConcentratedLiquidityPoolAndMigrationLink(ctx sdk.Context, c

// Set the migration link in x/gamm.
// This will also migrate the CFMM distribution records to point to the new CL pool.
err = keepers.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, gammtypes.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{
err = keepers.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(ctx, gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{
BalancerPoolId: cfmmPoolId,
ClPoolId: concentratedPool.GetId(),
Expand Down
6 changes: 3 additions & 3 deletions app/upgrades/v16/concentrated_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/osmosis-labs/osmosis/v16/app/apptesting"
v16 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v16"
gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
poolincentivestypes "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types"
)

Expand Down Expand Up @@ -244,8 +244,8 @@ func (suite *ConcentratedUpgradeTestSuite) TestCreateCanonicalConcentratedLiquid
// Validate migration record.
migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx)
suite.Require().NoError(err)
suite.Require().Equal(migrationInfo, gammtypes.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{
suite.Require().Equal(migrationInfo, gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{
BalancerPoolId: balancerId,
ClPoolId: clPoolInState.GetId(),
Expand Down
20 changes: 1 addition & 19 deletions proto/osmosis/gamm/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "osmosis/gamm/v1beta1/shared.proto";

// Params holds parameters for the incentives module
message Params {
Expand All @@ -26,22 +27,3 @@ message GenesisState {
Params params = 3 [ (gogoproto.nullable) = false ];
MigrationRecords migration_records = 4;
}

// MigrationRecords contains all the links between balancer and concentrated
// pools
message MigrationRecords {
repeated BalancerToConcentratedPoolLink balancer_to_concentrated_pool_links =
1 [ (gogoproto.nullable) = false ];
}

// BalancerToConcentratedPoolLink defines a single link between a single
// balancer pool and a single concentrated liquidity pool. This link is used to
// allow a balancer pool to migrate to a single canonical full range
// concentrated liquidity pool position
// A balancer pool can be linked to a maximum of one cl pool, and a cl pool can
// be linked to a maximum of one balancer pool.
message BalancerToConcentratedPoolLink {
option (gogoproto.equal) = true;
uint64 balancer_pool_id = 1;
uint64 cl_pool_id = 2;
}
1 change: 1 addition & 0 deletions proto/osmosis/gamm/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "osmosis/gamm/v1beta1/genesis.proto";
import "osmosis/gamm/v1beta1/shared.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

Expand Down
28 changes: 28 additions & 0 deletions proto/osmosis/gamm/v1beta1/shared.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";
package osmosis.gamm.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration";

// MigrationRecords contains all the links between balancer and concentrated
// pools
message MigrationRecords {
repeated BalancerToConcentratedPoolLink balancer_to_concentrated_pool_links =
1 [ (gogoproto.nullable) = false ];
}

// BalancerToConcentratedPoolLink defines a single link between a single
// balancer pool and a single concentrated liquidity pool. This link is used to
// allow a balancer pool to migrate to a single canonical full range
// concentrated liquidity pool position
// A balancer pool can be linked to a maximum of one cl pool, and a cl pool can
// be linked to a maximum of one balancer pool.
message BalancerToConcentratedPoolLink {
option (gogoproto.equal) = true;
uint64 balancer_pool_id = 1;
uint64 cl_pool_id = 2;
}
6 changes: 3 additions & 3 deletions x/concentrated-liquidity/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
clmodel "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types"
"github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer"
gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
)

type BenchTestSuite struct {
Expand Down Expand Up @@ -102,8 +102,8 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p
gammKeeper := s.App.GAMMKeeper

// Create a link between the balancer and cl pool.
record := gammtypes.BalancerToConcentratedPoolLink{BalancerPoolId: gammPoolId, ClPoolId: clPoolId}
err = gammKeeper.ReplaceMigrationRecords(s.Ctx, []gammtypes.BalancerToConcentratedPoolLink{record})
record := gammmigration.BalancerToConcentratedPoolLink{BalancerPoolId: gammPoolId, ClPoolId: clPoolId}
err = gammKeeper.ReplaceMigrationRecords(s.Ctx, []gammmigration.BalancerToConcentratedPoolLink{record})
s.Require().NoError(err)

_, err = gammKeeper.GetLinkedConcentratedPoolID(s.Ctx, gammPoolId)
Expand Down
17 changes: 9 additions & 8 deletions x/concentrated-liquidity/incentives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types"
"github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer"
gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
poolincentivestypes "github.com/osmosis-labs/osmosis/v16/x/pool-incentives/types"
)

Expand Down Expand Up @@ -1019,8 +1020,8 @@ func (s *KeeperTestSuite) TestUpdateUptimeAccumulatorsToNow() {
// Create balancer pool and bond its shares
balancerPoolId = s.setupBalancerPoolWithFractionLocked(tc.canonicalBalancerPoolAssets, sdk.OneDec())
s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx,
gammtypes.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{
gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()},
},
},
Expand Down Expand Up @@ -3589,8 +3590,8 @@ func (s *KeeperTestSuite) TestPrepareBalancerPoolAsFullRange() {
balancerPoolId = 0
} else {
s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx,
gammtypes.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{
gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()},
},
},
Expand Down Expand Up @@ -3723,8 +3724,8 @@ func (s *KeeperTestSuite) TestPrepareBalancerPoolAsFullRangeWithNonExistentPools
}

s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx,
gammtypes.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{
gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{BalancerPoolId: balancerPoolId, ClPoolId: clPool.GetId()},
},
},
Expand Down Expand Up @@ -3891,8 +3892,8 @@ func (s *KeeperTestSuite) TestClaimAndResetFullRangeBalancerPool() {

// Link the balancer and CL pools
s.App.GAMMKeeper.OverwriteMigrationRecordsAndRedirectDistrRecords(s.Ctx,
gammtypes.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammtypes.BalancerToConcentratedPoolLink{
gammmigration.MigrationRecords{
BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{BalancerPoolId: balancerPoolId, ClPoolId: clPoolId},
},
})
Expand Down
7 changes: 4 additions & 3 deletions x/gamm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer"
"github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/stableswap"
"github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
poolmanagertypes "github.com/osmosis-labs/osmosis/v16/x/poolmanager/types"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -630,7 +631,7 @@ func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) {
return sdk.NormalizeCoins(decCoins), nil
}

func parseMigrationRecords(cmd *cobra.Command) ([]types.BalancerToConcentratedPoolLink, error) {
func parseMigrationRecords(cmd *cobra.Command) ([]gammmigration.BalancerToConcentratedPoolLink, error) {
assetsStr, err := cmd.Flags().GetString(FlagMigrationRecords)
if err != nil {
return nil, err
Expand All @@ -642,7 +643,7 @@ func parseMigrationRecords(cmd *cobra.Command) ([]types.BalancerToConcentratedPo
return nil, errors.New("migration records should be a list of balancer pool id and concentrated pool id pairs")
}

replaceMigrations := []types.BalancerToConcentratedPoolLink{}
replaceMigrations := []gammmigration.BalancerToConcentratedPoolLink{}
i := 0
for i < len(assets) {
balancerPoolId, err := strconv.Atoi(assets[i])
Expand All @@ -654,7 +655,7 @@ func parseMigrationRecords(cmd *cobra.Command) ([]types.BalancerToConcentratedPo
return nil, err
}

replaceMigrations = append(replaceMigrations, types.BalancerToConcentratedPoolLink{
replaceMigrations = append(replaceMigrations, gammmigration.BalancerToConcentratedPoolLink{
BalancerPoolId: uint64(balancerPoolId),
ClPoolId: uint64(clPoolId),
})
Expand Down
3 changes: 2 additions & 1 deletion x/gamm/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
)

// InitGenesis initializes the x/gamm module's state from a provided genesis
Expand Down Expand Up @@ -36,7 +37,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState, unpack
k.setTotalLiquidity(ctx, liquidity)

if genState.MigrationRecords == nil {
k.SetMigrationRecords(ctx, types.MigrationRecords{})
k.SetMigrationRecords(ctx, gammmigration.MigrationRecords{})
} else {
k.SetMigrationRecords(ctx, *genState.MigrationRecords)
}
Expand Down
3 changes: 2 additions & 1 deletion x/gamm/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

"github.com/osmosis-labs/osmosis/v16/x/gamm/pool-models/balancer"
"github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammmigration "github.com/osmosis-labs/osmosis/v16/x/gamm/types/migration"
)

var DefaultMigrationRecords = types.MigrationRecords{BalancerToConcentratedPoolLinks: []types.BalancerToConcentratedPoolLink{
var DefaultMigrationRecords = gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{
{BalancerPoolId: 1, ClPoolId: 4},
{BalancerPoolId: 2, ClPoolId: 5},
{BalancerPoolId: 3, ClPoolId: 6},
Expand Down
Loading