diff --git a/server/v2/store/server.go b/server/v2/store/server.go index 44b1ddcac710..ec6d2d14e133 100644 --- a/server/v2/store/server.go +++ b/server/v2/store/server.go @@ -78,9 +78,7 @@ func (s *Server[T]) Config() any { // An empty home directory *is* permitted at this stage, but attempting to build // the store with an empty home directory will fail. func UnmarshalConfig(cfg map[string]any) (*root.Config, error) { - config := &root.Config{ - Options: root.DefaultStoreOptions(), - } + config := root.DefaultConfig() if err := serverv2.UnmarshalSubConfig(cfg, ServerName, config); err != nil { return nil, fmt.Errorf("failed to unmarshal store config: %w", err) } diff --git a/simapp/v2/app_test.go b/simapp/v2/app_test.go index 3ea361e3becb..2c11beca7caf 100644 --- a/simapp/v2/app_test.go +++ b/simapp/v2/app_test.go @@ -153,13 +153,13 @@ func TestSimAppExportAndBlockedAddrs_WithOneBlockProduced(t *testing.T) { MoveNextBlock(t, app, ctx) - _, err := app.ExportAppStateAndValidators(nil) + _, err := app.ExportAppStateAndValidators(false, nil) require.NoError(t, err) } func TestSimAppExportAndBlockedAddrs_NoBlocksProduced(t *testing.T) { app, _ := NewTestApp(t) - _, err := app.ExportAppStateAndValidators(nil) + _, err := app.ExportAppStateAndValidators(false, nil) require.NoError(t, err) } diff --git a/simapp/v2/export.go b/simapp/v2/export.go index 61175f41607f..04701bc6874f 100644 --- a/simapp/v2/export.go +++ b/simapp/v2/export.go @@ -13,7 +13,9 @@ import ( // file. // This is a demonstation of how to export a genesis file. Export may need extended at // the user discretion for cleaning the genesis state at the end provided with jailAllowedAddrs +// Same applies for forZeroHeight preprocessing. func (app *SimApp[T]) ExportAppStateAndValidators( + forZeroHeight bool, jailAllowedAddrs []string, ) (v2.ExportedApp, error) { ctx := context.Background() @@ -44,5 +46,9 @@ func (app *SimApp[T]) ExportAppStateAndValidators( exportedApp.AppState = genesis exportedApp.Height = int64(latestHeight) + if forZeroHeight { + exportedApp.Height = 0 + } + return exportedApp, nil } diff --git a/store/db/prefixdb_test.go b/store/db/prefixdb_test.go index 199aa50d056a..3f25feabe3be 100644 --- a/store/db/prefixdb_test.go +++ b/store/db/prefixdb_test.go @@ -3,10 +3,11 @@ package db_test import ( "testing" - "cosmossdk.io/store/db" - "cosmossdk.io/store/mock" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + + "cosmossdk.io/store/db" + "cosmossdk.io/store/mock" ) func TestPrefixDB(t *testing.T) { diff --git a/store/v2/root/builder.go b/store/v2/root/builder.go index 199184f8e761..a282c9fe3328 100644 --- a/store/v2/root/builder.go +++ b/store/v2/root/builder.go @@ -55,6 +55,11 @@ func (sb *builder) Build( if config.Home == "" { return nil, fmt.Errorf("home directory is required") } + + if len(config.AppDBBackend) == 0 { + return nil, fmt.Errorf("application db backend is required") + } + scRawDb, err := db.NewDB( db.DBType(config.AppDBBackend), "application", diff --git a/tests/integration/v2/distribution/fixture_test.go b/tests/integration/v2/distribution/fixture_test.go index d2ea156b5b69..f84278be5555 100644 --- a/tests/integration/v2/distribution/fixture_test.go +++ b/tests/integration/v2/distribution/fixture_test.go @@ -156,5 +156,4 @@ func (s *fixture) registerMsgRouterService(router *integration.RouterService) { func (s *fixture) registerQueryRouterService(router *integration.RouterService) { // register custom router service - } diff --git a/tests/systemtests/go.mod b/tests/systemtests/go.mod index 538ee4c11c20..6ffc4a0b9f5f 100644 --- a/tests/systemtests/go.mod +++ b/tests/systemtests/go.mod @@ -4,7 +4,7 @@ go 1.23 require ( cosmossdk.io/math v1.4.0 - cosmossdk.io/systemtests v1.0.0-rc.2.0.20241205143753-9e94ea87f6e4 + cosmossdk.io/systemtests v1.0.0-rc.3 github.com/cosmos/cosmos-sdk v0.50.6 ) diff --git a/tests/systemtests/go.sum b/tests/systemtests/go.sum index e8228123732a..71d65c5309e4 100644 --- a/tests/systemtests/go.sum +++ b/tests/systemtests/go.sum @@ -16,8 +16,8 @@ cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= -cosmossdk.io/systemtests v1.0.0-rc.2.0.20241205143753-9e94ea87f6e4 h1:gt0rrxBW4x9KM3+ES8Gy5BZbKIHI3AspYEuvWZO6fgU= -cosmossdk.io/systemtests v1.0.0-rc.2.0.20241205143753-9e94ea87f6e4/go.mod h1:B3RY1tY/iwLjQ9MUTz+GsiXV9gEdS8mfUvSQtWUwaAo= +cosmossdk.io/systemtests v1.0.0-rc.3 h1:W1ZdfHtWxbzRCiBwcMb1nMKkmUNyAcHapJOrfh1lX20= +cosmossdk.io/systemtests v1.0.0-rc.3/go.mod h1:B3RY1tY/iwLjQ9MUTz+GsiXV9gEdS8mfUvSQtWUwaAo= cosmossdk.io/x/tx v0.13.3-0.20240419091757-db5906b1e894 h1:kHEvzVqpNv/9pnaEPBsgE/FMc+cVmWjSsInRufkZkpQ= cosmossdk.io/x/tx v0.13.3-0.20240419091757-db5906b1e894/go.mod h1:Tb6/tpONmtL5qFdOMdv1pdvrtJNxcazZBoz04HB71ss= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/x/genutil/v2/cli/commands.go b/x/genutil/v2/cli/commands.go index 6812345d23ba..8e27cbafc04b 100644 --- a/x/genutil/v2/cli/commands.go +++ b/x/genutil/v2/cli/commands.go @@ -20,7 +20,7 @@ type genesisMM interface { } type ExportableApp interface { - ExportAppStateAndValidators([]string) (v2.ExportedApp, error) + ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string) (v2.ExportedApp, error) LoadHeight(uint64) error } diff --git a/x/genutil/v2/cli/export.go b/x/genutil/v2/cli/export.go index c53236d49329..812201c322fd 100644 --- a/x/genutil/v2/cli/export.go +++ b/x/genutil/v2/cli/export.go @@ -17,6 +17,7 @@ import ( const ( flagHeight = "height" + flagForZeroHeight = "for-zero-height" flagJailAllowedAddrs = "jail-allowed-addrs" ) @@ -56,6 +57,7 @@ func ExportCmd(app ExportableApp) *cobra.Command { } height, _ := cmd.Flags().GetInt64(flagHeight) + forZeroHeight, _ := cmd.Flags().GetBool(flagForZeroHeight) jailAllowedAddrs, _ := cmd.Flags().GetStringSlice(flagJailAllowedAddrs) outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument) if height != -1 { @@ -63,7 +65,7 @@ func ExportCmd(app ExportableApp) *cobra.Command { return err } } - exported, err := app.ExportAppStateAndValidators(jailAllowedAddrs) + exported, err := app.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) if err != nil { return fmt.Errorf("error exporting state: %w", err) } @@ -105,6 +107,7 @@ func ExportCmd(app ExportableApp) *cobra.Command { StringSlice(flagJailAllowedAddrs, []string{}, "Comma-separated list of operator addresses of jailed validators to unjail") cmd.Flags(). String(flags.FlagOutputDocument, "", "Exported state is written to the given file instead of STDOUT") + cmd.Flags().Bool(flagForZeroHeight, false, "Export state to start at height zero (perform preproccessing)") return cmd }