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

Revert "Optimize Genesis for CL Module (#5453)" #5631

Merged
merged 1 commit into from
Jun 27, 2023
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
35 changes: 10 additions & 25 deletions proto/osmosis/concentrated-liquidity/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "osmosis/accum/v1beta1/accum.proto";
import "osmosis/concentrated-liquidity/params.proto";
import "osmosis/concentrated-liquidity/position.proto";
import "osmosis/concentrated-liquidity/tickInfo.proto";
import "osmosis/concentrated-liquidity/incentive_record.proto";

Expand All @@ -16,18 +16,20 @@ option go_package = "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidit
// FullTick contains tick index and pool id along with other tick model
// information.
message FullTick {
// pool id associated with the tick.
uint64 pool_id = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ];
// tick's index.
int64 tick_index = 1 [ (gogoproto.moretags) = "yaml:\"tick_index\"" ];
int64 tick_index = 2 [ (gogoproto.moretags) = "yaml:\"tick_index\"" ];
// tick's info.
TickInfo info = 2 [
TickInfo info = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"tick_info\""
];
}

// PoolData represents a serialized pool along with its ticks
// for genesis state.
message GenesisPoolData {
message PoolData {
// pool struct
google.protobuf.Any pool = 1 [ (cosmos_proto.accepts_interface) = "PoolI" ];
// pool's ticks
Expand All @@ -44,42 +46,25 @@ message GenesisPoolData {
// incentive records to be set
repeated IncentiveRecord incentive_records = 5
[ (gogoproto.nullable) = false ];

repeated PositionData position_data = 6 [ (gogoproto.nullable) = false ];
}

message PositionData {
PositionWithoutPoolId position = 1;
Position position = 1;
uint64 lock_id = 2 [ (gogoproto.moretags) = "yaml:\"lock_id\"" ];
osmosis.accum.v1beta1.Record spread_reward_accum_record = 3
[ (gogoproto.nullable) = false ];
repeated osmosis.accum.v1beta1.Record uptime_accum_records = 4
[ (gogoproto.nullable) = false ];
}

message PositionWithoutPoolId {
uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ];
string address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
int64 lower_tick = 3;
int64 upper_tick = 4;
google.protobuf.Timestamp join_time = 5 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"join_time\""
];
string liquidity = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"liquidity\"",
(gogoproto.nullable) = false
];
}

// GenesisState defines the concentrated liquidity module's genesis state.
message GenesisState {
// params are all the parameters of the module
Params params = 1 [ (gogoproto.nullable) = false ];
// pool data containining serialized pool struct and ticks.
repeated GenesisPoolData pool_data = 2 [ (gogoproto.nullable) = false ];
repeated PoolData pool_data = 2 [ (gogoproto.nullable) = false ];

repeated PositionData position_data = 3 [ (gogoproto.nullable) = false ];

uint64 next_position_id = 4
[ (gogoproto.moretags) = "yaml:\"next_position_id\"" ];
Expand Down
3 changes: 2 additions & 1 deletion tests/cl-genesis-positions/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress,
numberOfSuccesfulPositions++

bigBangPositions = append(bigBangPositions, clgenesis.PositionData{
Position: &clgenesis.PositionWithoutPoolId{
Position: &model.Position{
Address: randomCreator.String(),
PoolId: poolId,
JoinTime: osmosis.Ctx.BlockTime(),
Liquidity: position.LiquidityCreated,
PositionId: position.PositionId,
Expand Down
21 changes: 13 additions & 8 deletions tests/cl-genesis-positions/edit_localosmosis_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ func EditLocalOsmosisGenesis(updatedCLGenesis *clgenesis.GenesisState, updatedBa
})
appState[poolmanagertypes.ModuleName] = cdc.MustMarshalJSON(&localOsmosisPoolManagerGenesis)

// Copy positions
largestPositionId := uint64(0)
for _, positionData := range updatedCLGenesis.PositionData {
positionData.Position.PoolId = nextPoolId
localOsmosisCLGenesis.PositionData = append(localOsmosisCLGenesis.PositionData, positionData)
if positionData.Position.PositionId > largestPositionId {
largestPositionId = positionData.Position.PositionId
}
}

// Create map of pool balances
balancesMap := map[string][]banktypes.Balance{}
Expand Down Expand Up @@ -92,6 +100,10 @@ func EditLocalOsmosisGenesis(updatedCLGenesis *clgenesis.GenesisState, updatedBa
}
anyCopy := *any

for i := range pool.Ticks {
pool.Ticks[i].PoolId = nextPoolId
}

for i := range pool.IncentiveRecords {
pool.IncentiveRecords[i].PoolId = nextPoolId
}
Expand All @@ -100,13 +112,7 @@ func EditLocalOsmosisGenesis(updatedCLGenesis *clgenesis.GenesisState, updatedBa
pool.IncentivesAccumulators[i].Name = cltypes.KeyUptimeAccumulator(nextPoolId, uint64(i))
}

for _, pos := range pool.PositionData {
if pos.Position.PositionId > largestPositionId {
largestPositionId = pos.Position.PositionId
}
}

updatedPoolData := clgenesis.GenesisPoolData{
updatedPoolData := clgenesis.PoolData{
Pool: &anyCopy,
Ticks: pool.Ticks,
IncentivesAccumulators: pool.IncentivesAccumulators,
Expand All @@ -115,7 +121,6 @@ func EditLocalOsmosisGenesis(updatedCLGenesis *clgenesis.GenesisState, updatedBa
Name: cltypes.KeySpreadRewardPoolAccumulator(nextPoolId),
AccumContent: pool.SpreadRewardAccumulator.AccumContent,
},
PositionData: pool.PositionData,
}

// Update bank genesis with balances
Expand Down
6 changes: 2 additions & 4 deletions tests/cl-genesis-positions/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/tendermint/tendermint v0.37.0-rc1
)

require github.com/osmosis-labs/osmosis/v16 v16.0.0-20230612054801-1cd3195471ff
require github.com/osmosis-labs/osmosis/v16 v16.0.0-20230612230414-cf10d2bbf17d

require (
cosmossdk.io/errors v1.0.0-beta.7 // indirect
Expand All @@ -30,7 +30,6 @@ require (
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
Expand All @@ -57,6 +56,7 @@ require (
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
Expand Down Expand Up @@ -86,7 +86,6 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down Expand Up @@ -133,7 +132,6 @@ require (
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect
golang.org/x/mod v0.10.0 // indirect
Expand Down
Loading