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

Remove the encoding config arg to NewOsmosisApp #2587

Merged
merged 3 commits into from
Sep 3, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#2390](https://github.com/osmosis-labs/osmosis/pull/2390) x/mint remove unused mintCoins parameter from AfterDistributeMintedCoin
* [#2418](https://github.com/osmosis-labs/osmosis/pull/2418) x/mint remove SetInitialSupplyOffsetDuringMigration from keeper
* [#2417](https://github.com/osmosis-labs/osmosis/pull/2417) x/mint unexport keeper `SetLastReductionEpochNum`, `getLastReductionEpochNum`, `CreateDeveloperVestingModuleAccount`, and `MintCoins`
* [#2587](https://github.com/osmosis-labs/osmosis/pull/2587) remove encoding config argument from NewOsmosisApp

### Features

Expand Down
3 changes: 1 addition & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/osmosis-labs/osmosis/v11/app/keepers"
appparams "github.com/osmosis-labs/osmosis/v11/app/params"
"github.com/osmosis-labs/osmosis/v11/app/upgrades"
v10 "github.com/osmosis-labs/osmosis/v11/app/upgrades/v10"
v11 "github.com/osmosis-labs/osmosis/v11/app/upgrades/v11"
Expand Down Expand Up @@ -152,12 +151,12 @@ func NewOsmosisApp(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig appparams.EncodingConfig,
appOpts servertypes.AppOptions,
wasmEnabledProposals []wasm.ProposalType,
wasmOpts []wasm.Option,
baseAppOptions ...func(*baseapp.BaseApp),
) *OsmosisApp {
encodingConfig := MakeEncodingConfig()
appCodec := encodingConfig.Marshaler
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand Down
6 changes: 2 additions & 4 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"time"

"github.com/osmosis-labs/osmosis/v11/app/params"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -30,7 +29,7 @@ func DefaultConfig() network.Config {
LegacyAmino: encCfg.Amino,
InterfaceRegistry: encCfg.InterfaceRegistry,
AccountRetriever: authtypes.AccountRetriever{},
AppConstructor: NewAppConstructor(encCfg),
AppConstructor: NewAppConstructor(),
GenesisState: ModuleBasics.DefaultGenesis(encCfg.Marshaler),
TimeoutCommit: 1 * time.Second / 2,
ChainID: "osmosis-code-test",
Expand All @@ -48,11 +47,10 @@ func DefaultConfig() network.Config {
}

// NewAppConstructor returns a new Osmosis app given encoding type configs.
func NewAppConstructor(encodingCfg params.EncodingConfig) network.AppConstructor {
func NewAppConstructor() network.AppConstructor {
return func(val network.Validator) servertypes.Application {
return NewOsmosisApp(
val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0,
encodingCfg,
simapp.EmptyAppOptions{},
GetWasmEnabledProposals(),
EmptyWasmOpts,
Expand Down
2 changes: 1 addition & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/std"
)

// MakeEncodingConfig creates an EncodingConfig for testing.
// MakeEncodingConfig creates an EncodingConfig.
func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
Expand Down
5 changes: 2 additions & 3 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

var defaultGenesisBz []byte
var defaultEncodingConfig = MakeEncodingConfig()

func getDefaultGenesisStateBytes() []byte {
if len(defaultGenesisBz) == 0 {
Expand All @@ -30,7 +29,7 @@ func getDefaultGenesisStateBytes() []byte {
// Setup initializes a new OsmosisApp.
func Setup(isCheckTx bool) *OsmosisApp {
db := dbm.NewMemDB()
app := NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, defaultEncodingConfig, simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts)
app := NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts)
if !isCheckTx {
stateBytes := getDefaultGenesisStateBytes()

Expand All @@ -54,7 +53,7 @@ func SetupTestingAppWithLevelDb(isCheckTx bool) (app *OsmosisApp, cleanupFn func
if err != nil {
panic(err)
}
app = NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts)
app = NewOsmosisApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, simapp.EmptyAppOptions{}, GetWasmEnabledProposals(), EmptyWasmOpts)
if !isCheckTx {
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down
5 changes: 2 additions & 3 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
osmosis.MakeEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd.
appOpts,
osmosis.GetWasmEnabledProposals(),
wasmOpts,
Expand All @@ -300,13 +299,13 @@ func createOsmosisAppAndExport(
encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var app *osmosis.OsmosisApp
if height != -1 {
app = osmosis.NewOsmosisApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), encCfg, appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
app = osmosis.NewOsmosisApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)

if err := app.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
app = osmosis.NewOsmosisApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), encCfg, appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
app = osmosis.NewOsmosisApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
}

return app.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
Expand Down
2 changes: 0 additions & 2 deletions tests/simulator/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func fullAppSimulation(tb testing.TB, is_testing bool) {
map[int64]bool{},
app.DefaultNodeHome,
osmosim.FlagPeriodValue,
app.MakeEncodingConfig(),
osmosim.EmptyAppOptions{},
app.GetWasmEnabledProposals(),
app.EmptyWasmOpts,
Expand Down Expand Up @@ -165,7 +164,6 @@ func TestAppStateDeterminism(t *testing.T) {
map[int64]bool{},
app.DefaultNodeHome,
osmosim.FlagPeriodValue,
app.MakeEncodingConfig(),
osmosim.EmptyAppOptions{},
app.GetWasmEnabledProposals(),
app.EmptyWasmOpts,
Expand Down