Skip to content

Commit

Permalink
Operational swing-store artifact level (#9391)
Browse files Browse the repository at this point in the history
closes: #9388

## Description

Switch from `replay` to `operational` for state-sync export/restore,
genesis export/import, and as the default for cosmic-swingset's
export/import of kernel DB command line tool.

Drive by change of the default chain home directory for the
import/export tool (this location was effectively changed a couple year
ago but not consistently in the rest of the SDK).

### Security Considerations

If all nodes prune historical "replay" artifacts, we lose the ability to
perform replay based upgrades in the future. We expect archive nodes to
not manually prune their DB in this way.

### Scaling Considerations

This should have no impact on performance right now. In the future, when
exporting the IAVL data is not as slow, this would reduce the time it
takes for state-sync snapshots to be created.

### Documentation Considerations

Should communicate this change with validators

### Testing Considerations

Covered by existing integration tests.

### Upgrade Considerations

Chain software change
  • Loading branch information
mergify[bot] committed Jun 3, 2024
2 parents 440d7a8 + 319b386 commit 8879538
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
5 changes: 2 additions & 3 deletions golang/cosmos/x/swingset/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func InitGenesis(ctx sdk.Context, k Keeper, swingStoreExportsHandler *SwingStore
ReadNextArtifact: artifactProvider.ReadNextArtifact,
},
keeper.SwingStoreRestoreOptions{
ArtifactMode: keeper.SwingStoreArtifactModeReplay,
ArtifactMode: keeper.SwingStoreArtifactModeOperational,
ExportDataMode: keeper.SwingStoreExportDataModeAll,
},
)
Expand Down Expand Up @@ -98,9 +98,8 @@ func ExportGenesis(ctx sdk.Context, k Keeper, swingStoreExportsHandler *SwingSto
// The export will fail if the export of a historical height was requested
snapshotHeight,
swingStoreGenesisEventHandler{exportDir: swingStoreExportDir, snapshotHeight: snapshotHeight},
// The export will fail if the swing-store does not contain all replay artifacts
keeper.SwingStoreExportOptions{
ArtifactMode: keeper.SwingStoreArtifactModeReplay,
ArtifactMode: keeper.SwingStoreArtifactModeOperational,
ExportDataMode: keeper.SwingStoreExportDataModeSkip,
},
)
Expand Down
4 changes: 2 additions & 2 deletions golang/cosmos/x/swingset/keeper/extension_snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (snapshotter *ExtensionSnapshotter) InitiateSnapshot(height int64) error {
blockHeight := uint64(height)

return snapshotter.swingStoreExportsHandler.InitiateExport(blockHeight, snapshotter, SwingStoreExportOptions{
ArtifactMode: SwingStoreArtifactModeReplay,
ArtifactMode: SwingStoreArtifactModeOperational,
ExportDataMode: SwingStoreExportDataModeSkip,
})
}
Expand Down Expand Up @@ -304,6 +304,6 @@ func (snapshotter *ExtensionSnapshotter) RestoreExtension(blockHeight uint64, fo

return snapshotter.swingStoreExportsHandler.RestoreExport(
SwingStoreExportProvider{BlockHeight: blockHeight, GetExportDataReader: getExportDataReader, ReadNextArtifact: readNextArtifact},
SwingStoreRestoreOptions{ArtifactMode: SwingStoreArtifactModeReplay, ExportDataMode: SwingStoreExportDataModeAll},
SwingStoreRestoreOptions{ArtifactMode: SwingStoreArtifactModeOperational, ExportDataMode: SwingStoreExportDataModeAll},
)
}
9 changes: 3 additions & 6 deletions packages/cosmic-swingset/src/export-kernel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export const ExportManifestFileName = 'export-manifest.json';
*/
export const getEffectiveArtifactMode = artifactMode => {
switch (artifactMode) {
case undefined:
case 'none':
case 'operational':
return 'operational';
case undefined:
case 'replay':
return 'replay';
case 'archival':
Expand Down Expand Up @@ -296,11 +296,8 @@ export const main = async (

const stateDir =
processValue.getFlag('state-dir') ||
// We try to find the actual cosmos state directory (default=~/.ag-chain-cosmos)
`${processValue.getFlag(
'home',
`${homedir}/.ag-chain-cosmos`,
)}/data/agoric`;
// We try to find the actual cosmos state directory (default=~/.agoric)
`${processValue.getFlag('home', `${homedir}/.agoric`)}/data/agoric`;

const stateDirStat = await fs.stat(stateDir);
if (!stateDirStat.isDirectory()) {
Expand Down
9 changes: 3 additions & 6 deletions packages/cosmic-swingset/src/import-kernel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const checkAndGetImportSwingStoreOptions = (options, manifest) => {

manifest.data || Fail`State-sync manifest missing export data`;

const { artifactMode = manifest.artifactMode || 'replay' } = options;
const { artifactMode = manifest.artifactMode || 'operational' } = options;

if (artifactMode === 'none') {
throw Fail`Cannot import "export data" without at least "operational" artifacts`;
Expand Down Expand Up @@ -247,11 +247,8 @@ export const main = async (

const stateDir =
processValue.getFlag('state-dir') ||
// We try to find the actual cosmos state directory (default=~/.ag-chain-cosmos)
`${processValue.getFlag(
'home',
`${homedir}/.ag-chain-cosmos`,
)}/data/agoric`;
// We try to find the actual cosmos state directory (default=~/.agoric)
`${processValue.getFlag('home', `${homedir}/.agoric`)}/data/agoric`;

const stateDirStat = await fs.stat(stateDir);
if (!stateDirStat.isDirectory()) {
Expand Down

0 comments on commit 8879538

Please sign in to comment.