Skip to content

Commit

Permalink
DynamicConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Jan 30, 2025
1 parent 35b4c7c commit a58622d
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 26 deletions.
8 changes: 4 additions & 4 deletions baseapp/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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,
) {
Expand Down
4 changes: 2 additions & 2 deletions runtime/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions runtime/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -501,4 +503,4 @@ func (m mapGetter) GetString(key string) string {
return str.(string)
}

var _ servertypes.AppOptions = mapGetter{}
var _ coreserver.DynamicConfig = mapGetter{}
3 changes: 2 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{"*"},
Expand Down
5 changes: 3 additions & 2 deletions simapp/simd/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -30,15 +29,14 @@ import (
type SetupOptions struct {
Logger log.Logger
DB corestore.KVStoreWithBatch
AppOpts servertypes.AppOptions
AppOpts coreserver.DynamicConfig
}

func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
db := coretesting.NewMemDB()

appOptions := make(simtestutil.AppOptionsMap, 0)
appOptions[flags.FlagHome] = DefaultNodeHome
appOptions[server.FlagInvCheckPeriod] = invCheckPeriod

app := NewSimApp(log.NewNopLogger(), db, nil, true, appOptions)
if withGenesis {
Expand Down
14 changes: 7 additions & 7 deletions simsx/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions testutil/sims/app_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit a58622d

Please sign in to comment.