From 85fd98af6d0ad66b8be36c517710c0148473417f Mon Sep 17 00:00:00 2001 From: Chip Morningstar Date: Mon, 14 Nov 2022 14:41:18 -0800 Subject: [PATCH] fix: CI failures in other packages --- packages/cosmic-swingset/src/launch-chain.js | 14 +++++--------- packages/solo/src/start.js | 15 +++++---------- packages/swing-store/src/swingStore.js | 16 ++++++++-------- packages/swingset-runner/src/main.js | 8 ++------ 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/packages/cosmic-swingset/src/launch-chain.js b/packages/cosmic-swingset/src/launch-chain.js index 108bb2c37834..a880d868224c 100644 --- a/packages/cosmic-swingset/src/launch-chain.js +++ b/packages/cosmic-swingset/src/launch-chain.js @@ -220,15 +220,11 @@ export async function launch({ }) { console.info('Launching SwingSet kernel'); - const { kvStore, streamStore, snapStore, commit } = openSwingStore( - kernelStateDBDir, - { traceFile: swingStoreTraceFile, keepSnapshots }, - ); - const hostStorage = { - kvStore, - streamStore, - snapStore, - }; + const hostStorage = openSwingStore(kernelStateDBDir, { + traceFile: swingStoreTraceFile, + keepSnapshots, + }); + const { kvStore, commit } = hostStorage; // makeQueue() thinks it should commit/abort, but the kvStore doesn't provide // those ('commit' is reserved for flushing the block buffer). Furthermore diff --git a/packages/solo/src/start.js b/packages/solo/src/start.js index a0c250ff3988..9aa70abd9b65 100644 --- a/packages/solo/src/start.js +++ b/packages/solo/src/start.js @@ -198,15 +198,10 @@ const buildSwingset = async ( const keepSnapshots = XSNAP_KEEP_SNAPSHOTS === '1' || XSNAP_KEEP_SNAPSHOTS === 'true'; - const { kvStore, streamStore, snapStore, commit } = openSwingStore( - kernelStateDBDir, - { traceFile: swingStoreTraceFile, keepSnapshots }, - ); - const hostStorage = { - kvStore, - streamStore, - snapStore, - }; + const hostStorage = openSwingStore(kernelStateDBDir, { + traceFile: swingStoreTraceFile, + keepSnapshots, + }); // Not to be confused with the gas model, this meter is for OpenTelemetry. const metricMeter = metricsProvider.getMeter('ag-solo'); @@ -240,7 +235,7 @@ const buildSwingset = async ( async function saveState() { const ms = JSON.stringify(mbs.exportToData()); await atomicReplaceFile(mailboxStateFile, ms); - await commit(); + await hostStorage.commit(); } function deliverOutbound() { diff --git a/packages/swing-store/src/swingStore.js b/packages/swing-store/src/swingStore.js index ac76b17f5624..60b65e8b398d 100644 --- a/packages/swing-store/src/swingStore.js +++ b/packages/swing-store/src/swingStore.js @@ -325,8 +325,12 @@ function makeSwingStore(dirPath, forceReset, options) { function set(key, value) { assert.typeof(key, 'string'); assert.typeof(value, 'string'); + // synchronous read after write within a transaction is safe + // The transaction's overall success will be awaited during commit + ensureTxn(); + sqlKVSet.run(key, value); const keyType = getKeyType(key); - assert(keyType !== 'invalid'); + // assert(keyType !== 'invalid'); if (keyType === 'consensus') { crankhasher.add('add'); crankhasher.add('\n'); @@ -335,10 +339,6 @@ function makeSwingStore(dirPath, forceReset, options) { crankhasher.add(value); crankhasher.add('\n'); } - // synchronous read after write within a transaction is safe - // The transaction's overall success will be awaited during commit - ensureTxn(); - sqlKVSet.run(key, value); trace('set', key, value); } @@ -357,16 +357,16 @@ function makeSwingStore(dirPath, forceReset, options) { */ function del(key) { assert.typeof(key, 'string'); + ensureTxn(); + sqlKVDel.run(key); const keyType = getKeyType(key); - assert(keyType !== 'invalid'); + // assert(keyType !== 'invalid'); if (keyType === 'consensus') { crankhasher.add('delete'); crankhasher.add('\n'); crankhasher.add(key); crankhasher.add('\n'); } - ensureTxn(); - sqlKVDel.run(key); trace('del', key); } diff --git a/packages/swingset-runner/src/main.js b/packages/swingset-runner/src/main.js index 86e3ca326375..ea3aac4a9c33 100644 --- a/packages/swingset-runner/src/main.js +++ b/packages/swingset-runner/src/main.js @@ -423,16 +423,12 @@ export async function main() { runtimeOptions.slogSender = slogSender; } let bootstrapResult; - const hostStorage = { - kvStore: swingStore.kvStore, - streamStore: swingStore.streamStore, - }; if (forceReset) { // eslint-disable-next-line @jessie.js/no-nested-await bootstrapResult = await initializeSwingset( config, bootstrapArgv, - hostStorage, + swingStore, { verbose }, runtimeOptions, ); @@ -445,7 +441,7 @@ export async function main() { } } const controller = await makeSwingsetController( - hostStorage, + swingStore, deviceEndowments, runtimeOptions, );