From a58622d5325ebd20b2e2fcb220be204a25132db7 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 30 Jan 2025 14:51:06 -0500 Subject: [PATCH] DynamicConfig --- baseapp/streaming.go | 8 ++++---- runtime/builder.go | 4 ++-- runtime/module.go | 4 ++-- server/util_test.go | 4 +++- simapp/app.go | 3 ++- simapp/sim_test.go | 2 +- simapp/simd/cmd/commands.go | 5 +++-- simapp/test_helpers.go | 6 ++---- simsx/runner.go | 14 +++++++------- testutil/sims/app_helpers.go | 3 +-- 10 files changed, 27 insertions(+), 26 deletions(-) diff --git a/baseapp/streaming.go b/baseapp/streaming.go index 78b19d5337c4..8961894cf520 100644 --- a/baseapp/streaming.go +++ b/baseapp/streaming.go @@ -12,6 +12,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" "github.com/spf13/cast" + "cosmossdk.io/core/server" "cosmossdk.io/log" "cosmossdk.io/schema" "cosmossdk.io/schema/appdata" @@ -21,7 +22,6 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/client/flags" - servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -60,7 +60,7 @@ func (app *BaseApp) EnableIndexer(indexerOpts interface{}, keys map[string]*stor } // RegisterStreamingServices registers streaming services with the BaseApp. -func (app *BaseApp) RegisterStreamingServices(appOpts servertypes.AppOptions, keys map[string]*storetypes.KVStoreKey) error { +func (app *BaseApp) RegisterStreamingServices(appOpts server.DynamicConfig, keys map[string]*storetypes.KVStoreKey) error { // register streaming services streamingCfg := cast.ToStringMap(appOpts.Get(StreamingTomlKey)) for service := range streamingCfg { @@ -83,7 +83,7 @@ func (app *BaseApp) RegisterStreamingServices(appOpts servertypes.AppOptions, ke // registerStreamingPlugin registers streaming plugins with the BaseApp. func (app *BaseApp) registerStreamingPlugin( - appOpts servertypes.AppOptions, + appOpts server.DynamicConfig, keys map[string]*storetypes.KVStoreKey, streamingPlugin interface{}, ) error { @@ -98,7 +98,7 @@ func (app *BaseApp) registerStreamingPlugin( // registerABCIListenerPlugin registers plugins that implement the ABCIListener interface. func (app *BaseApp) registerABCIListenerPlugin( - appOpts servertypes.AppOptions, + appOpts server.DynamicConfig, keys map[string]*storetypes.KVStoreKey, abciListener storetypes.ABCIListener, ) { diff --git a/runtime/builder.go b/runtime/builder.go index f3de4da2dcbf..c0f76b346b32 100644 --- a/runtime/builder.go +++ b/runtime/builder.go @@ -8,12 +8,12 @@ import ( "github.com/spf13/cast" + "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth/ante/unorderedtx" @@ -25,7 +25,7 @@ import ( type AppBuilder struct { app *App - appOptions servertypes.AppOptions + appOptions server.DynamicConfig } // DefaultGenesis returns a default genesis from the registered modules. diff --git a/runtime/module.go b/runtime/module.go index 488bc6c93b8e..69b256533a9d 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -15,6 +15,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/comet" "cosmossdk.io/core/registry" + "cosmossdk.io/core/server" "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" @@ -24,7 +25,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -161,7 +161,7 @@ type AppInputs struct { BaseAppOptions []BaseAppOption InterfaceRegistry codectypes.InterfaceRegistry LegacyAmino registry.AminoRegistrar - AppOptions servertypes.AppOptions `optional:"true"` // can be nil in client wiring + AppOptions server.DynamicConfig `optional:"true"` // can be nil in client wiring } func SetupAppBuilder(inputs AppInputs) { diff --git a/server/util_test.go b/server/util_test.go index d03f1ad10fe6..c658973772fb 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -16,6 +16,8 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" + coreserver "cosmossdk.io/core/server" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" @@ -501,4 +503,4 @@ func (m mapGetter) GetString(key string) string { return str.(string) } -var _ servertypes.AppOptions = mapGetter{} +var _ coreserver.DynamicConfig = mapGetter{} diff --git a/simapp/app.go b/simapp/app.go index e57e2899d1c0..871d06185d0d 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/registry" + coreserver "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" @@ -110,7 +111,7 @@ func NewSimApp( db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, - appOpts servertypes.AppOptions, + appOpts coreserver.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { var ( diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 50c304a0d27f..7b91cd47f0f3 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -174,7 +174,7 @@ func TestAppStateDeterminism(t *testing.T) { } } // overwrite default app config - interBlockCachingAppFactory := func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp)) *SimApp { + interBlockCachingAppFactory := func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp)) *SimApp { if FlagEnableStreamingValue { m := map[string]any{ "streaming.abci.keys": []string{"*"}, diff --git a/simapp/simd/cmd/commands.go b/simapp/simd/cmd/commands.go index 2b6e1a9032af..6f4731f252c5 100644 --- a/simapp/simd/cmd/commands.go +++ b/simapp/simd/cmd/commands.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/viper" "cosmossdk.io/client/v2/offchain" + coreserver "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" "cosmossdk.io/log" "cosmossdk.io/simapp" @@ -118,7 +119,7 @@ func newApp( logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, - appOpts servertypes.AppOptions, + appOpts coreserver.DynamicConfig, ) servertypes.Application { baseappOptions := server.DefaultBaseappOptions(appOpts) return simapp.NewSimApp( @@ -136,7 +137,7 @@ func appExport( height int64, forZeroHeight bool, jailAllowedAddrs []string, - appOpts servertypes.AppOptions, + appOpts coreserver.DynamicConfig, modulesToExport []string, ) (servertypes.ExportedApp, error) { viperAppOpts, ok := appOpts.(*viper.Viper) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index aceebaf59b7b..3e5d8228d37c 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -9,6 +9,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/stretchr/testify/require" + coreserver "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" coretesting "cosmossdk.io/core/testing" "cosmossdk.io/log" @@ -18,8 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/server" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/testutil/mock" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -30,7 +29,7 @@ import ( type SetupOptions struct { Logger log.Logger DB corestore.KVStoreWithBatch - AppOpts servertypes.AppOptions + AppOpts coreserver.DynamicConfig } func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { @@ -38,7 +37,6 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = DefaultNodeHome - appOptions[server.FlagInvCheckPeriod] = invCheckPeriod app := NewSimApp(log.NewNopLogger(), db, nil, true, appOptions) if withGenesis { diff --git a/simsx/runner.go b/simsx/runner.go index f18333bae635..548507150eef 100644 --- a/simsx/runner.go +++ b/simsx/runner.go @@ -11,6 +11,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" + "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" "cosmossdk.io/log" @@ -19,7 +20,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" - servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -76,7 +76,7 @@ func Run[T SimulationApp]( db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, - appOpts servertypes.AppOptions, + appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp), ) T, setupStateFactory func(app T) SimStateFactory, @@ -102,7 +102,7 @@ func RunWithSeeds[T SimulationApp]( db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, - appOpts servertypes.AppOptions, + appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp), ) T, setupStateFactory func(app T) SimStateFactory, @@ -122,7 +122,7 @@ func RunWithSeedsAndRandAcc[T SimulationApp]( db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, - appOpts servertypes.AppOptions, + appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp), ) T, setupStateFactory func(app T) SimStateFactory, @@ -152,7 +152,7 @@ func RunWithSeedsAndRandAcc[T SimulationApp]( func RunWithSeed[T SimulationApp]( tb testing.TB, cfg simtypes.Config, - appFactory func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp)) T, + appFactory func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp)) T, setupStateFactory func(app T) SimStateFactory, seed int64, fuzzSeed []byte, @@ -166,7 +166,7 @@ func RunWithSeed[T SimulationApp]( func RunWithSeedAndRandAcc[T SimulationApp]( tb testing.TB, cfg simtypes.Config, - appFactory func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp)) T, + appFactory func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp)) T, setupStateFactory func(app T) SimStateFactory, seed int64, fuzzSeed []byte, @@ -329,7 +329,7 @@ func prepareWeightedOps( func NewSimulationAppInstance[T SimulationApp]( tb testing.TB, tCfg simtypes.Config, - appFactory func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp)) T, + appFactory func(logger log.Logger, db corestore.KVStoreWithBatch, traceStore io.Writer, loadLatest bool, appOpts server.DynamicConfig, baseAppOptions ...func(*baseapp.BaseApp)) T, ) TestInstance[T] { tb.Helper() workDir := tb.TempDir() diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index f5a3dac886bb..2e5949d66205 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -25,7 +25,6 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/runtime" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/testutil/mock" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -320,7 +319,7 @@ func (m AppOptionsMap) GetString(key string) string { return v.(string) } -func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions { +func NewAppOptionsWithFlagHome(homePath string) server.DynamicConfig { return AppOptionsMap{ flags.FlagHome: homePath, }