Skip to content

Commit

Permalink
fixup! feat(x/swingset): export swing store in genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Aug 22, 2023
1 parent 15b00c0 commit 127d93b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion golang/cosmos/daemon/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,14 @@ func (ac appCreator) newApp(

const (
// FlagExportDir is the command-line flag for the "export" command specifying
// where the output of the export should be placed.
// where the output of the export should be placed. It contains both the
// items names below: the genesis file, and a directory containing the
// exported swing-store artifacts
FlagExportDir = "export-dir"
// ExportedGenesisFileName is the file name used to save the genesis in the export-dir
ExportedGenesisFileName = "genesis.json"
// ExportedSwingStoreDirectoryName is the directory name used to save the swing-store
// export (artifacts only) in the export-dir
ExportedSwingStoreDirectoryName = "swing-store"
)

Expand Down Expand Up @@ -319,6 +323,10 @@ func extendCosmosExportCommand(cmd *cobra.Command, hasVMController bool) {
if err != nil {
return err
}
// We unconditionally set FlagSwingStoreExportDir as for export, it makes
// little sense for users to control this location separately, and we don't
// want to override any swing-store artifacts that may be associated to the
// current genesis.
serverCtx.Viper.Set(gaia.FlagSwingStoreExportDir, swingStoreExportPath)

// This will fail is a genesis.json already exists in the export-dir
Expand Down
11 changes: 9 additions & 2 deletions golang/cosmos/x/swingset/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ func InitGenesis(ctx sdk.Context, k Keeper, swingStoreExportsHandler *SwingStore
}

err = swingStoreExportsHandler.RestoreExport(
keeper.SwingStoreExportProvider{BlockHeight: snapshotHeight, GetExportDataReader: getExportDataReader, ReadNextArtifact: artifactProvider.ReadNextArtifact},
keeper.SwingStoreRestoreOptions{ArtifactMode: keeper.SwingStoreArtifactModeReplay, ExportDataMode: keeper.SwingStoreExportDataModeAll},
keeper.SwingStoreExportProvider{
BlockHeight: snapshotHeight,
GetExportDataReader: getExportDataReader,
ReadNextArtifact: artifactProvider.ReadNextArtifact,
},
keeper.SwingStoreRestoreOptions{
ArtifactMode: keeper.SwingStoreArtifactModeReplay,
ExportDataMode: keeper.SwingStoreExportDataModeAll,
},
)
if err != nil {
panic(err)
Expand Down

0 comments on commit 127d93b

Please sign in to comment.