diff --git a/golang/cosmos/x/swingset/keeper/snapshotter.go b/golang/cosmos/x/swingset/keeper/snapshotter.go index 8d8244f29ab5..c86f42eb9698 100644 --- a/golang/cosmos/x/swingset/keeper/snapshotter.go +++ b/golang/cosmos/x/swingset/keeper/snapshotter.go @@ -332,22 +332,24 @@ func (snapshotter *SwingsetSnapshotter) RestoreExtension(height uint64, format u return err } - filename := artifactNameSanitizer.ReplaceAllString(filepath.Base(payload.Name), "-") - filename = fmt.Sprintf("%d-%s", len(manifest.Artifacts), filename) - manifest.Artifacts = append(manifest.Artifacts, [2]string{payload.Name, filename}) - err = writeExportFile(filename, payload.Data) - - if payload.Name == UntrustedExportDataArtifactName { - if len(swingStoreEntries) == 0 { - snapshotter.logger().Info("using unverified export data for swingstore restore") - _, err := exportDataFile.Write(payload.Data) - if err != nil { - return err - } - continue - } else { - filename = UntrustedExportDataFilename - } + switch { + case payload.Name != UntrustedExportDataArtifactName: + // Artifact verifiable on import from the export data + filename := artifactNameSanitizer.ReplaceAllString(filepath.Base(payload.Name), "-") + filename = fmt.Sprintf("%d-%s", len(manifest.Artifacts), filename) + manifest.Artifacts = append(manifest.Artifacts, [2]string{payload.Name, filename}) + err = writeExportFile(filename, payload.Data) + + case len(swingStoreEntries) > 0: + // Pseudo artifact containing untrusted export data which may have been + // saved separately for debugging purposes (not referenced from the manifest) + err = writeExportFile(UntrustedExportDataFilename, payload.Data) + + default: + // There is no trusted export data, so use any untrusted export data artifact + // FIXME: Remove. Only useful if streamed export data is disabled + snapshotter.logger().Info("using unverified export data for swingstore restore") + _, err = exportDataFile.Write(payload.Data) } if err != nil {