Skip to content

Commit

Permalink
feat: refresh slogulator to account for smallcaps and improve UX
Browse files Browse the repository at this point in the history
This is in support of #8647
  • Loading branch information
FUDCo committed Dec 18, 2023
1 parent 1b6f03b commit 73b4514
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 121 deletions.
15 changes: 15 additions & 0 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,19 @@ export default function buildKernel(
return results;
}

function getCrankVatForSlog(message) {
if (message.type === 'send') {
const { type } = parseKernelSlot(message.target);
if (type !== 'promise') {
return kernelKeeper.ownerOfKernelObject(message.target);
} else {
return '<unknown vat>';
}
} else {
return message.vatID;
}
}

/**
* @param {RunQueueEvent} message
* @returns {Promise<PolicyInput>}
Expand All @@ -1216,6 +1229,7 @@ export default function buildKernel(
crankType: 'delivery',
crankNum: kernelKeeper.getCrankNumber(),
message,
vatID: getCrankVatForSlog(message),
});
/** @type { PolicyInput } */
let policyInput = ['none', {}];
Expand Down Expand Up @@ -1375,6 +1389,7 @@ export default function buildKernel(
crankType: 'routing',
crankNum: kernelKeeper.getCrankNumber(),
message,
vatID: getCrankVatForSlog(message),
});
/** @type { PolicyInput } */
const policyInput = ['none', {}];
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ export default function makeKernelKeeper(kernelStorage, kernelSlog) {
const acceptanceQueue = dumpQueue('acceptanceQueue');

return harden({
crankNumber: kvStore.get('crankNumber'),
vatTables,
kernelTable,
promises,
Expand Down
13 changes: 2 additions & 11 deletions packages/SwingSet/tools/run-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ const sink = () => {};

/**
* @param {import('../src/controller/controller.js').SwingsetController} controller
* @param {(...args: any[]) => void} [log]
*/
export const makeRunUtils = (controller, log = (..._) => {}) => {
let cranksRun = 0;

export const makeRunUtils = controller => {
const mutex = makeQueue();

mutex.put(controller.run());
Expand All @@ -27,18 +24,12 @@ export const makeRunUtils = (controller, log = (..._) => {}) => {

const thunkResult = await thunk();

const result = controller.run().then(cranks => {
cranksRun += cranks;
log(`kernel ran ${cranks} cranks`);
return thunkResult;
});
const result = controller.run().then(() => thunkResult);
mutex.put(result.then(sink, sink));
return result;
};

const queueAndRun = async (deliveryThunk, voidResult = false) => {
log('queueAndRun at', cranksRun);

const kpid = await runThunk(deliveryThunk);

if (voidResult) {
Expand Down
1 change: 1 addition & 0 deletions packages/swingset-runner/bin/slogulator-debug
17 changes: 17 additions & 0 deletions packages/swingset-runner/src/slogulator-debug-entrypoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node --inspect-brk
/* eslint-env node */

/**
* Simple boilerplate program providing linkage to launch an application written using modules within the
* as yet not-entirely-ESM-supporting version of NodeJS.
*/
import '@endo/init';
import { main } from './slogulator.js';

process.exitCode = 1;
try {
main();
process.exitCode = 0;
} catch (error) {
console.error(error);
}
14 changes: 6 additions & 8 deletions packages/swingset-runner/src/slogulator-entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import '@endo/init';
import { main } from './slogulator.js';

process.exitCode = 1;
main().then(
() => {
process.exitCode = 0;
},
error => {
console.error(error);
},
);
try {
main();
process.exitCode = 0;
} catch (error) {
console.error(error);
}
Loading

0 comments on commit 73b4514

Please sign in to comment.