Skip to content
Draft
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@graphql-tools/optimize@npm:^2.0.0": "patch:@graphql-tools/optimize@npm%3A2.0.0#~/.yarn/patches/@graphql-tools-optimize-npm-2.0.0-710bf461f3.patch"
},
"dependenciesMeta": {
"[email protected]": {
"@photostructure/[email protected]": {
"built": true
},
"[email protected]": {
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/misc-tools/baggage-check-tool.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import process from 'process';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import '@endo/init/debug.js';
import { checkBaggage } from '../tools/baggage-check.js';

Expand All @@ -12,7 +12,7 @@ function main() {
const vatID = argv[0];
const dbPath = argv[1];

const db = sqlite3(dbPath);
const db = createDatabase(dbPath);
checkBaggage(db, vatID, true);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/misc-tools/build-mezzanine-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import process from 'process';
import readline from 'readline';

import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';

function makeDB(dbPath) {
const db = sqlite3(dbPath);
const db = createDatabase(dbPath);
const indexes = [];
const sql = {};
db.exec(`PRAGMA journal_mode=WAL`);
Expand Down Expand Up @@ -243,7 +243,7 @@
}

function copySwingStore(sql, swingstoreDbPath) {
const swingstoreDb = sqlite3(swingstoreDbPath);

Check failure on line 246 in packages/SwingSet/misc-tools/build-mezzanine-db.js

View workflow job for this annotation

GitHub Actions / lint-primary

'sqlite3' is not defined
sql.clearPromiseDeciders.run();
sql.clearPromiseSubscribers.run();
/** @type {any} */
Expand Down
8 changes: 4 additions & 4 deletions packages/SwingSet/misc-tools/classify-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @ts-nocheck XXX
/* eslint no-labels: "off", no-extra-label: "off", no-underscore-dangle: "off" */
import process from 'process';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import yargsParser from 'yargs-parser';
import '@endo/init/debug.js';
import { makeStandinPromise, krefOf } from '@agoric/kmarshal';
Expand Down Expand Up @@ -157,7 +157,7 @@ const decodeResolveSyscall = syscall => {
* In either case, it also returns a reverse-sorted `krefHistory` and a
* forward-sorted `syscalls` list representing the trace.
*
* @param {import('better-sqlite3').Statement<[kpid: string]>} getSyscallsForKref
* @param {import('@agoric/swing-store').WrappedStatement} getSyscallsForKref
* @param {string} kref
* @returns {SyscallTraceFailure | SyscallTraceSuccess}
*/
Expand Down Expand Up @@ -290,7 +290,7 @@ const methargsZoeSeatMethodShape = harden([
* Searches for and decodes the syscall.send whose result corresponds with a provided kpid,
* or explains failure to do so.
*
* @param {import('better-sqlite3').Statement<[kpid: string]>} getSyscallsForKref
* @param {import('@agoric/swing-store').WrappedStatement} getSyscallsForKref
* @param {string} kpid
* @returns {{failure: string, kpidSyscalls: unknown[]} | ReturnType<decodeSendSyscall>}
*/
Expand Down Expand Up @@ -338,7 +338,7 @@ const main = rawArgv => {
}

const [dbPath] = args;
const db = sqlite3(/** @type {string} */ (dbPath));
const db = createDatabase(/** @type {string} */ (dbPath));
/** @type {any} */
const getUnsettledPromises = db.prepare(`
SELECT d.kpid, d.decider, s.subscriber
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/misc-tools/ingest-xs-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import fs from 'fs';
import zlib from 'zlib';
import process from 'process';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';

// super-experimental tool to parse an XS heap snapshot file (as
// extracted from kerneldb by extract-snapshot.js) and populate a
Expand All @@ -18,7 +18,7 @@ import sqlite3 from 'better-sqlite3';
// sqlite3 output.sqlite .schema

function makeDB(dbfn) {
const db = sqlite3(dbfn);
const db = createDatabase(dbfn);
db.exec(`PRAGMA journal_mode=WAL`);
// these tables hold the snapshot contents more-or-less verbatim
db.exec(`CREATE TABLE chunk (chunk BLOB)`);
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/misc-tools/replay-transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import { Readable, finished as finishedCallback } from 'stream';
import { performance } from 'perf_hooks';
import { tmpName, dirSync as tmpDirSync } from 'tmp';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';

Check failure on line 17 in packages/SwingSet/misc-tools/replay-transcript.js

View workflow job for this annotation

GitHub Actions / lint-primary

'/home/runner/work/agoric-sdk/agoric-sdk/node_modules/@agoric/swing-store/src/index.js' imported multiple times
import yargsParser from 'yargs-parser';
import { makeMeasureSeconds } from '@agoric/internal';
import { makeWithQueue } from '@agoric/internal/src/queue.js';
import { makeSnapStore } from '@agoric/swing-store';

Check failure on line 21 in packages/SwingSet/misc-tools/replay-transcript.js

View workflow job for this annotation

GitHub Actions / lint-primary

'/home/runner/work/agoric-sdk/agoric-sdk/node_modules/@agoric/swing-store/src/index.js' imported multiple times
import { getLockdownBundle } from '@agoric/xsnap-lockdown';
import { getSupervisorBundle } from '@agoric/swingset-xsnap-supervisor';
import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js';
Expand Down Expand Up @@ -251,7 +251,7 @@
});
cleanupSnapStore = tmpDb.removeCallback;
snapStore = makeSnapStore(
sqlite3(`${tmpDb.name}/snapstore.sqlite`),
createDatabase(`${tmpDb.name}/snapstore.sqlite`),
() => {},
makeSnapStoreIO(),
undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/misc-tools/scan-9039-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import process from 'process';
import fs from 'fs';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import yargsParser from 'yargs-parser';
import '@endo/init/debug.js';

Expand All @@ -31,7 +31,7 @@ const main = rawArgv => {
if (!fs.existsSync(ssDBPath)) {
throw Error(`swingstore DB path (${ssDBPath}) must exist`);
}
const ssDB = sqlite3(/** @type {string} */ (ssDBPath));
const ssDB = createDatabase(/** @type {string} */ (ssDBPath));
let queries = 0;

const sqlGet = ssDB.prepare('SELECT value FROM kvStore WHERE key=?').pluck();
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/misc-tools/vat-map-from-swingstore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
import '@endo/init';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import fs from 'fs';
import process from 'process';

Expand All @@ -27,7 +27,7 @@ assert(
fs.existsSync(swingstoreDBPath),
`missing SQLite file: ${swingstoreDBPath}`,
);
const ssdb = sqlite3(swingstoreDBPath);
const ssdb = createDatabase(swingstoreDBPath);

const sqlGet = ssdb
.prepare('SELECT value FROM kvStore WHERE key = ?')
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"lint:eslint": "yarn run -T eslint ."
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.13",
"@types/microtime": "^2.1.0",
"@types/tmp": "^0.2.0",
"@types/yargs-parser": "^21.0.0",
Expand Down Expand Up @@ -56,9 +55,9 @@
"@endo/ses-ava": "^1.3.2",
"@endo/stream": "^1.2.13",
"@endo/zip": "^1.0.11",
"@photostructure/sqlite": "^0.0.1",
"ansi-styles": "^6.2.1",
"anylogger": "^0.21.0",
"better-sqlite3": "^10.1.0",
"import-meta-resolve": "^4.1.0",
"microtime": "^3.1.0",
"semver": "^6.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import { test } from '../../../tools/prepare-test-env-ava.js';

import tmp from 'tmp';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';

Check failure on line 6 in packages/SwingSet/test/vat-admin/slow-termination/slow-termination.test.js

View workflow job for this annotation

GitHub Actions / lint-primary

'/home/runner/work/agoric-sdk/agoric-sdk/node_modules/@agoric/swing-store/src/index.js' imported multiple times
import path from 'path';

import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
import { kser } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';

Check failure on line 11 in packages/SwingSet/test/vat-admin/slow-termination/slow-termination.test.js

View workflow job for this annotation

GitHub Actions / lint-primary

'/home/runner/work/agoric-sdk/agoric-sdk/node_modules/@agoric/swing-store/src/index.js' imported multiple times

import { buildVatController, buildKernelBundles } from '../../../src/index.js';
import { enumeratePrefixedKeys } from '../../../src/kernel/state/storageHelper.js';
Expand Down Expand Up @@ -86,7 +86,7 @@
const { commit } = ss.hostStorage;
const { kvStore } = kernelStorage;
// look directly at DB to confirm changes
const db = sqlite3(path.join(dbDir, 'swingstore.sqlite'));
const db = createDatabase(path.join(dbDir, 'swingstore.sqlite'));

const controller = await buildVatController(config, [], {
...t.context.data,
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/vat-warehouse/preload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { test } from '../../tools/prepare-test-env-ava.js';

// import * as proc from 'child_process';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';

Check failure on line 6 in packages/SwingSet/test/vat-warehouse/preload.test.js

View workflow job for this annotation

GitHub Actions / lint-primary

'/home/runner/work/agoric-sdk/agoric-sdk/node_modules/@agoric/swing-store/src/index.js' imported multiple times
import {
initSwingStore,
makeSnapStore,
Expand Down Expand Up @@ -35,7 +35,7 @@
};
const argv = [];

const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const snapStore = makeSnapStore(db, () => {}, makeSnapStoreIO());
const kernelStorage = { ...initSwingStore().kernelStorage, snapStore };

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/vat-warehouse/reload-snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import {
initSwingStore,
makeSnapStore,
Expand Down Expand Up @@ -32,7 +32,7 @@ const vatReload = async (t, restartWorkerOnSnapshot, vatConfig) => {
},
};

const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const snapStore = makeSnapStore(db, () => {}, makeSnapStoreIO());
const kernelStorage = { ...initSwingStore().kernelStorage, snapStore };

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/xsnap-metering.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { test } from '../tools/prepare-test-env-ava.js';
import { spawn } from 'child_process';
import fs from 'fs';
import { tmpName } from 'tmp';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import { makePromiseKit } from '@endo/promise-kit';
import { makeSnapStore, makeSnapStoreIO } from '@agoric/swing-store';

Expand Down Expand Up @@ -49,7 +49,7 @@ function checkMetered(t, args, metered) {
}

async function doTest(t, metered) {
const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const store = makeSnapStore(db, () => {}, makeSnapStoreIO());

const { p: p1, startXSnap: start1 } = make(store);
Expand Down
12 changes: 6 additions & 6 deletions packages/SwingSet/test/xsnap-store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { spawn } from 'child_process';
import fs from 'fs';
import { tmpName } from 'tmp';
import { type as osType } from 'os';
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import test from 'ava';
import { makeMeasureSeconds } from '@agoric/internal';
import { xsnap } from '@agoric/xsnap';
Expand Down Expand Up @@ -63,7 +63,7 @@ test(`create XS Machine, snapshot (${snapSize.raw} Kb), compress to smaller`, as
const vat = await bootWorker('xs1', async m => m, '1 + 1');
t.teardown(() => vat.close());

const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const store = makeSnapStore(db, () => {}, makeMockSnapStoreIO());

const { compressedSize } = await store.saveSnapshot(
Expand All @@ -84,7 +84,7 @@ test('SES bootstrap, save, compress', async t => {
const vat = await bootSESWorker('ses-boot1', async m => m);
t.teardown(() => vat.close());

const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const store = makeSnapStore(db, () => {}, makeMockSnapStoreIO());

await vat.evaluate('globalThis.x = harden({a: 1})');
Expand All @@ -102,7 +102,7 @@ test('SES bootstrap, save, compress', async t => {
});

test('create SES worker, save, restore, resume', async t => {
const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const store = makeSnapStore(db, () => {}, makeMockSnapStoreIO());

const vat0 = await bootSESWorker('ses-boot2', async m => m);
Expand Down Expand Up @@ -140,7 +140,7 @@ test('XS + SES snapshots are long-term deterministic', async t => {
return;
}

const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const store = makeSnapStore(db, () => {}, makeMockSnapStoreIO());

const vat = await bootWorker('xs1', async m => m, '1 + 1');
Expand Down Expand Up @@ -186,7 +186,7 @@ Then commit the changes in .../snapshots/ path.
});

async function makeTestSnapshot() {
const db = sqlite3(':memory:');
const db = createDatabase(':memory:');
const store = makeSnapStore(db, () => {}, makeMockSnapStoreIO());
const vat = await bootWorker('xs1', async m => m, '1 + 1');
const bootScript = await getBootScript();
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
},
"devDependencies": {
"@agoric/kmarshal": "workspace:*",
"@photostructure/sqlite": "^0.0.1",
"ava": "^5.3.0",
"better-sqlite3": "^10.1.0",
"c8": "^10.1.3",
"execa": "^9.5.2"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/cosmic-swingset/tools/inquisitor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { fileURLToPath } from 'node:url';
import { inspect, parseArgs } from 'node:util';
import { isMainThread } from 'node:worker_threads';
// eslint-disable-next-line import/no-extraneous-dependencies
import sqlite3 from 'better-sqlite3';
import { createDatabase } from '@agoric/swing-store';
import { Fail, b, q } from '@endo/errors';
import { makePromiseKit } from '@endo/promise-kit';
import { objectMap, BridgeId } from '@agoric/internal';
Expand All @@ -63,7 +63,7 @@ import {
import { makeCosmicSwingsetTestKit } from './test-kit.js';

/**
* @import {Database} from 'better-sqlite3';
* @import {WrappedDatabase} from '@agoric/swing-store';
* @import {ManagerType, SwingSetConfig} from '@agoric/swingset-vat';
* @import {KVStore} from '../src/helpers/bufferedStorage.js';
*/
Expand Down Expand Up @@ -91,7 +91,7 @@ const storeExportAPI = ['getExportRecords', 'getArtifactNames'];

/**
* @param {object} opt
* @param {Database} opt.db
* @param {WrappedDatabase} opt.db
* @param {any} opt.EV
*/
export const makeHelpers = ({ db, EV }) => {
Expand Down Expand Up @@ -640,7 +640,7 @@ export const makeSwingStoreOverlay = (dbPath, wrapStore = wrapSubstore) => {
});
},
wrapBundleStore: bundleStore => {
const overlayDB = sqlite3(':memory:');
const overlayDB = createDatabase(':memory:');
const overlay = makeBundleStore(overlayDB, noop, noop);
let modified = false;
const onNewBundle = (operation, key, ...details) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/swing-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
"@endo/check-bundle": "^1.0.17",
"@endo/errors": "^1.2.13",
"@endo/nat": "^5.1.3",
"better-sqlite3": "^10.1.0"
"@photostructure/sqlite": "^0.0.1"
},
"devDependencies": {
"@endo/init": "^1.1.12",
"@endo/promise-kit": "^1.1.13",
"@endo/stream": "^1.2.13",
"@types/better-sqlite3": "^7.6.13",
"ava": "^5.3.0",
"c8": "^10.1.3",
"tmp": "^0.2.1"
Expand Down
Loading
Loading