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

Delete unused simulator code (backport #1671) #2158

Merged
merged 3 commits into from
Jul 20, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ This release contains minor CLI bug fixes.

* [#1699](https://github.com/osmosis-labs/osmosis/pull/1699) Fixes bug in sig fig rounding on spot price queries for small values

* [#1671](https://github.com/osmosis-labs/osmosis/pull/1671) Remove methods that constitute AppModuleSimulation APIs for several modules' AppModules, which implemented no-ops
* [#1671](https://github.com/osmosis-labs/osmosis/pull/1671) Add hourly epochs to `x/epochs` DefaultGenesis.
* [#1665](https://github.com/osmosis-labs/osmosis/pull/1665) Delete app/App interface, instead use simapp.App
* [#1630](https://github.com/osmosis-labs/osmosis/pull/1630) Delete the v043_temp module, now that we're on an updated SDK version.

### Bug Fixes
Expand All @@ -81,6 +84,7 @@ This release contains minor CLI bug fixes.
* [1931](https://github.com/osmosis-labs/osmosis/pull/1931) Add explicit check for input denoms to `CalcJoinPoolShares`



## [v9.0.0 - Nitrogen](https://github.com/osmosis-labs/osmosis/releases/tag/v9.0.0)

The Nitrogen release brings with it a number of features enabling further cosmwasm development work in Osmosis.
Expand Down
4 changes: 0 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ func simulationModules(
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
authzmodule.NewAppModule(appCodec, *app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper),
txfees.NewAppModule(appCodec, *app.TxFeesKeeper),
gov.NewAppModule(appCodec, *app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, *app.MintKeeper, app.AccountKeeper, app.BankKeeper),
slashing.NewAppModule(appCodec, *app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper),
Expand All @@ -234,7 +232,6 @@ func simulationModules(
incentives.NewAppModule(appCodec, *app.IncentivesKeeper, app.AccountKeeper, app.BankKeeper, app.EpochsKeeper),
lockup.NewAppModule(appCodec, *app.LockupKeeper, app.AccountKeeper, app.BankKeeper),
poolincentives.NewAppModule(appCodec, *app.PoolIncentivesKeeper),
epochs.NewAppModule(appCodec, *app.EpochsKeeper),
superfluid.NewAppModule(
appCodec,
*app.SuperfluidKeeper,
Expand All @@ -245,7 +242,6 @@ func simulationModules(
app.GAMMKeeper,
app.EpochsKeeper,
),
tokenfactory.NewAppModule(appCodec, *app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
app.TransferModule,
}
}
Expand Down
16 changes: 5 additions & 11 deletions x/epochs/keeper/epoch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@ import (
func (suite *KeeperTestSuite) TestEpochLifeCycle() {
suite.SetupTest()

epochInfo := types.EpochInfo{
Identifier: "monthly",
StartTime: time.Time{},
Duration: time.Hour * 24 * 30,
CurrentEpoch: 0,
CurrentEpochStartTime: time.Time{},
EpochCountingStarted: false,
}
epochInfo := types.NewGenesisEpochInfo("monthly", time.Hour*24*30)
suite.App.EpochsKeeper.SetEpochInfo(suite.Ctx, epochInfo)
epochInfoSaved := suite.App.EpochsKeeper.GetEpochInfo(suite.Ctx, "monthly")
suite.Require().Equal(epochInfo, epochInfoSaved)

allEpochs := suite.App.EpochsKeeper.AllEpochInfos(suite.Ctx)
suite.Require().Len(allEpochs, 3)
suite.Require().Len(allEpochs, 4)
suite.Require().Equal(allEpochs[0].Identifier, "day") // alphabetical order
suite.Require().Equal(allEpochs[1].Identifier, "monthly")
suite.Require().Equal(allEpochs[2].Identifier, "week")
suite.Require().Equal(allEpochs[1].Identifier, "hour")
suite.Require().Equal(allEpochs[2].Identifier, "monthly")
suite.Require().Equal(allEpochs[3].Identifier, "week")
}
22 changes: 7 additions & 15 deletions x/epochs/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,14 @@ func TestEpochsExportGenesis(t *testing.T) {
chainStartHeight := ctx.BlockHeight()

genesis := app.EpochsKeeper.ExportGenesis(ctx)
require.Len(t, genesis.Epochs, 2)
require.Len(t, genesis.Epochs, 3)

require.Equal(t, genesis.Epochs[0].Identifier, "day")
require.Equal(t, genesis.Epochs[0].StartTime, chainStartTime)
require.Equal(t, genesis.Epochs[0].Duration, time.Hour*24)
require.Equal(t, genesis.Epochs[0].CurrentEpoch, int64(0))
require.Equal(t, genesis.Epochs[0].CurrentEpochStartHeight, chainStartHeight)
require.Equal(t, genesis.Epochs[0].CurrentEpochStartTime, chainStartTime)
require.Equal(t, genesis.Epochs[0].EpochCountingStarted, false)
require.Equal(t, genesis.Epochs[1].Identifier, "week")
require.Equal(t, genesis.Epochs[1].StartTime, chainStartTime)
require.Equal(t, genesis.Epochs[1].Duration, time.Hour*24*7)
require.Equal(t, genesis.Epochs[1].CurrentEpoch, int64(0))
require.Equal(t, genesis.Epochs[1].CurrentEpochStartHeight, chainStartHeight)
require.Equal(t, genesis.Epochs[1].CurrentEpochStartTime, chainStartTime)
require.Equal(t, genesis.Epochs[1].EpochCountingStarted, false)
expectedEpochs := types.DefaultGenesis().Epochs
for i := 0; i < len(expectedEpochs); i++ {
expectedEpochs[i].CurrentEpochStartHeight = chainStartHeight
expectedEpochs[i].CurrentEpochStartTime = chainStartTime
}
require.Equal(t, expectedEpochs, genesis.Epochs)
}

func TestEpochsInitGenesis(t *testing.T) {
Expand Down
41 changes: 4 additions & 37 deletions x/epochs/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper_test

import (
gocontext "context"
"time"

"github.com/osmosis-labs/osmosis/v10/x/epochs/types"
)
Expand All @@ -11,42 +10,10 @@ func (suite *KeeperTestSuite) TestQueryEpochInfos() {
suite.SetupTest()
queryClient := suite.queryClient

chainStartTime := suite.Ctx.BlockHeader().Time
epochInfo := types.EpochInfo{
Identifier: "day",
StartTime: chainStartTime,
Duration: time.Hour * 24,
CurrentEpoch: 0,
CurrentEpochStartTime: chainStartTime,
EpochCountingStarted: false,
}
suite.App.EpochsKeeper.SetEpochInfo(suite.Ctx, epochInfo)
epochInfo = types.EpochInfo{
Identifier: "week",
StartTime: chainStartTime,
Duration: time.Hour * 24 * 7,
CurrentEpoch: 0,
CurrentEpochStartTime: chainStartTime,
EpochCountingStarted: false,
}
suite.App.EpochsKeeper.SetEpochInfo(suite.Ctx, epochInfo)

// Invalid param
// Check that querying epoch infos on default genesis returns the default genesis epoch infos
epochInfosResponse, err := queryClient.EpochInfos(gocontext.Background(), &types.QueryEpochsInfoRequest{})
suite.Require().NoError(err)
suite.Require().Len(epochInfosResponse.Epochs, 2)

// check if EpochInfos are correct
suite.Require().Equal(epochInfosResponse.Epochs[0].Identifier, "day")
suite.Require().Equal(epochInfosResponse.Epochs[0].StartTime, chainStartTime)
suite.Require().Equal(epochInfosResponse.Epochs[0].Duration, time.Hour*24)
suite.Require().Equal(epochInfosResponse.Epochs[0].CurrentEpoch, int64(0))
suite.Require().Equal(epochInfosResponse.Epochs[0].CurrentEpochStartTime, chainStartTime)
suite.Require().Equal(epochInfosResponse.Epochs[0].EpochCountingStarted, false)
suite.Require().Equal(epochInfosResponse.Epochs[1].Identifier, "week")
suite.Require().Equal(epochInfosResponse.Epochs[1].StartTime, chainStartTime)
suite.Require().Equal(epochInfosResponse.Epochs[1].Duration, time.Hour*24*7)
suite.Require().Equal(epochInfosResponse.Epochs[1].CurrentEpoch, int64(0))
suite.Require().Equal(epochInfosResponse.Epochs[1].CurrentEpochStartTime, chainStartTime)
suite.Require().Equal(epochInfosResponse.Epochs[1].EpochCountingStarted, false)
suite.Require().Len(epochInfosResponse.Epochs, 3)
expectedEpochs := types.DefaultGenesis().Epochs
suite.Require().Equal(expectedEpochs, epochInfosResponse.Epochs)
}
31 changes: 0 additions & 31 deletions x/epochs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand All @@ -16,11 +15,9 @@ import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

"github.com/osmosis-labs/osmosis/v10/x/epochs/client/cli"
"github.com/osmosis-labs/osmosis/v10/x/epochs/keeper"
"github.com/osmosis-labs/osmosis/v10/x/epochs/simulation"
"github.com/osmosis-labs/osmosis/v10/x/epochs/types"
"github.com/osmosis-labs/osmosis/v10/x/mint/client/rest"
)
Expand Down Expand Up @@ -163,33 +160,5 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
return []abci.ValidatorUpdate{}
}

// ___________________________________________________________________________

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the pool-incentives module.
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
simulation.RandomizedGenState(simState)
}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

// RandomizedParams creates randomized pool-incentives param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for supply module's types.
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
}

// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
return nil // TODO
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }
3 changes: 2 additions & 1 deletion x/epochs/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ func NewGenesisState(epochs []EpochInfo) *GenesisState {
// DefaultGenesis returns the default Capability genesis state.
func DefaultGenesis() *GenesisState {
epochs := []EpochInfo{
NewGenesisEpochInfo("day", time.Hour*24), // alphabetical order
NewGenesisEpochInfo("hour", time.Hour),
NewGenesisEpochInfo("week", time.Hour*24*7),
NewGenesisEpochInfo("day", time.Hour*24),
}
return NewGenesisState(epochs)
}
Expand Down
39 changes: 2 additions & 37 deletions x/gamm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand All @@ -16,20 +15,17 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/osmosis-labs/osmosis/v10/x/gamm/client/cli"
"github.com/osmosis-labs/osmosis/v10/x/gamm/keeper"
"github.com/osmosis-labs/osmosis/v10/x/gamm/pool-models/balancer"
"github.com/osmosis-labs/osmosis/v10/x/gamm/simulation"
"github.com/osmosis-labs/osmosis/v10/x/gamm/types"
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModuleSimulation = AppModule{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
)

type AppModuleBasic struct {
Expand Down Expand Up @@ -160,36 +156,5 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
return []abci.ValidatorUpdate{}
}

// ___________________________________________________________________________

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the gamm module.
// However, at launch the gamm module has no state, hence this is a no-op.
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
// simulation.RandomizedGenState(simState)
}

// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}

// RandomizedParams creates randomized gamm param changes for the simulator.
// There are no params that we view as sensible to randomize at the moment.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
// return simulation.ParamChanges(r)
}

// RegisterStoreDecoder registers a decoder for supply module's types.
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
}

// WeightedOperations returns all the simulation operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
return simulation.WeightedOperations(simState.AppParams, simState.Cdc, am.ak, am.bk, am.keeper)
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }
Loading