Skip to content

Commit

Permalink
feat: remove pools params (#184)
Browse files Browse the repository at this point in the history
## Description

This removes the list of services that allowed to use pool-restaking as
we now have per-user preferences.

Closes: MILK-116

<!-- Add a description of the changes that this PR introduces and the
files that
are the most critical to review. -->

---

### Author Checklist

*All items are required. Please add a note to the item if the item is
not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR
Targeting](https://github.com/milkyway-labs/milkyway/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building
modules](https://docs.cosmos.network/v0.44/building-modules/intro.html)
- [ ] included the necessary unit and integration
[tests](https://github.com/milkyway-labs/milkyway/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go
code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable
and please add
your handle next to the items reviewed if you only reviewed selected
items.*

I have...

- [ ] confirmed the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

---------

Co-authored-by: Hanjun Kim <[email protected]>
  • Loading branch information
RiccardoM and hallazzang authored Nov 22, 2024
1 parent bbd101c commit a5b0407
Show file tree
Hide file tree
Showing 37 changed files with 89 additions and 3,267 deletions.
4 changes: 2 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func appModules(
icacallbacks.NewAppModule(appCodec, *app.ICACallbacksKeeper, app.AccountKeeper, app.BankKeeper),

// MilkyWay modules
services.NewAppModule(appCodec, app.ServicesKeeper, app.PoolsKeeper, app.AccountKeeper, app.BankKeeper),
services.NewAppModule(appCodec, app.ServicesKeeper, app.AccountKeeper, app.BankKeeper),
operators.NewAppModule(appCodec, app.OperatorsKeeper),
pools.NewAppModule(appCodec, app.PoolsKeeper),
restaking.NewAppModule(appCodec, app.RestakingKeeper),
Expand Down Expand Up @@ -231,7 +231,7 @@ func simulationModules(
app.ICAModule,

// MilkyWay modules
services.NewAppModule(appCodec, app.ServicesKeeper, app.PoolsKeeper, app.AccountKeeper, app.BankKeeper),
services.NewAppModule(appCodec, app.ServicesKeeper, app.AccountKeeper, app.BankKeeper),
}
}

Expand Down
8 changes: 2 additions & 6 deletions proto/milkyway/pools/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ package milkyway.pools.v1;

import "gogoproto/gogo.proto";
import "milkyway/pools/v1/models.proto";
import "milkyway/pools/v1/params.proto";

option go_package = "github.com/milkyway-labs/milkyway/x/pools/types";

// GenesisState defines the pools module's genesis state.
message GenesisState {
// Params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];

// NextPoolID represents the id to be used when creating the next pool.
uint32 next_pool_id = 2 [
uint32 next_pool_id = 1 [
(gogoproto.customname) = "NextPoolID",
(gogoproto.moretags) = "yaml:\"next_pool_id\""
];

// Pools defines the list of pools.
repeated Pool pools = 3
repeated Pool pools = 2
[ (gogoproto.moretags) = "yaml:\"pools\"", (gogoproto.nullable) = false ];
}
14 changes: 0 additions & 14 deletions proto/milkyway/pools/v1/params.proto

This file was deleted.

48 changes: 0 additions & 48 deletions proto/milkyway/restaking/legacy/models.proto

This file was deleted.

2 changes: 0 additions & 2 deletions x/liquidvesting/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ func (suite *KeeperTestSuite) TestKeepr_InitGenesis() {
testPool.Tokens = math.NewIntFromUint64(50)
testPool.DelegatorShares = math.LegacyNewDecFromInt(math.NewIntFromUint64(50))
poolsKeeperGenesis := poolstypes.GenesisState{
Params: poolstypes.DefaultParams(),
NextPoolID: 2,
Pools: []poolstypes.Pool{testPool},
}
Expand Down Expand Up @@ -375,7 +374,6 @@ func (suite *KeeperTestSuite) TestKeepr_InitGenesis() {
testPool.Tokens = math.NewIntFromUint64(50)
testPool.DelegatorShares = math.LegacyNewDecFromInt(math.NewIntFromUint64(50))
poolsKeeperGenesis := poolstypes.GenesisState{
Params: poolstypes.DefaultParams(),
NextPoolID: 2,
Pools: []poolstypes.Pool{testPool},
}
Expand Down
13 changes: 1 addition & 12 deletions x/pools/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,18 @@ func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
panic(err)
}

params, err := k.GetParams(ctx)
if err != nil {
panic(err)
}

return types.NewGenesis(
nextPoolID,
pools,
params,
)
}

// --------------------------------------------------------------------------------------------------------------------

// InitGenesis initializes the genesis store using the provided data
func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) error {
err := k.SetParams(ctx, data.Params)
if err != nil {
return err
}

// Set the next pool id
err = k.SetNextPoolID(ctx, data.NextPoolID)
err := k.SetNextPoolID(ctx, data.NextPoolID)
if err != nil {
return err
}
Expand Down
13 changes: 2 additions & 11 deletions x/pools/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() {
{
name: "next pool id is exported properly",
store: func(ctx sdk.Context) {
err := suite.k.SetParams(ctx, types.DefaultParams())
suite.Require().NoError(err)

err = suite.k.SetNextPoolID(ctx, 10)
err := suite.k.SetNextPoolID(ctx, 10)
suite.Require().NoError(err)
},
expGenesis: &types.GenesisState{
NextPoolID: 10,
Params: types.DefaultParams(),
},
},
{
name: "pools are exported properly",
store: func(ctx sdk.Context) {
err := suite.k.SetParams(ctx, types.DefaultParams())
suite.Require().NoError(err)

err = suite.k.SetNextPoolID(ctx, 1)
err := suite.k.SetNextPoolID(ctx, 1)
suite.Require().NoError(err)

err = suite.k.SavePool(ctx, types.NewPool(1, "umilk"))
Expand All @@ -47,7 +40,6 @@ func (suite *KeeperTestSuite) TestKeeper_ExportGenesis() {
types.NewPool(1, "umilk"),
types.NewPool(2, "uatom"),
},
Params: types.DefaultParams(),
},
},
}
Expand Down Expand Up @@ -94,7 +86,6 @@ func (suite *KeeperTestSuite) TestKeeper_InitGenesis() {
types.NewPool(1, "umilk"),
types.NewPool(2, "uatom"),
},
types.DefaultParams(),
),
shouldErr: false,
check: func(ctx sdk.Context) {
Expand Down
7 changes: 0 additions & 7 deletions x/pools/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type Keeper struct {
nextPoolID collections.Sequence // Sequence for pool IDs
pools collections.Map[uint32, types.Pool] // Map of pool ID to pool
poolAddressSet collections.KeySet[string] // Set of pool addresses
params collections.Item[types.Params] // Module parameters
}

func NewKeeper(cdc codec.Codec,
Expand Down Expand Up @@ -55,12 +54,6 @@ func NewKeeper(cdc codec.Codec,
"pools_addresses_set",
collections.StringKey,
),
params: collections.NewItem(
sb,
types.ParamsKey,
"params",
codec.CollValue[types.Params](cdc),
),
}

schema, err := sb.Build()
Expand Down
17 changes: 0 additions & 17 deletions x/pools/keeper/params.go

This file was deleted.

12 changes: 3 additions & 9 deletions x/pools/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,28 @@ import (
)

// NewGenesis creates a new GenesisState instance
func NewGenesis(nextPoolID uint32, pools []Pool, params Params) *GenesisState {
func NewGenesis(nextPoolID uint32, pools []Pool) *GenesisState {
return &GenesisState{
Params: params,
NextPoolID: nextPoolID,
Pools: pools,
}
}

// DefaultGenesis returns the default GenesisState
func DefaultGenesis() *GenesisState {
return NewGenesis(1, nil, DefaultParams())
return NewGenesis(1, nil)
}

// Validate checks if the GenesisState is valid
func (data *GenesisState) Validate() error {
err := data.Params.Validate()
if err != nil {
return fmt.Errorf("invalid params: %w", err)
}

// Validate the next pool ID
if data.NextPoolID == 0 {
return fmt.Errorf("invalid next pool id")
}

// Validate the pools
for _, pool := range data.Pools {
err = pool.Validate()
err := pool.Validate()
if err != nil {
return fmt.Errorf("invalid pool with id %d: %w", pool.ID, err)
}
Expand Down
Loading

0 comments on commit a5b0407

Please sign in to comment.