From 2141355ed51a452fd6e725ba4e01838099e8d5f9 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Thu, 13 Apr 2023 20:15:03 -0700 Subject: [PATCH 1/6] added wrapper --- .../concentrated-liquidity/genesis.proto | 5 +- x/concentrated-liquidity/genesis.go | 13 +- x/concentrated-liquidity/genesis_test.go | 12 ++ .../types/genesis/genesis.pb.go | 134 +++++++++++------- 4 files changed, 113 insertions(+), 51 deletions(-) diff --git a/proto/osmosis/concentrated-liquidity/genesis.proto b/proto/osmosis/concentrated-liquidity/genesis.proto index 9ad7e880552..566d271841b 100644 --- a/proto/osmosis/concentrated-liquidity/genesis.proto +++ b/proto/osmosis/concentrated-liquidity/genesis.proto @@ -57,7 +57,10 @@ message GenesisState { repeated Position positions = 3 [ (gogoproto.nullable) = false ]; - uint64 next_position_id = 4 + uint64 position_lock_id = 4 + [ (gogoproto.moretags) = "yaml:\"position_lock_id\"" ]; + + uint64 next_position_id = 5 [ (gogoproto.moretags) = "yaml:\"next_position_id\"" ]; } diff --git a/x/concentrated-liquidity/genesis.go b/x/concentrated-liquidity/genesis.go index 4cfb11cc575..aa8594baf76 100644 --- a/x/concentrated-liquidity/genesis.go +++ b/x/concentrated-liquidity/genesis.go @@ -7,10 +7,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/osmoutils/accum" + "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/model" types "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types/genesis" ) +type PositionWrapper struct { + Position model.Position + LockId uint64 +} + // InitGenesis initializes the concentrated-liquidity module with the provided genesis state. func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) { k.SetParams(ctx, genState.Params) @@ -64,8 +70,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) { panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", position.PoolId)) } + pos := PositionWrapper{ + Position: position, + LockId: genState.PositionLockId, + } + // We hardcode the underlying lock id to 0, because genesisState should already hold the positionId to lockId connections - err := k.SetPosition(ctx, position.PoolId, sdk.MustAccAddressFromBech32(position.Address), position.LowerTick, position.UpperTick, position.JoinTime, position.Liquidity, position.PositionId, 0) + err := k.SetPosition(ctx, pos.Position.PoolId, sdk.MustAccAddressFromBech32(pos.Position.Address), pos.Position.LowerTick, pos.Position.UpperTick, pos.Position.JoinTime, pos.Position.Liquidity, pos.Position.PositionId, pos.LockId) if err != nil { panic(err) } diff --git a/x/concentrated-liquidity/genesis_test.go b/x/concentrated-liquidity/genesis_test.go index 9790bc17b8d..901c2e7dbc6 100644 --- a/x/concentrated-liquidity/genesis_test.go +++ b/x/concentrated-liquidity/genesis_test.go @@ -138,6 +138,7 @@ func setupGenesis(baseGenesis genesis.GenesisState, poolGenesisEntries []singleP IncentiveRecords: poolGenesisEntry.incentiveRecords, }) baseGenesis.Positions = append(baseGenesis.Positions, poolGenesisEntry.positions...) + baseGenesis.PositionLockId = uint64(len(poolGenesisEntry.positions)) baseGenesis.NextPositionId = uint64(len(poolGenesisEntry.positions)) } @@ -465,6 +466,11 @@ func (s *KeeperTestSuite) TestInitGenesis() { } // Validate next position id. s.Require().Equal(tc.genesis.NextPositionId, clKeeper.GetNextPositionId(ctx)) + + lockId, err := clKeeper.GetPositionIdToLock(ctx, baseCase.positionId) + s.Require().NoError(err) + + s.Require().Equal(tc.genesis.PositionLockId, lockId) }) } } @@ -652,6 +658,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { // Validate next position id. s.Require().Equal(tc.genesis.NextPositionId, actualExported.NextPositionId) + + // validate position lockId + lockId, err := clKeeper.GetPositionIdToLock(ctx, baseCase.positionId) + s.Require().NoError(err) + + s.Require().Equal(tc.genesis.PositionLockId, lockId) }) } } diff --git a/x/concentrated-liquidity/types/genesis/genesis.pb.go b/x/concentrated-liquidity/types/genesis/genesis.pb.go index 0b1227d0fa4..fe7abefd1f7 100644 --- a/x/concentrated-liquidity/types/genesis/genesis.pb.go +++ b/x/concentrated-liquidity/types/genesis/genesis.pb.go @@ -182,7 +182,8 @@ type GenesisState struct { // pool data containining serialized pool struct and ticks. PoolData []PoolData `protobuf:"bytes,2,rep,name=pool_data,json=poolData,proto3" json:"pool_data"` Positions []model.Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions"` - NextPositionId uint64 `protobuf:"varint,4,opt,name=next_position_id,json=nextPositionId,proto3" json:"next_position_id,omitempty" yaml:"next_position_id"` + PositionLockId uint64 `protobuf:"varint,4,opt,name=position_lock_id,json=positionLockId,proto3" json:"position_lock_id,omitempty" yaml:"position_lock_id"` + NextPositionId uint64 `protobuf:"varint,5,opt,name=next_position_id,json=nextPositionId,proto3" json:"next_position_id,omitempty" yaml:"next_position_id"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -239,6 +240,13 @@ func (m *GenesisState) GetPositions() []model.Position { return nil } +func (m *GenesisState) GetPositionLockId() uint64 { + if m != nil { + return m.PositionLockId + } + return 0 +} + func (m *GenesisState) GetNextPositionId() uint64 { if m != nil { return m.NextPositionId @@ -311,54 +319,55 @@ func init() { } var fileDescriptor_5c140d686ee6724a = []byte{ - // 740 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x6e, 0x13, 0x3b, - 0x14, 0xce, 0x34, 0xd3, 0xde, 0xc6, 0xe9, 0xed, 0x8f, 0xd5, 0xdb, 0xce, 0xed, 0xd5, 0x9d, 0x84, - 0x41, 0x95, 0x8a, 0x4a, 0x66, 0xd4, 0x94, 0xb2, 0x60, 0xd7, 0x29, 0x3f, 0x0a, 0x0b, 0xa8, 0xa6, - 0x5d, 0x81, 0x50, 0xe4, 0xcc, 0x38, 0xc1, 0x74, 0x62, 0x87, 0xd8, 0xa9, 0x12, 0xb1, 0xe3, 0x09, - 0x10, 0x3b, 0xde, 0x83, 0x37, 0x60, 0x53, 0x21, 0x16, 0x5d, 0xb2, 0x8a, 0x50, 0xfb, 0x06, 0x79, - 0x02, 0x34, 0xb6, 0x27, 0x49, 0x2b, 0x50, 0x52, 0x76, 0x63, 0x9f, 0xef, 0xfb, 0xce, 0x77, 0xec, - 0xe3, 0x33, 0xe0, 0x2e, 0xe3, 0x4d, 0xc6, 0x09, 0xf7, 0x42, 0x46, 0x43, 0x4c, 0x45, 0x1b, 0x09, - 0x1c, 0x95, 0x62, 0xf2, 0xb6, 0x43, 0x22, 0x22, 0x7a, 0x5e, 0x03, 0x53, 0xcc, 0x09, 0x77, 0x5b, - 0x6d, 0x26, 0x18, 0xdc, 0xd4, 0x68, 0x77, 0x1c, 0x3d, 0x04, 0xbb, 0xa7, 0x3b, 0x35, 0x2c, 0xd0, - 0xce, 0xc6, 0x6a, 0x83, 0x35, 0x98, 0x64, 0x78, 0xc9, 0x97, 0x22, 0x6f, 0xfc, 0x1b, 0x4a, 0x76, - 0x55, 0x05, 0xd4, 0x42, 0x87, 0x6c, 0xb5, 0xf2, 0x6a, 0x88, 0x63, 0x4f, 0xab, 0x78, 0x21, 0x23, - 0x34, 0xa5, 0x36, 0x18, 0x6b, 0xc4, 0xd8, 0x93, 0xab, 0x5a, 0xa7, 0xee, 0x21, 0xda, 0xd3, 0xa1, - 0x5b, 0x69, 0x01, 0x28, 0x0c, 0x3b, 0xcd, 0x21, 0x59, 0xae, 0x34, 0x64, 0x7b, 0x42, 0x8d, 0x2d, - 0xd4, 0x46, 0xcd, 0xd4, 0x4a, 0x69, 0x12, 0x98, 0x71, 0x22, 0x08, 0xa3, 0x53, 0xc2, 0x05, 0x09, - 0x4f, 0x2a, 0xb4, 0x9e, 0x9e, 0xc1, 0xde, 0x04, 0x38, 0x91, 0xbb, 0xe4, 0x14, 0x57, 0xdb, 0x38, - 0x64, 0xed, 0x48, 0xd1, 0x9c, 0x6f, 0x06, 0x98,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, 0xdb, 0xc0, 0xa4, 0xa8, 0x89, 0xe5, 0x11, 0xe6, 0xfc, 0xa5, 0x41, - 0xbf, 0x90, 0xd7, 0x52, 0xa8, 0x89, 0x9d, 0x40, 0x06, 0xe1, 0x33, 0xf0, 0xb7, 0xec, 0x86, 0x6a, - 0xc8, 0xa8, 0xc0, 0x54, 0xc8, 0x71, 0x91, 0x2f, 0xdf, 0x19, 0x16, 0xa5, 0x86, 0xea, 0x95, 0xfe, - 0x52, 0x1d, 0x72, 0xa0, 0x08, 0xc1, 0x82, 0x44, 0xe8, 0x95, 0x1f, 0x9d, 0x5d, 0xd8, 0xc6, 0xf9, - 0x85, 0x6d, 0xfc, 0xb8, 0xb0, 0x8d, 0x0f, 0x97, 0x76, 0xe6, 0xfc, 0xd2, 0xce, 0x7c, 0xbf, 0xb4, - 0x33, 0x2f, 0x9e, 0x36, 0x88, 0x78, 0xdd, 0xa9, 0xb9, 0x21, 0x6b, 0x7a, 0x5a, 0xbc, 0x14, 0xa3, - 0x1a, 0x4f, 0x17, 0xde, 0xe9, 0xce, 0x9e, 0xd7, 0xfd, 0xed, 0x4c, 0xed, 0xb5, 0x30, 0x4f, 0xff, - 0x4c, 0xb5, 0x39, 0x39, 0x29, 0x76, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x76, 0x72, 0xdb, 0xb7, - 0xca, 0x06, 0x00, 0x00, + // 760 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x6e, 0xd6, 0x74, 0xac, 0xee, 0xe8, 0xb6, 0x68, 0x6c, 0x61, 0x88, 0xb4, 0x04, 0x4d, 0x1a, + 0x1a, 0x4d, 0xb4, 0x8e, 0x71, 0xe0, 0xb6, 0x8c, 0x0f, 0x15, 0x21, 0x98, 0xb2, 0x9d, 0x40, 0x28, + 0x72, 0x13, 0xb7, 0x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x82, 0xf8, 0x27, 0x95, 0x20, 0x96, 0x89, 0x50, 0x87, + 0x79, 0x03, 0x24, 0x0e, 0xf4, 0xcc, 0xa4, 0xcc, 0x24, 0xc2, 0x74, 0xf3, 0xf1, 0x52, 0x62, 0xae, + 0x12, 0x98, 0x9f, 0x14, 0x90, 0x1b, 0x69, 0x23, 0xed, 0x2e, 0x50, 0x23, 0xd8, 0x40, 0xfc, 0x26, + 0xb2, 0xce, 0x52, 0xbf, 0x57, 0xc8, 0x49, 0x29, 0xd8, 0x40, 0xa6, 0xcb, 0x93, 0xda, 0x4b, 0x70, + 0x9d, 0x37, 0x95, 0xe7, 0x93, 0x88, 0xa1, 0x88, 0xf1, 0xa9, 0x93, 0x2b, 0xdf, 0x1b, 0x9c, 0x8d, + 0x98, 0xcd, 0x63, 0x6d, 0x2a, 0x1a, 0xed, 0x40, 0x10, 0xdc, 0x45, 0x8e, 0x90, 0x91, 0x13, 0x9c, + 0x5d, 0x18, 0xca, 0xf9, 0x85, 0xa1, 0xfc, 0xbe, 0x30, 0x94, 0x2f, 0x97, 0x46, 0xea, 0xfc, 0xd2, + 0x48, 0xfd, 0xba, 0x34, 0x52, 0xaf, 0x9f, 0xd7, 0x31, 0x7b, 0xd7, 0xae, 0x5a, 0x3e, 0x69, 0xd8, + 0x52, 0xbc, 0x14, 0xc2, 0x2a, 0x4d, 0x02, 0xfb, 0x74, 0x67, 0xcf, 0xee, 0xfc, 0x73, 0x34, 0x77, + 0x9b, 0x88, 0x26, 0x3f, 0xb8, 0xea, 0x3c, 0x1f, 0x38, 0xbb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, + 0xd7, 0xb9, 0xc4, 0xfe, 0x11, 0x07, 0x00, 0x00, } func (m *FullTick) Marshal() (dAtA []byte, err error) { @@ -514,6 +523,11 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.NextPositionId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.NextPositionId)) i-- + dAtA[i] = 0x28 + } + if m.PositionLockId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PositionLockId)) + i-- dAtA[i] = 0x20 } if len(m.Positions) > 0 { @@ -680,6 +694,9 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.PositionLockId != 0 { + n += 1 + sovGenesis(uint64(m.PositionLockId)) + } if m.NextPositionId != 0 { n += 1 + sovGenesis(uint64(m.NextPositionId)) } @@ -1182,6 +1199,25 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionLockId", wireType) + } + m.PositionLockId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PositionLockId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field NextPositionId", wireType) } From e376a98cc6fa96a1d7faaa7566b08f005cc78d08 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Thu, 13 Apr 2023 20:22:05 -0700 Subject: [PATCH 2/6] improved test --- x/concentrated-liquidity/genesis_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/x/concentrated-liquidity/genesis_test.go b/x/concentrated-liquidity/genesis_test.go index 901c2e7dbc6..0cf5d0c95c1 100644 --- a/x/concentrated-liquidity/genesis_test.go +++ b/x/concentrated-liquidity/genesis_test.go @@ -26,6 +26,7 @@ type singlePoolGenesisEntry struct { feeAccumValues genesis.AccumObject incentiveAccumulators []genesis.AccumObject incentiveRecords []types.IncentiveRecord + positionId uint64 } var ( @@ -138,7 +139,7 @@ func setupGenesis(baseGenesis genesis.GenesisState, poolGenesisEntries []singleP IncentiveRecords: poolGenesisEntry.incentiveRecords, }) baseGenesis.Positions = append(baseGenesis.Positions, poolGenesisEntry.positions...) - baseGenesis.PositionLockId = uint64(len(poolGenesisEntry.positions)) + baseGenesis.PositionLockId = uint64(poolGenesisEntry.positionId) baseGenesis.NextPositionId = uint64(len(poolGenesisEntry.positions)) } @@ -211,6 +212,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, + positionId: DefaultPositionId, }, }), expectedPools: []model.Pool{ @@ -287,6 +289,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, + positionId: DefaultPositionId, }, { pool: *poolTwo, @@ -316,6 +319,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, + positionId: DefaultPositionId + 1, }, }), expectedPools: []model.Pool{ @@ -537,6 +541,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { MinUptime: testUptimeOne, }, }, + positionId: DefaultPositionId, }, }), }, @@ -570,6 +575,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { MinUptime: testUptimeOne, }, }, + positionId: DefaultPositionId, }, { pool: *poolTwo, @@ -598,7 +604,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { MinUptime: testUptimeOne, }, }, - positions: []model.Position{withPositionId(positionWithPoolId(testPositionModel, 2), DefaultPositionId+1)}, + positions: []model.Position{withPositionId(positionWithPoolId(testPositionModel, 2), DefaultPositionId+1)}, + positionId: DefaultPositionId + 1, }, }), }, From 8f4ae55bc6bea868b1d7c9b34f4244626907a381 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Fri, 14 Apr 2023 14:11:53 -0700 Subject: [PATCH 3/6] roman comments --- .../concentrated-liquidity/genesis.proto | 12 +- x/concentrated-liquidity/genesis.go | 39 +- x/concentrated-liquidity/genesis_test.go | 114 ++++-- .../types/genesis/genesis.pb.go | 371 +++++++++++++----- 4 files changed, 382 insertions(+), 154 deletions(-) diff --git a/proto/osmosis/concentrated-liquidity/genesis.proto b/proto/osmosis/concentrated-liquidity/genesis.proto index 566d271841b..0b4715b21ab 100644 --- a/proto/osmosis/concentrated-liquidity/genesis.proto +++ b/proto/osmosis/concentrated-liquidity/genesis.proto @@ -48,6 +48,11 @@ message PoolData { [ (gogoproto.nullable) = false ]; } +message PositionData { + Position position = 1; + uint64 lock_id = 2 [ (gogoproto.moretags) = "yaml:\"lock_id\"" ]; +} + // GenesisState defines the concentrated liquidity module's genesis state. message GenesisState { // params are all the parameters of the module @@ -55,12 +60,9 @@ message GenesisState { // pool data containining serialized pool struct and ticks. repeated PoolData pool_data = 2 [ (gogoproto.nullable) = false ]; - repeated Position positions = 3 [ (gogoproto.nullable) = false ]; - - uint64 position_lock_id = 4 - [ (gogoproto.moretags) = "yaml:\"position_lock_id\"" ]; + repeated PositionData position_data = 3 [ (gogoproto.nullable) = false ]; - uint64 next_position_id = 5 + uint64 next_position_id = 4 [ (gogoproto.moretags) = "yaml:\"next_position_id\"" ]; } diff --git a/x/concentrated-liquidity/genesis.go b/x/concentrated-liquidity/genesis.go index aa8594baf76..9bd7de12b5b 100644 --- a/x/concentrated-liquidity/genesis.go +++ b/x/concentrated-liquidity/genesis.go @@ -7,16 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/osmoutils/accum" - "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/model" types "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types/genesis" ) -type PositionWrapper struct { - Position model.Position - LockId uint64 -} - // InitGenesis initializes the concentrated-liquidity module with the provided genesis state. func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) { k.SetParams(ctx, genState.Params) @@ -65,18 +59,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) { } // set positions for pool - for _, position := range genState.Positions { - if _, ok := seenPoolIds[position.PoolId]; !ok { - panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", position.PoolId)) - } - - pos := PositionWrapper{ - Position: position, - LockId: genState.PositionLockId, + for _, position := range genState.PositionData { + if _, ok := seenPoolIds[position.Position.PoolId]; !ok { + panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", position.Position.PoolId)) } // We hardcode the underlying lock id to 0, because genesisState should already hold the positionId to lockId connections - err := k.SetPosition(ctx, pos.Position.PoolId, sdk.MustAccAddressFromBech32(pos.Position.Address), pos.Position.LowerTick, pos.Position.UpperTick, pos.Position.JoinTime, pos.Position.Liquidity, pos.Position.PositionId, pos.LockId) + err := k.SetPosition(ctx, position.Position.PoolId, sdk.MustAccAddressFromBech32(position.Position.Address), position.Position.LowerTick, position.Position.UpperTick, position.Position.JoinTime, position.Position.Liquidity, position.Position.PositionId, position.LockId) if err != nil { panic(err) } @@ -163,10 +152,28 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *genesis.GenesisState { panic(err) } + positionData := make([]genesis.PositionData, 0, len(positions)) + for _, position := range positions { + getPosition, err := k.GetPosition(ctx, position.PositionId) + if err != nil { + panic(err) + } + + lockId, err := k.GetPositionIdToLock(ctx, position.PositionId) + if err != nil { + panic(err) + } + + positionData = append(positionData, genesis.PositionData{ + LockId: lockId, + Position: &getPosition, + }) + } + return &genesis.GenesisState{ Params: k.GetParams(ctx), PoolData: poolData, - Positions: positions, + PositionData: positionData, NextPositionId: k.GetNextPositionId(ctx), } } diff --git a/x/concentrated-liquidity/genesis_test.go b/x/concentrated-liquidity/genesis_test.go index 0cf5d0c95c1..6c63595eeef 100644 --- a/x/concentrated-liquidity/genesis_test.go +++ b/x/concentrated-liquidity/genesis_test.go @@ -22,11 +22,10 @@ import ( type singlePoolGenesisEntry struct { pool model.Pool tick []genesis.FullTick - positions []model.Position + positionData []genesis.PositionData feeAccumValues genesis.AccumObject incentiveAccumulators []genesis.AccumObject incentiveRecords []types.IncentiveRecord - positionId uint64 } var ( @@ -63,14 +62,14 @@ var ( } ) -func positionWithPoolId(position model.Position, poolId uint64) model.Position { +func positionWithPoolId(position model.Position, poolId uint64) *model.Position { position.PoolId = poolId - return position + return &position } -func withPositionId(position model.Position, positionId uint64) model.Position { +func withPositionId(position model.Position, positionId uint64) *model.Position { position.PositionId = positionId - return position + return &position } func incentiveAccumsWithPoolId(poolId uint64) []genesis.AccumObject { @@ -138,10 +137,8 @@ func setupGenesis(baseGenesis genesis.GenesisState, poolGenesisEntries []singleP IncentivesAccumulators: poolGenesisEntry.incentiveAccumulators, IncentiveRecords: poolGenesisEntry.incentiveRecords, }) - baseGenesis.Positions = append(baseGenesis.Positions, poolGenesisEntry.positions...) - baseGenesis.PositionLockId = uint64(poolGenesisEntry.positionId) - baseGenesis.NextPositionId = uint64(len(poolGenesisEntry.positions)) - + baseGenesis.PositionData = append(baseGenesis.PositionData, poolGenesisEntry.positionData...) + baseGenesis.NextPositionId = uint64(len(poolGenesisEntry.positionData)) } return baseGenesis } @@ -166,7 +163,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { genesis genesis.GenesisState expectedPools []model.Pool expectedTicksPerPoolId map[uint64][]genesis.FullTick - expectedPositions []model.Position + expectedPositionData []genesis.PositionData expectedfeeAccumValues []genesis.AccumObject expectedIncentiveRecords []types.IncentiveRecord }{ @@ -179,7 +176,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { withTickIndex(withPoolId(defaultFullTick, poolOne.Id), -10), withTickIndex(withPoolId(defaultFullTick, poolOne.Id), 10), }, - positions: []model.Position{testPositionModel}, + positionData: []genesis.PositionData{ + { + LockId: 1, + Position: &testPositionModel, + }, + }, feeAccumValues: genesis.AccumObject{ Name: types.KeyFeePoolAccumulator(1), AccumContent: &accum.AccumulatorContent{ @@ -212,7 +214,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, - positionId: DefaultPositionId, }, }), expectedPools: []model.Pool{ @@ -224,7 +225,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { withTickIndex(withPoolId(defaultFullTick, poolOne.Id), 10), }, }, - expectedPositions: []model.Position{testPositionModel}, + expectedPositionData: []genesis.PositionData{ + { + LockId: 1, + Position: &testPositionModel, + }, + }, expectedfeeAccumValues: []genesis.AccumObject{ { Name: types.KeyFeePoolAccumulator(1), @@ -267,7 +273,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { tick: []genesis.FullTick{ withTickIndex(withPoolId(defaultFullTick, poolOne.Id), -1234), }, - positions: []model.Position{testPositionModel}, + positionData: []genesis.PositionData{ + { + LockId: 1, + Position: &testPositionModel, + }, + }, feeAccumValues: genesis.AccumObject{ Name: types.KeyFeePoolAccumulator(1), AccumContent: &accum.AccumulatorContent{ @@ -289,7 +300,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, - positionId: DefaultPositionId, }, { pool: *poolTwo, @@ -297,7 +307,13 @@ func (s *KeeperTestSuite) TestInitGenesis() { withTickIndex(withPoolId(defaultFullTick, poolOne.Id), 0), withTickIndex(withPoolId(defaultFullTick, poolOne.Id), 999), }, - positions: []model.Position{withPositionId(positionWithPoolId(testPositionModel, 2), DefaultPositionId+1)}, + positionData: []genesis.PositionData{ + { + LockId: 2, + Position: withPositionId(*positionWithPoolId(testPositionModel, 2), DefaultPositionId+1), + }, + }, + feeAccumValues: genesis.AccumObject{ Name: types.KeyFeePoolAccumulator(2), AccumContent: &accum.AccumulatorContent{ @@ -319,7 +335,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, - positionId: DefaultPositionId + 1, }, }), expectedPools: []model.Pool{ @@ -375,7 +390,16 @@ func (s *KeeperTestSuite) TestInitGenesis() { MinUptime: testUptimeOne, }, }, - expectedPositions: []model.Position{testPositionModel, withPositionId(positionWithPoolId(testPositionModel, 2), DefaultPositionId+1)}, + expectedPositionData: []genesis.PositionData{ + { + LockId: 1, + Position: &testPositionModel, + }, + { + LockId: 2, + Position: withPositionId(*positionWithPoolId(testPositionModel, 2), DefaultPositionId+1), + }, + }, }, } @@ -443,9 +467,22 @@ func (s *KeeperTestSuite) TestInitGenesis() { // get all positions. positions, err := clKeeper.GetAllPositions(ctx) s.Require().NoError(err) + var positionData []genesis.PositionData + for _, position := range positions { + getPosition, err := clKeeper.GetPosition(ctx, position.PositionId) + s.Require().NoError(err) + + lockId, err := clKeeper.GetPositionIdToLock(ctx, position.PositionId) + s.Require().NoError(err) + + positionData = append(positionData, genesis.PositionData{ + LockId: lockId, + Position: &getPosition, + }) + } // Validate positions - s.Require().Equal(tc.expectedPositions, positions) + s.Require().Equal(tc.expectedPositionData, positionData) // Validate accum objects s.Require().Equal(len(feeAccums), len(tc.expectedfeeAccumValues)) @@ -470,11 +507,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { } // Validate next position id. s.Require().Equal(tc.genesis.NextPositionId, clKeeper.GetNextPositionId(ctx)) - - lockId, err := clKeeper.GetPositionIdToLock(ctx, baseCase.positionId) - s.Require().NoError(err) - - s.Require().Equal(tc.genesis.PositionLockId, lockId) }) } } @@ -508,7 +540,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { withTickIndex(withPoolId(defaultFullTick, poolOne.Id), -10), withTickIndex(withPoolId(defaultFullTick, poolOne.Id), 10), }, - positions: []model.Position{testPositionModel}, + positionData: []genesis.PositionData{ + { + LockId: 1, + Position: &testPositionModel, + }, + }, feeAccumValues: genesis.AccumObject{ Name: types.KeyFeePoolAccumulator(poolOne.Id), AccumContent: &accum.AccumulatorContent{ @@ -541,7 +578,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { MinUptime: testUptimeOne, }, }, - positionId: DefaultPositionId, }, }), }, @@ -553,7 +589,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { tick: []genesis.FullTick{ withTickIndex(withPoolId(defaultFullTick, poolOne.Id), -1234), }, - positions: []model.Position{testPositionModel}, + positionData: []genesis.PositionData{ + { + LockId: 1, + Position: &testPositionModel, + }, + }, feeAccumValues: genesis.AccumObject{ Name: types.KeyFeePoolAccumulator(poolOne.Id), AccumContent: &accum.AccumulatorContent{ @@ -575,7 +616,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { MinUptime: testUptimeOne, }, }, - positionId: DefaultPositionId, }, { pool: *poolTwo, @@ -604,8 +644,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { MinUptime: testUptimeOne, }, }, - positions: []model.Position{withPositionId(positionWithPoolId(testPositionModel, 2), DefaultPositionId+1)}, - positionId: DefaultPositionId + 1, + positionData: []genesis.PositionData{ + { + LockId: 2, + Position: withPositionId(*positionWithPoolId(testPositionModel, 2), DefaultPositionId+1), + }, + }, }, }), }, @@ -661,16 +705,10 @@ func (s *KeeperTestSuite) TestExportGenesis() { } // Validate positions. - s.Require().Equal(tc.genesis.Positions, actualExported.Positions) + s.Require().Equal(tc.genesis.PositionData, actualExported.PositionData) // Validate next position id. s.Require().Equal(tc.genesis.NextPositionId, actualExported.NextPositionId) - - // validate position lockId - lockId, err := clKeeper.GetPositionIdToLock(ctx, baseCase.positionId) - s.Require().NoError(err) - - s.Require().Equal(tc.genesis.PositionLockId, lockId) }) } } diff --git a/x/concentrated-liquidity/types/genesis/genesis.pb.go b/x/concentrated-liquidity/types/genesis/genesis.pb.go index fe7abefd1f7..b19ceff75c2 100644 --- a/x/concentrated-liquidity/types/genesis/genesis.pb.go +++ b/x/concentrated-liquidity/types/genesis/genesis.pb.go @@ -175,22 +175,73 @@ func (m *PoolData) GetIncentiveRecords() []types1.IncentiveRecord { return nil } +type PositionData struct { + Position *model.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + LockId uint64 `protobuf:"varint,2,opt,name=lock_id,json=lockId,proto3" json:"lock_id,omitempty" yaml:"lock_id"` +} + +func (m *PositionData) Reset() { *m = PositionData{} } +func (m *PositionData) String() string { return proto.CompactTextString(m) } +func (*PositionData) ProtoMessage() {} +func (*PositionData) Descriptor() ([]byte, []int) { + return fileDescriptor_5c140d686ee6724a, []int{2} +} +func (m *PositionData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PositionData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PositionData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PositionData) XXX_Merge(src proto.Message) { + xxx_messageInfo_PositionData.Merge(m, src) +} +func (m *PositionData) XXX_Size() int { + return m.Size() +} +func (m *PositionData) XXX_DiscardUnknown() { + xxx_messageInfo_PositionData.DiscardUnknown(m) +} + +var xxx_messageInfo_PositionData proto.InternalMessageInfo + +func (m *PositionData) GetPosition() *model.Position { + if m != nil { + return m.Position + } + return nil +} + +func (m *PositionData) GetLockId() uint64 { + if m != nil { + return m.LockId + } + return 0 +} + // GenesisState defines the concentrated liquidity module's genesis state. type GenesisState struct { // params are all the parameters of the module Params types1.Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` // pool data containining serialized pool struct and ticks. - PoolData []PoolData `protobuf:"bytes,2,rep,name=pool_data,json=poolData,proto3" json:"pool_data"` - Positions []model.Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions"` - PositionLockId uint64 `protobuf:"varint,4,opt,name=position_lock_id,json=positionLockId,proto3" json:"position_lock_id,omitempty" yaml:"position_lock_id"` - NextPositionId uint64 `protobuf:"varint,5,opt,name=next_position_id,json=nextPositionId,proto3" json:"next_position_id,omitempty" yaml:"next_position_id"` + PoolData []PoolData `protobuf:"bytes,2,rep,name=pool_data,json=poolData,proto3" json:"pool_data"` + PositionData []PositionData `protobuf:"bytes,3,rep,name=position_data,json=positionData,proto3" json:"position_data"` + NextPositionId uint64 `protobuf:"varint,4,opt,name=next_position_id,json=nextPositionId,proto3" json:"next_position_id,omitempty" yaml:"next_position_id"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_5c140d686ee6724a, []int{2} + return fileDescriptor_5c140d686ee6724a, []int{3} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -233,20 +284,13 @@ func (m *GenesisState) GetPoolData() []PoolData { return nil } -func (m *GenesisState) GetPositions() []model.Position { +func (m *GenesisState) GetPositionData() []PositionData { if m != nil { - return m.Positions + return m.PositionData } return nil } -func (m *GenesisState) GetPositionLockId() uint64 { - if m != nil { - return m.PositionLockId - } - return 0 -} - func (m *GenesisState) GetNextPositionId() uint64 { if m != nil { return m.NextPositionId @@ -264,7 +308,7 @@ func (m *AccumObject) Reset() { *m = AccumObject{} } func (m *AccumObject) String() string { return proto.CompactTextString(m) } func (*AccumObject) ProtoMessage() {} func (*AccumObject) Descriptor() ([]byte, []int) { - return fileDescriptor_5c140d686ee6724a, []int{3} + return fileDescriptor_5c140d686ee6724a, []int{4} } func (m *AccumObject) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -310,6 +354,7 @@ func (m *AccumObject) GetAccumContent() *accum.AccumulatorContent { func init() { proto.RegisterType((*FullTick)(nil), "osmosis.concentratedliquidity.v1beta1.FullTick") proto.RegisterType((*PoolData)(nil), "osmosis.concentratedliquidity.v1beta1.PoolData") + proto.RegisterType((*PositionData)(nil), "osmosis.concentratedliquidity.v1beta1.PositionData") proto.RegisterType((*GenesisState)(nil), "osmosis.concentratedliquidity.v1beta1.GenesisState") proto.RegisterType((*AccumObject)(nil), "osmosis.concentratedliquidity.v1beta1.AccumObject") } @@ -319,55 +364,57 @@ func init() { } var fileDescriptor_5c140d686ee6724a = []byte{ - // 760 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4d, 0x6f, 0xd3, 0x30, - 0x18, 0x6e, 0xd6, 0x74, 0xac, 0xee, 0xe8, 0xb6, 0x68, 0x6c, 0x61, 0x88, 0xb4, 0x04, 0x4d, 0x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xbf, 0x9b, 0x40, 0x57, 0xf9, 0x2b, 0xbf, 0xd5, 0xef, 0x15, 0xd6, 0x93, 0x57, - 0x3e, 0x8e, 0x30, 0xdd, 0x7c, 0xb2, 0xf4, 0x82, 0xf8, 0x27, 0x95, 0x20, 0x96, 0x89, 0x50, 0x87, - 0x79, 0x03, 0x24, 0x0e, 0xf4, 0xcc, 0xa4, 0xcc, 0x24, 0xc2, 0x74, 0xf3, 0xf1, 0x52, 0x62, 0xae, - 0x12, 0x98, 0x9f, 0x14, 0x90, 0x1b, 0x69, 0x23, 0xed, 0x2e, 0x50, 0x23, 0xd8, 0x40, 0xfc, 0x26, - 0xb2, 0xce, 0x52, 0xbf, 0x57, 0xc8, 0x49, 0x29, 0xd8, 0x40, 0xa6, 0xcb, 0x93, 0xda, 0x4b, 0x70, - 0x9d, 0x37, 0x95, 0xe7, 0x93, 0x88, 0xa1, 0x88, 0xf1, 0xa9, 0x93, 0x2b, 0xdf, 0x1b, 0x9c, 0x8d, - 0x98, 0xcd, 0x63, 0x6d, 0x2a, 0x1a, 0xed, 0x40, 0x10, 0xdc, 0x45, 0x8e, 0x90, 0x91, 0x13, 0x9c, - 0x5d, 0x18, 0xca, 0xf9, 0x85, 0xa1, 0xfc, 0xbe, 0x30, 0x94, 0x2f, 0x97, 0x46, 0xea, 0xfc, 0xd2, - 0x48, 0xfd, 0xba, 0x34, 0x52, 0xaf, 0x9f, 0xd7, 0x31, 0x7b, 0xd7, 0xae, 0x5a, 0x3e, 0x69, 0xd8, - 0x52, 0xbc, 0x14, 0xc2, 0x2a, 0x4d, 0x02, 0xfb, 0x74, 0x67, 0xcf, 0xee, 0xfc, 0x73, 0x34, 0x77, - 0x9b, 0x88, 0x26, 0x3f, 0xb8, 0xea, 0x3c, 0x1f, 0x38, 0xbb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, - 0xd7, 0xb9, 0xc4, 0xfe, 0x11, 0x07, 0x00, 0x00, + // 787 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcb, 0x6e, 0xdb, 0x38, + 0x14, 0xb5, 0x62, 0xc5, 0x63, 0xd3, 0xce, 0x4b, 0xc8, 0x24, 0x9a, 0x0c, 0x46, 0xf6, 0x68, 0x10, + 0x20, 0x83, 0x8c, 0x25, 0xc4, 0x99, 0xcc, 0x62, 0x76, 0x51, 0xfa, 0x80, 0x5b, 0xa0, 0x0d, 0xd4, + 0xac, 0x5a, 0xb4, 0x06, 0x2d, 0xd1, 0x2e, 0x1b, 0x59, 0x74, 0x4d, 0x3a, 0xb0, 0xd1, 0x5d, 0x57, + 0x5d, 0x16, 0xdd, 0xf5, 0x3f, 0xfa, 0x11, 0x41, 0x51, 0x14, 0x59, 0x76, 0x65, 0x14, 0xc9, 0x1f, + 0xf8, 0x0b, 0x0a, 0xf1, 0xe1, 0x47, 0xd0, 0xc2, 0x4e, 0x77, 0x22, 0xef, 0x39, 0x87, 0xe7, 0x5e, + 0xde, 0x4b, 0x81, 0x7f, 0x08, 0x6d, 0x11, 0x8a, 0xa9, 0x1b, 0x90, 0x38, 0x40, 0x31, 0xeb, 0x40, + 0x86, 0xc2, 0x72, 0x84, 0x5f, 0x76, 0x71, 0x88, 0x59, 0xdf, 0x6d, 0xa2, 0x18, 0x51, 0x4c, 0x9d, + 0x76, 0x87, 0x30, 0x62, 0x6c, 0x4b, 0xb4, 0x33, 0x89, 0x1e, 0x81, 0x9d, 0xb3, 0xbd, 0x3a, 0x62, + 0x70, 0x6f, 0x6b, 0xbd, 0x49, 0x9a, 0x84, 0x33, 0xdc, 0xe4, 0x4b, 0x90, 0xb7, 0x7e, 0x0b, 0x38, + 0xbb, 0x26, 0x02, 0x62, 0x21, 0x43, 0x96, 0x58, 0xb9, 0x75, 0x48, 0x91, 0x2b, 0x55, 0xdc, 0x80, + 0xe0, 0x58, 0x51, 0x9b, 0x84, 0x34, 0x23, 0xe4, 0xf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x4a, 0x7d, 0xb9, 0xb2, 0x52, + 0x8f, 0xef, 0x35, 0x31, 0x7b, 0xde, 0xad, 0x3b, 0x01, 0x69, 0xb9, 0x52, 0xbc, 0x1c, 0xc1, 0x3a, + 0x55, 0x0b, 0xf7, 0x6c, 0xef, 0xc0, 0xed, 0xfd, 0xf0, 0xa5, 0xef, 0xb7, 0x11, 0x55, 0xff, 0xcb, + 0x7a, 0x86, 0xbf, 0x5f, 0xfb, 0xdf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x77, 0x9b, 0x18, 0x08, 0x60, + 0x07, 0x00, 0x00, } func (m *FullTick) Marshal() (dAtA []byte, err error) { @@ -500,6 +547,46 @@ func (m *PoolData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PositionData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PositionData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PositionData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LockId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.LockId)) + i-- + dAtA[i] = 0x10 + } + if m.Position != nil { + { + size, err := m.Position.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *GenesisState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -523,17 +610,12 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.NextPositionId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.NextPositionId)) i-- - dAtA[i] = 0x28 - } - if m.PositionLockId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.PositionLockId)) - i-- dAtA[i] = 0x20 } - if len(m.Positions) > 0 { - for iNdEx := len(m.Positions) - 1; iNdEx >= 0; iNdEx-- { + if len(m.PositionData) > 0 { + for iNdEx := len(m.PositionData) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Positions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.PositionData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -674,6 +756,22 @@ func (m *PoolData) Size() (n int) { return n } +func (m *PositionData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Position != nil { + l = m.Position.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.LockId != 0 { + n += 1 + sovGenesis(uint64(m.LockId)) + } + return n +} + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -688,15 +786,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Positions) > 0 { - for _, e := range m.Positions { + if len(m.PositionData) > 0 { + for _, e := range m.PositionData { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } } - if m.PositionLockId != 0 { - n += 1 + sovGenesis(uint64(m.PositionLockId)) - } if m.NextPositionId != 0 { n += 1 + sovGenesis(uint64(m.NextPositionId)) } @@ -1068,7 +1163,7 @@ func (m *PoolData) Unmarshal(dAtA []byte) error { } return nil } -func (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *PositionData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1091,15 +1186,15 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: PositionData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PositionData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Position", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1126,13 +1221,85 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Position == nil { + m.Position = &model.Position{} + } + if err := m.Position.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LockId", wireType) + } + m.LockId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LockId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolData", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1159,14 +1326,13 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PoolData = append(m.PoolData, PoolData{}) - if err := m.PoolData[len(m.PoolData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Positions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PoolData", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1193,16 +1359,16 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Positions = append(m.Positions, model.Position{}) - if err := m.Positions[len(m.Positions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.PoolData = append(m.PoolData, PoolData{}) + if err := m.PoolData[len(m.PoolData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PositionLockId", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PositionData", wireType) } - m.PositionLockId = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -1212,12 +1378,27 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PositionLockId |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 5: + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PositionData = append(m.PositionData, PositionData{}) + if err := m.PositionData[len(m.PositionData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field NextPositionId", wireType) } From bb4e0f5980c5fdb0517fdd6e38e756f714ddc4d0 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Fri, 14 Apr 2023 14:18:04 -0700 Subject: [PATCH 4/6] nits --- x/concentrated-liquidity/genesis.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/concentrated-liquidity/genesis.go b/x/concentrated-liquidity/genesis.go index 9bd7de12b5b..f908b90036f 100644 --- a/x/concentrated-liquidity/genesis.go +++ b/x/concentrated-liquidity/genesis.go @@ -64,7 +64,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) { panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", position.Position.PoolId)) } - // We hardcode the underlying lock id to 0, because genesisState should already hold the positionId to lockId connections err := k.SetPosition(ctx, position.Position.PoolId, sdk.MustAccAddressFromBech32(position.Position.Address), position.Position.LowerTick, position.Position.UpperTick, position.Position.JoinTime, position.Position.Liquidity, position.Position.PositionId, position.LockId) if err != nil { panic(err) From d4c3df6eb03b69cf2d5c1385ddedf607ed1ade4a Mon Sep 17 00:00:00 2001 From: stackman27 Date: Sat, 15 Apr 2023 15:10:37 -0700 Subject: [PATCH 5/6] romans feedback --- x/concentrated-liquidity/genesis.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/concentrated-liquidity/genesis.go b/x/concentrated-liquidity/genesis.go index f908b90036f..9970e3209b7 100644 --- a/x/concentrated-liquidity/genesis.go +++ b/x/concentrated-liquidity/genesis.go @@ -59,12 +59,12 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState genesis.GenesisState) { } // set positions for pool - for _, position := range genState.PositionData { - if _, ok := seenPoolIds[position.Position.PoolId]; !ok { - panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", position.Position.PoolId)) + for _, positionWrapper := range genState.PositionData { + if _, ok := seenPoolIds[positionWrapper.Position.PoolId]; !ok { + panic(fmt.Sprintf("found position with pool id (%d) but there is no pool with such id that exists", positionWrapper.Position.PoolId)) } - err := k.SetPosition(ctx, position.Position.PoolId, sdk.MustAccAddressFromBech32(position.Position.Address), position.Position.LowerTick, position.Position.UpperTick, position.Position.JoinTime, position.Position.Liquidity, position.Position.PositionId, position.LockId) + err := k.SetPosition(ctx, positionWrapper.Position.PoolId, sdk.MustAccAddressFromBech32(positionWrapper.Position.Address), positionWrapper.Position.LowerTick, positionWrapper.Position.UpperTick, positionWrapper.Position.JoinTime, positionWrapper.Position.Liquidity, positionWrapper.Position.PositionId, positionWrapper.LockId) if err != nil { panic(err) } From d1fb08a23fca6164f93493e809daadfd715cebc2 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Sat, 15 Apr 2023 15:17:02 -0700 Subject: [PATCH 6/6] added changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d448bcb02cd..a46fcb90b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#4659](https://github.com/osmosis-labs/osmosis/pull/4659) implement AllPools query in x/poolmanager. * [#4783](https://github.com/osmosis-labs/osmosis/pull/4783) Update wasmd to 0.31.0 + * [#4886](https://github.com/osmosis-labs/osmosis/pull/4886) Implement MsgSplitRouteSwapExactAmountIn and MsgSplitRouteSwapExactAmountOut that supports route splitting. ### Misc Improvements @@ -56,8 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#4891](https://github.com/osmosis-labs/osmosis/pull/4891) Enable CORS by default on localosmosis * [#4892](https://github.com/osmosis-labs/osmosis/pull/4847) Update Golang to 1.20 * [#4893](https://github.com/osmosis-labs/osmosis/pull/4893) Update alpine docker base image to `alpine:3.17` + * [#4912](https://github.com/osmosis-labs/osmosis/pull/4912) Export Position_lock_id mappings to GenesisState -### API Breaks ### API breaks