Skip to content

Commit

Permalink
feat: tweak state-sync logging (#7468)
Browse files Browse the repository at this point in the history
Do not default to printing out export steps
Add logging to restore process

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
mhofman and mergify[bot] authored Apr 22, 2023
1 parent 338650a commit 9ec9ce2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion golang/cosmos/x/swingset/keeper/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (snapshotter *SwingsetSnapshotter) SnapshotExtension(height uint64, payload

snapshotter.activeSnapshot.retrieved = true

snapshotter.activeSnapshot.logger.Info("fully retrieved snapshot from", "exportDir", exportDir)
snapshotter.activeSnapshot.logger.Info("retrieved snapshot", "exportDir", exportDir)

return nil
}
Expand Down Expand Up @@ -460,5 +460,7 @@ func (snapshotter *SwingsetSnapshotter) RestoreExtension(height uint64, format u
return err
}

snapshotter.logger.Info("restored snapshot", "exportDir", exportDir, "height", height)

return nil
}
10 changes: 9 additions & 1 deletion packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,13 @@ export default async function main(progname, args, { env, homedir, agcc }) {
if (typeof exportDir !== 'string') {
throw Fail`Invalid exportDir argument ${q(exportDir)}`;
}
console.info(
'Restoring SwingSet state from snapshot at block height',
blockHeight,
);
return performStateSyncImport(
{ exportDir, stateDir: stateDBDir, blockHeight },
{ fs: { ...fs, ...fsPromises }, pathResolve },
{ fs: { ...fs, ...fsPromises }, pathResolve, log: null },
);
}
case 'initiate': {
Expand Down Expand Up @@ -534,6 +538,10 @@ export default async function main(progname, args, { env, homedir, agcc }) {
);
});

console.info(
'Initiating SwingSet state snapshot at block height',
blockHeight,
);
exportData.exporter = spawnSwingStoreExport(
{
stateDir: stateDBDir,
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/src/export-kernel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const checkExportMode = mode => {
* @param {import('path')['resolve']} powers.pathResolve
* @param {typeof import('@agoric/swing-store')['makeSwingStoreExporter']} [powers.makeSwingStoreExporter]
* @param {typeof import('@agoric/swing-store')['openSwingStore']} [powers.openSwingStore]
* @param {(...args: any[]) => void} [powers.log]
* @param {null | ((...args: any[]) => void)} [powers.log]
* @returns {StateSyncExporter}
*/
export const initiateSwingStoreExport = (
Expand Down Expand Up @@ -274,7 +274,7 @@ export const main = async (
{
fs,
pathResolve,
log: verbose ? console.log : undefined,
log: verbose ? console.log : null,
},
);

Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/src/import-kernel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { makeProcessValue } from './helpers/process-value.js';
* @param {Pick<import('fs/promises'), 'readFile'> & Pick<import('fs'), 'createReadStream'>} powers.fs
* @param {import('path')['resolve']} powers.pathResolve
* @param {typeof import('@agoric/swing-store')['importSwingStore']} [powers.importSwingStore]
* @param {(...args: any[]) => void} [powers.log]
* @param {null | ((...args: any[]) => void)} [powers.log]
* @returns {Promise<void>}
*/
export const performStateSyncImport = async (
Expand All @@ -40,7 +40,7 @@ export const performStateSyncImport = async (
fs: { createReadStream, readFile },
pathResolve,
importSwingStore: importDB = importSwingStore,
log,
log = console.log,
},
) => {
/** @param {string} allegedRelativeFilename */
Expand Down

0 comments on commit 9ec9ce2

Please sign in to comment.