Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tweak state-sync logging #7468

Merged
merged 3 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
);
Comment on lines +541 to +544
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should this precede the tmpdir creation?

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that'd do it!

},
);

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