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

fix(SwingSet): remove consensusMode flip-flop #4768

Merged
merged 3 commits into from
Mar 12, 2022
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
5 changes: 2 additions & 3 deletions packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function makeStartXSnap(bundles, { snapStore, env, spawn }) {
* slogSender?: (obj: any, jsonObj: string) => void,
* testTrackDecref?: unknown,
* warehousePolicy?: { maxVatsOnline?: number },
* overrideVatManagerOptions?: { consensusMode?: boolean },
* overrideVatManagerOptions?: unknown,
* spawn?: typeof import('child_process').spawn,
* env?: Record<string, string | undefined>
* }} runtimeOptions
Expand Down Expand Up @@ -445,8 +445,7 @@ export async function makeSwingsetController(
* @param {{ hostStorage?: HostStore, env?: Record<string, string>, verbose?:
* boolean, kernelBundles?: Record<string, string>, debugPrefix?: string,
* slogCallbacks?: unknown, testTrackDecref?: unknown, warehousePolicy?: {
* maxVatsOnline?: number }, overrideVatManagerOptions?: { consensusMode?:
* boolean }, slogFile?: string, }} runtimeOptions
* maxVatsOnline?: number }, slogFile?: string }} runtimeOptions
* @typedef { import('@agoric/swing-store').KVStore } KVStore
*/
export async function buildVatController(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export function makeVatManagerFactory({

function validateManagerOptions(managerOptions) {
assertKnownOptions(managerOptions, [
'consensusMode',
'enablePipelining',
'managerType',
'gcEveryCrank',
Expand Down
13 changes: 1 addition & 12 deletions packages/SwingSet/src/kernel/vat-loader/manager-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function makeLocalVatManagerFactory(tools) {
vatSyscallHandler,
) {
const {
consensusMode,
enableDisavow = false,
enableSetup = false,
vatConsole,
Expand Down Expand Up @@ -100,17 +99,7 @@ export function makeLocalVatManagerFactory(tools) {
const makeLog = level => {
const log = logger[level];
assert.typeof(log, 'function', X`logger[${level}] must be a function`);
return (...args) => {
// We have to dynamically wrap the consensus mode so that it can change
// during the lifetime of the supervisor (which when snapshotting, is
// restored to its current heap across restarts, not actually stopping
// until the vat is terminated).
if (consensusMode) {
return;
}

log(...args);
};
return log;
};
return makeLog;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export function makeNodeWorkerVatManagerFactory(tools) {

function createFromBundle(vatID, bundle, managerOptions, vatSyscallHandler) {
const {
consensusMode,
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
Expand Down Expand Up @@ -113,7 +112,6 @@ export function makeNodeWorkerVatManagerFactory(tools) {
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
consensusMode,
]);

function deliverToWorker(delivery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function makeNodeSubprocessFactory(tools) {

function createFromBundle(vatID, bundle, managerOptions, vatSyscallHandler) {
const {
consensusMode,
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
Expand Down Expand Up @@ -108,7 +107,6 @@ export function makeNodeSubprocessFactory(tools) {
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
consensusMode,
]);

function shutdown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function makeXsSubprocessFactory({
) {
parentLog(vatID, 'createFromBundle', { vatID });
const {
consensusMode,
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
Expand Down Expand Up @@ -149,7 +148,6 @@ export function makeXsSubprocessFactory({
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
consensusMode,
gcEveryCrank,
]);
if (bundleReply[0] === 'dispatchReady') {
Expand All @@ -168,7 +166,7 @@ export function makeXsSubprocessFactory({
parentLog(vatID, `sending delivery`, delivery);
let result;
try {
result = await issueTagged(['deliver', delivery, consensusMode]);
result = await issueTagged(['deliver', delivery]);
} catch (err) {
parentLog('issueTagged error:', err.code, err.message);
let message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ parentPort.on('message', ([type, ...margs]) => {
workerLog(`got start`);
sendUplink(['gotStart']);
} else if (type === 'setBundle') {
const [
bundle,
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
consensusMode,
] = margs;
const [bundle, virtualObjectCacheSize, enableDisavow, enableVatstore] =
margs;

function testLog(...args) {
sendUplink(['testLog', ...args]);
Expand Down Expand Up @@ -85,14 +80,6 @@ parentPort.on('message', ([type, ...margs]) => {
const log = logger[level];
assert.typeof(log, 'function', X`logger[${level}] must be a function`);
return (...args) => {
// We have to dynamically wrap the consensus mode so that it can change
// during the lifetime of the supervisor (which when snapshotting, is
// restored to its current heap across restarts, not actually stopping
// until the vat is terminated).
if (consensusMode) {
return;
}

log(...args);
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ fromParent.on('data', ([type, ...margs]) => {
workerLog(`got start`);
sendUplink(['gotStart']);
} else if (type === 'setBundle') {
const [
bundle,
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
consensusMode,
] = margs;
const [bundle, virtualObjectCacheSize, enableDisavow, enableVatstore] =
margs;

function testLog(...args) {
sendUplink(['testLog', ...args]);
Expand Down Expand Up @@ -104,14 +99,6 @@ fromParent.on('data', ([type, ...margs]) => {
const log = logger[level];
assert.typeof(log, 'function', X`logger[${level}] must be a function`);
return (...args) => {
// We have to dynamically wrap the consensus mode so that it can change
// during the lifetime of the supervisor (which when snapshotting, is
// restored to its current heap across restarts, not actually stopping
// until the vat is terminated).
if (consensusMode) {
return;
}

log(...args);
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,12 @@ function makeWorker(port) {
/** @type { ((delivery: VatDeliveryObject) => Promise<VatDeliveryResult>) | null } */
let dispatch = null;

/** @type {unknown} */
let currentConsensusMode;

/**
* @param {unknown} vatID
* @param {unknown} bundle
* @param {unknown} virtualObjectCacheSize
* @param {boolean} enableDisavow
* @param {boolean} enableVatstore
* @param {boolean} consensusMode
* @param {boolean} [gcEveryCrank]
* @returns { Promise<Tagged> }
*/
Expand All @@ -199,12 +195,8 @@ function makeWorker(port) {
virtualObjectCacheSize,
enableDisavow,
enableVatstore,
consensusMode,
gcEveryCrank,
) {
// Enable or disable the consensus mode according to current settings.
currentConsensusMode = consensusMode;

/** @type { (vso: VatSyscallObject) => VatSyscallResult } */
function syscallToManager(vatSyscallObject) {
workerLog('doSyscall', vatSyscallObject);
Expand Down Expand Up @@ -255,14 +247,6 @@ function makeWorker(port) {
port.send([dst, level, ...args]);
};
return (...args) => {
// We have to dynamically wrap the consensus mode so that it can change
// during the lifetime of the supervisor (which when snapshotting, is
// restored to its current heap across restarts, not actually stopping
// until the vat is terminated).
if (currentConsensusMode) {
return;
}

// Use the causal console, but output to the port.
//
// FIXME: This is a hack until the start compartment can create
Expand Down Expand Up @@ -328,22 +312,19 @@ function makeWorker(port) {
assert(!dispatch, 'cannot setBundle again');
const enableDisavow = !!args[3];
const enableVatstore = !!args[4];
const consensusMode = !!args[5];
const gcEveryCrank = args[6] === undefined ? true : !!args[6];
const gcEveryCrank = args[5] === undefined ? true : !!args[5];
return setBundle(
args[0],
args[1],
args[2],
enableDisavow,
enableVatstore,
consensusMode,
gcEveryCrank,
);
}
case 'deliver': {
assert(dispatch, 'cannot deliver before setBundle');
const [vatDeliveryObject, consensusMode] = args;
currentConsensusMode = consensusMode;
const [vatDeliveryObject] = args;
insistVatDeliveryObject(vatDeliveryObject);
return dispatch(vatDeliveryObject);
}
Expand Down
1 change: 0 additions & 1 deletion packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export {};
*
* @typedef { 'local' | 'nodeWorker' | 'node-subprocess' | 'xs-worker' | 'xs-worker-no-gc' } ManagerType
* @typedef {{
* consensusMode: boolean,
* enablePipelining?: boolean,
* managerType: ManagerType,
* gcEveryCrank?: boolean,
Expand Down
4 changes: 0 additions & 4 deletions packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ export default async function main(progname, args, { env, homedir, agcc }) {

const mapSize = (LMDB_MAP_SIZE && parseInt(LMDB_MAP_SIZE, 10)) || undefined;

// We want to make it hard for a validator to accidentally disable
// consensusMode.
const consensusMode = true;
const s = await launch({
actionQueue,
kernelStateDBDir: stateDBDir,
Expand All @@ -358,7 +355,6 @@ export default async function main(progname, args, { env, homedir, agcc }) {
metricsProvider,
slogFile: SLOGFILE,
slogSender,
consensusMode,
mapSize,
});
return s;
Expand Down
5 changes: 1 addition & 4 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function buildSwingset(
hostStorage,
vatconfig,
argv,
{ consensusMode, debugName = undefined, slogCallbacks, slogFile, slogSender },
{ debugName = undefined, slogCallbacks, slogFile, slogSender },
) {
const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
let config = await loadSwingsetConfigFile(vatconfig);
Expand Down Expand Up @@ -79,7 +79,6 @@ async function buildSwingset(
hostStorage,
deviceEndowments,
{
overrideVatManagerOptions: { consensusMode },
slogCallbacks,
slogFile,
slogSender,
Expand Down Expand Up @@ -151,7 +150,6 @@ export async function launch({
metricsProvider = DEFAULT_METER_PROVIDER,
slogFile = undefined,
slogSender,
consensusMode = true,
mapSize = DEFAULT_LMDB_MAP_SIZE,
}) {
console.info('Launching SwingSet kernel');
Expand Down Expand Up @@ -184,7 +182,6 @@ export async function launch({
slogCallbacks,
slogFile,
slogSender,
consensusMode,
},
);

Expand Down
3 changes: 0 additions & 3 deletions packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
},
};

// We don't want to force a sim chain to use consensus mode.
const consensusMode = false;
const s = await launch({
actionQueue,
kernelStateDBDir: stateDBdir,
Expand All @@ -120,7 +118,6 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
metricsProvider,
slogFile: SLOGFILE,
slogSender,
consensusMode,
mapSize,
});

Expand Down