Skip to content

Commit 0efc33f

Browse files
committed
feat: use debugName to differentiate sim-chain instances
1 parent 92b67d1 commit 0efc33f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

packages/SwingSet/src/controller.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ function makeConsole(tag) {
3535
}
3636
const console = makeConsole('SwingSet:controller');
3737

38-
// FIXME: Put this somewhere better.
39-
process.on('unhandledRejection', e =>
40-
console.error('UnhandledPromiseRejectionWarning:', e),
41-
);
42-
4338
const ADMIN_DEVICE_PATH = require.resolve('./kernel/vatAdmin/vatAdmin-src');
4439
const ADMIN_VAT_PATH = require.resolve('./kernel/vatAdmin/vatAdminWrapper');
4540
const KERNEL_SOURCE_PATH = require.resolve('./kernel/kernel.js');
@@ -135,10 +130,19 @@ export async function buildVatController(
135130
argv = [],
136131
runtimeOptions = {},
137132
) {
133+
const { debugPrefix = '' } = runtimeOptions;
138134
if (typeof Compartment === 'undefined') {
139135
throw Error('SES must be installed before calling buildVatController');
140136
}
141137

138+
// eslint-disable-next-line no-shadow
139+
const console = makeConsole(`${debugPrefix}SwingSet:controller`);
140+
141+
// FIXME: Put this somewhere better.
142+
process.on('unhandledRejection', e =>
143+
console.error('UnhandledPromiseRejectionWarning:', e),
144+
);
145+
142146
// https://github.com/Agoric/SES-shim/issues/292
143147
harden(Object.getPrototypeOf(console));
144148
harden(console);
@@ -168,7 +172,7 @@ export async function buildVatController(
168172
const kernelNS = await importBundle(kernelSource, {
169173
filePrefix: 'kernel',
170174
endowments: {
171-
console: makeConsole('SwingSet:kernel'),
175+
console: makeConsole(`${debugPrefix}SwingSet:kernel`),
172176
require: kernelRequire,
173177
HandledPromise,
174178
},
@@ -203,7 +207,7 @@ export async function buildVatController(
203207

204208
function makeVatEndowments(consoleTag) {
205209
return harden({
206-
console: makeConsole(`SwingSet:${consoleTag}`),
210+
console: makeConsole(`${debugPrefix}SwingSet:${consoleTag}`),
207211
HandledPromise,
208212
// re2 is a RegExp work-a-like that disables backtracking expressions for
209213
// safer memory consumption

packages/cosmic-swingset/lib/ag-solo/fake-chain.js

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export async function connectToFakeChain(basedir, GCI, role, delay, inbound) {
6262
flushChainSends,
6363
vatsdir,
6464
argv,
65+
GCI, // debugName
6566
);
6667

6768
const blockManager = makeBlockManager(s);

packages/cosmic-swingset/lib/launch-chain.js

+5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ async function buildSwingset(
2222
storage,
2323
vatsDir,
2424
argv,
25+
debugName = undefined,
2526
) {
27+
const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
2628
const config = {};
2729
const mbs = buildMailboxStateMap();
2830
mbs.populateFromData(mailboxState);
@@ -50,6 +52,7 @@ async function buildSwingset(
5052

5153
const controller = await buildVatController(config, argv, {
5254
hostStorage: storage,
55+
debugPrefix,
5356
});
5457
await controller.run();
5558

@@ -64,6 +67,7 @@ export async function launch(
6467
flushChainSends,
6568
vatsDir,
6669
argv,
70+
debugName = undefined,
6771
) {
6872
log.info('Launching SwingSet kernel');
6973

@@ -87,6 +91,7 @@ export async function launch(
8791
storage,
8892
vatsDir,
8993
argv,
94+
debugName,
9095
);
9196

9297
function saveChainState() {

0 commit comments

Comments
 (0)