Skip to content

Commit

Permalink
fix(swingset): implement replayTranscript for all vat types
Browse files Browse the repository at this point in the history
"local" workers had this already, but "nodeWorker" and "subprocess-node" did
not.
  • Loading branch information
warner committed Jan 18, 2021
1 parent ca4188b commit 7fde6a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
17 changes: 13 additions & 4 deletions packages/SwingSet/src/kernel/vatManager/nodeWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export function makeNodeWorkerVatManagerFactory(tools) {
// TODO: warn+ignore, rather than throw, because the kernel enables it
// for all vats, because the Spawner still needs it. When the kernel
// stops doing that, turn this into a regular assert
console.log(`node-worker does not support enableInternalMetering`);
console.log(
`node-worker does not support enableInternalMetering, ignoring`,
);
}
const vatKeeper = kernelKeeper.getVatKeeper(vatID);
const transcriptManager = makeTranscriptManager(
Expand Down Expand Up @@ -135,9 +137,16 @@ export function makeNodeWorkerVatManagerFactory(tools) {
return pr.promise;
}

function replayTranscript() {
// TODO unimplemented
throw Error(`replayTranscript not yet implemented`);
async function replayTranscript() {
transcriptManager.startReplay();
for (const t of vatKeeper.getTranscript()) {
transcriptManager.checkReplayError();
transcriptManager.startReplayDelivery(t.syscalls);
// eslint-disable-next-line no-await-in-loop
await deliver(t.d);
}
transcriptManager.checkReplayError();
transcriptManager.finishReplay();
}

function shutdown() {
Expand Down
17 changes: 13 additions & 4 deletions packages/SwingSet/src/kernel/vatManager/worker-subprocess-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export function makeNodeSubprocessFactory(tools) {
// TODO: warn+ignore, rather than throw, because the kernel enables it
// for all vats, because the Spawner still needs it. When the kernel
// stops doing that, turn this into a regular assert
console.log(`node-worker does not support enableInternalMetering`);
console.log(
`node-worker does not support enableInternalMetering, ignoring`,
);
}
const vatKeeper = kernelKeeper.getVatKeeper(vatID);
const transcriptManager = makeTranscriptManager(
Expand Down Expand Up @@ -135,9 +137,16 @@ export function makeNodeSubprocessFactory(tools) {
return pr.promise;
}

function replayTranscript() {
// TODO unimplemented
throw Error(`replayTranscript not yet implemented`);
async function replayTranscript() {
transcriptManager.startReplay();
for (const t of vatKeeper.getTranscript()) {
transcriptManager.checkReplayError();
transcriptManager.startReplayDelivery(t.syscalls);
// eslint-disable-next-line no-await-in-loop
await deliver(t.d);
}
transcriptManager.checkReplayError();
transcriptManager.finishReplay();
}

function shutdown() {
Expand Down

0 comments on commit 7fde6a4

Please sign in to comment.