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

chore(SwingSet): Improve anachrophobia messages #10469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 20 additions & 12 deletions packages/SwingSet/src/kernel/vat-warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function makeSyscallSimulator(
deliveryNum,
transcriptEntry,
) {
const context = `anachrophobia in ${vatID} delivery ${deliveryNum}`;
const syscallsExpected = [...transcriptEntry.sc]; // copy
const syscallsMade = [];
// syscallStatus's length will be max(syscallsExpected,
Expand All @@ -107,7 +108,9 @@ export function makeSyscallSimulator(
let replayError; // sticky

const explain = () => {
console.log(`anachrophobia strikes ${vatID} on delivery ${deliveryNum}`);
console.log(
`anachrophobia strikes ${vatID} syscalls for delivery ${deliveryNum}`,
);
for (const [idx, status] of syscallStatus.entries()) {
const expected = syscallsExpected[idx];
const got = syscallsMade[idx];
Expand All @@ -117,17 +120,20 @@ export function makeSyscallSimulator(
break;
}
case 'wrong': {
console.log(`sc[${idx}]: wrong`);
console.log(` expected: ${djson.stringify(expected.s)}`);
console.log(` got : ${djson.stringify(got)}`);
console.log(
`
sc[${idx}]: WRONG
expected: ${djson.stringify(expected.s)}
got : ${djson.stringify(got)}`.trimStart(),
);
break;
}
case 'extra': {
console.log(`sc[${idx}]: extra: ${djson.stringify(got)}`);
console.log(`sc[${idx}]: EXTRA: ${djson.stringify(got)}`);
break;
}
case 'missing': {
console.log(`sc[${idx}]: missing: ${djson.stringify(expected.s)}`);
console.log(`sc[${idx}]: MISSING: ${djson.stringify(expected.s)}`);
break;
}
default:
Expand All @@ -140,16 +146,16 @@ export function makeSyscallSimulator(
// slog entries have no kernel-translated kso/ksr
const finish = kernelSlog.syscall(vatID, undefined, vso);
const expected = syscallsExpected[syscallsMade.length];
syscallsMade.push(vso);
const idx = syscallsMade.push(vso) - 1;
if (!expected) {
syscallStatus.push('extra');
const error = Error(`anachrophobia in ${vatID}: extra syscall`);
const error = Error(`${context}: extra syscall at index ${idx}`);
replayError ||= error;
throw error;
}
if (!syscallsAreIdentical(expected.s, vso)) {
syscallStatus.push('wrong');
const error = Error(`anachrophobia in ${vatID}: wrong syscall`);
const error = Error(`${context}: wrong syscall at index ${idx}`);
replayError ||= error;
throw error;
}
Expand All @@ -159,12 +165,14 @@ export function makeSyscallSimulator(
};

const finishSimulation = () => {
if (syscallsMade.length < syscallsExpected.length) {
const missing = syscallsExpected.length - syscallsMade.length;
const missing = syscallsExpected.length - syscallsMade.length;
if (missing > 0) {
for (let i = 0; i < missing; i += 1) {
syscallStatus.push('missing');
}
const error = Error(`anachrophobia in ${vatID}: missing syscalls`);
const error = Error(
`${context}: missing ${missing} syscall(s) at index ${syscallsMade.length}`,
);
replayError ||= error;
}

Expand Down
Loading