Skip to content

Commit

Permalink
refactor!: clean up organization of swing-store
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Aug 24, 2021
1 parent 7bd027a commit 3c7e57b
Show file tree
Hide file tree
Showing 52 changed files with 207 additions and 893 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,8 @@ jobs:
run: cd packages/store && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (swing-store-lmdb)
run: cd packages/swing-store-lmdb && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (swing-store-simple)
run: cd packages/swing-store-simple && yarn test
- name: yarn test (swing-store)
run: cd packages/swing-store && yarn test
env:
ESM_DISABLE_CACHE: true

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"packages/same-structure",
"packages/captp",
"packages/stat-logger",
"packages/swing-store-lmdb",
"packages/swing-store-simple",
"packages/swing-store",
"packages/SwingSet",
"packages/swingset-runner",
"packages/ERTP",
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"@agoric/notifier": "^0.3.28",
"@agoric/promise-kit": "^0.2.25",
"@agoric/store": "^0.6.3",
"@agoric/swing-store-lmdb": "^0.5.11",
"@agoric/swing-store-simple": "^0.4.11",
"@agoric/swing-store": "^0.5.11",
"@agoric/xsnap": "^0.8.2",
"@endo/base64": "^0.2.6",
"@types/tmp": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export async function makeSwingsetController(
* overrideVatManagerOptions?: { consensusMode?: boolean },
* slogFile?: string,
* }} runtimeOptions
* @typedef { import('@agoric/swing-store-simple').KVStore } KVStore
* @typedef { import('@agoric/swing-store').KVStore } KVStore
*/
export async function buildVatController(
config,
Expand Down
15 changes: 5 additions & 10 deletions packages/SwingSet/src/hostStorage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// @ts-check
import { initSimpleSwingStore } from '@agoric/swing-store-simple';
import {
initLMDBSwingStore,
openLMDBSwingStore,
} from '@agoric/swing-store-lmdb';

import { initSwingStore, openSwingStore } from '@agoric/swing-store';
import { assert, details as X } from '@agoric/assert';

/*
Expand Down Expand Up @@ -34,7 +29,7 @@ directly.
*/
export function buildHostDBInMemory(kvStore) {
if (!kvStore) {
kvStore = initSimpleSwingStore().kvStore;
kvStore = initSwingStore(null).kvStore;
}

/**
Expand Down Expand Up @@ -155,12 +150,12 @@ export function provideHostStorage(
let swingStore;
if (kernelStateDBDir) {
if (initialize) {
swingStore = initLMDBSwingStore(kernelStateDBDir);
swingStore = initSwingStore(kernelStateDBDir);
} else {
swingStore = openLMDBSwingStore(kernelStateDBDir);
swingStore = openSwingStore(kernelStateDBDir);
}
} else {
swingStore = initSimpleSwingStore();
swingStore = initSwingStore(null);
}
return {
kvStore: swingStore.kvStore,
Expand Down
10 changes: 5 additions & 5 deletions packages/SwingSet/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
* makeSnapshot?: (ss: SnapStore) => Promise<string>,
* shutdown: () => Promise<void>,
* } } VatManager
* @typedef { ReturnType<typeof import('@agoric/swing-store-lmdb').makeSnapStore> } SnapStore
* @typedef { ReturnType<typeof import('@agoric/swing-store').makeSnapStore> } SnapStore
* @typedef { () => Promise<void> } WaitUntilQuiescent
*/

Expand Down Expand Up @@ -175,10 +175,10 @@
* @typedef {{ bundleName: string} | { bundle: Bundle }} SourceOfBundle
*/
/**
* @typedef { import('@agoric/swing-store-simple').KVStore } KVStore
* @typedef { import('@agoric/swing-store-simple').StreamStore } StreamStore
* @typedef { import('@agoric/swing-store-simple').StreamPosition } StreamPosition
* @typedef { import('@agoric/swing-store-simple').SwingStore } SwingStore
* @typedef { import('@agoric/swing-store').KVStore } KVStore
* @typedef { import('@agoric/swing-store').StreamStore } StreamStore
* @typedef { import('@agoric/swing-store').StreamPosition } StreamPosition
* @typedef { import('@agoric/swing-store').SwingStore } SwingStore
*
* @typedef {{
* kvStore: KVStore,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-activityhash-vs-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { getAllState, setAllState } from '@agoric/swing-store-simple';
import { getAllState, setAllState } from '@agoric/swing-store';
import { provideHostStorage } from '../src/hostStorage.js';
import { initializeSwingset, makeSwingsetController } from '../src/index.js';
import { capargs } from './util.js';
Expand Down
6 changes: 3 additions & 3 deletions packages/SwingSet/test/test-clist.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { initSimpleSwingStore } from '@agoric/swing-store-simple';
import { initSwingStore } from '@agoric/swing-store';
import { createSHA256 } from '../src/hasher.js';
import { makeDummySlogger } from '../src/kernel/slogger.js';
import makeKernelKeeper from '../src/kernel/state/kernelKeeper.js';

test(`clist reachability`, async t => {
const slog = makeDummySlogger({});
const hostStorage = initSimpleSwingStore();
const hostStorage = initSwingStore(null);
const kk = makeKernelKeeper(hostStorage, slog, createSHA256);
const s = kk.kvStore;
kk.createStartingKernelState('local');
Expand Down Expand Up @@ -93,7 +93,7 @@ test(`clist reachability`, async t => {

test('getImporters', async t => {
const slog = makeDummySlogger({});
const hostStorage = initSimpleSwingStore();
const hostStorage = initSwingStore(null);
const kk = makeKernelKeeper(hostStorage, slog, createSHA256);

kk.createStartingKernelState('local');
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '../tools/prepare-test-env-ava.js';

import bundleSource from '@agoric/bundle-source';
import { getAllState } from '@agoric/swing-store-simple';
import { getAllState } from '@agoric/swing-store';
import { provideHostStorage } from '../src/hostStorage.js';

import {
Expand Down
18 changes: 7 additions & 11 deletions packages/SwingSet/test/test-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import { test } from '../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { createHash } from 'crypto';
import {
initSimpleSwingStore,
getAllState,
setAllState,
} from '@agoric/swing-store-simple';
import { initSwingStore, getAllState, setAllState } from '@agoric/swing-store';
import { createSHA256 } from '../src/hasher.js';
import { buildHostDBInMemory } from '../src/hostStorage.js';
import { buildBlockBuffer } from '../src/blockBuffer.js';
Expand Down Expand Up @@ -72,12 +68,12 @@ function testStorage(t, s, getState, commit) {
}

test('storageInMemory', t => {
const store = initSimpleSwingStore();
const store = initSwingStore(null);
testStorage(t, store.kvStore, () => getAllState(store).kvStuff, null);
});

function buildHostDBAndGetState() {
const store = initSimpleSwingStore();
const store = initSwingStore(null);
const hostDB = buildHostDBInMemory(store.kvStore);
return { hostDB, getState: () => getAllState(store).kvStuff };
}
Expand Down Expand Up @@ -123,7 +119,7 @@ test('blockBuffer fulfills storage API', t => {
});

test('crankBuffer fulfills storage API', t => {
const store = initSimpleSwingStore();
const store = initSwingStore(null);
const { crankBuffer, commitCrank } = buildCrankBuffer(
store.kvStore,
createSHA256,
Expand Down Expand Up @@ -188,7 +184,7 @@ test('crankBuffer can abortCrank', t => {
});

test('storage helpers', t => {
const store = initSimpleSwingStore();
const store = initSwingStore(null);
const s = addHelpers(store.kvStore);

s.set('foo.0', 'f0');
Expand Down Expand Up @@ -238,12 +234,12 @@ test('storage helpers', t => {
});

function buildKeeperStorageInMemory() {
const store = initSimpleSwingStore();
const store = initSwingStore(null);
return { getState: () => getAllState(store).kvStuff, ...store };
}

function duplicateKeeper(getState) {
const store = initSimpleSwingStore();
const store = initSwingStore(null);
setAllState(store, { kvStuff: getState(), streamStuff: new Map() });
return makeKernelKeeper(store, null, createSHA256);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-transcript-light.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { getAllState, setAllState } from '@agoric/swing-store-simple';
import { getAllState, setAllState } from '@agoric/swing-store';

import { provideHostStorage } from '../src/hostStorage.js';
import { buildVatController, loadBasedir } from '../src/index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-transcript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { getAllState, setAllState } from '@agoric/swing-store-simple';
import { getAllState, setAllState } from '@agoric/swing-store';

// import fs from 'fs';
import { provideHostStorage } from '../src/hostStorage.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line import/order
import { test } from '../../../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { getAllState, setAllState } from '@agoric/swing-store-simple';
import { getAllState, setAllState } from '@agoric/swing-store';
import { provideHostStorage } from '../../../src/hostStorage.js';

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/vat-admin/test-replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '../../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import bundleSource from '@agoric/bundle-source';
import { getAllState, setAllState } from '@agoric/swing-store-simple';
import { getAllState, setAllState } from '@agoric/swing-store';
import { provideHostStorage } from '../../src/hostStorage.js';
import { buildKernelBundles, buildVatController } from '../../src/index.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '../../tools/prepare-test-env-ava.js';

import tmp from 'tmp';
import { makeSnapStore, makeSnapStoreIO } from '@agoric/swing-store-lmdb';
import { makeSnapStore, makeSnapStoreIO } from '@agoric/swing-store';
import { provideHostStorage } from '../../src/hostStorage.js';
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
import { capargs } from '../util.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/vat-warehouse/test-warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { test } from '../../tools/prepare-test-env-ava.js';
import fs from 'fs';
import tmp from 'tmp';
import { initLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { initSwingStore } from '@agoric/swing-store';
import { loadBasedir, buildVatController } from '../../src/index.js';
import { makeLRU } from '../../src/kernel/vatManager/vat-warehouse.js';

Expand Down Expand Up @@ -124,7 +124,7 @@ function unusedSnapshotsOnDisk(kvStore, snapstorePath) {
test('snapshot after deliveries', async t => {
const swingStorePath = tmp.dirSync({ unsafeCleanup: true }).name;

const { kvStore, streamStore, commit } = initLMDBSwingStore(swingStorePath);
const { kvStore, streamStore, commit } = initSwingStore(swingStorePath);
const hostStorage = { kvStore, streamStore };
const c = await makeController('xs-worker', {
hostStorage,
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/tools/db-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@agoric/install-ses';
import process from 'process';
import { openLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { openSwingStore } from '@agoric/swing-store';

const log = console.log;

Expand Down Expand Up @@ -47,7 +47,7 @@ function run() {
const stateDBDir = argv.shift();
const key = argv.shift();

const { kvStore, commit } = openLMDBSwingStore(stateDBDir);
const { kvStore, commit } = openSwingStore(stateDBDir);

if (range) {
for (const k of kvStore.getKeys(`${key}.`, `${key}/`)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/tools/db-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@agoric/install-ses';
import process from 'process';
import { openLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { openSwingStore } from '@agoric/swing-store';

const log = console.log;

Expand Down Expand Up @@ -58,7 +58,7 @@ function run() {
const stateDBDir = argv.shift();
const key = argv.shift();

const { kvStore } = openLMDBSwingStore(stateDBDir);
const { kvStore } = openSwingStore(stateDBDir);

function pkv(k) {
const value = kvStore.get(k);
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/tools/db-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@agoric/install-ses';
import process from 'process';
import { openLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { openSwingStore } from '@agoric/swing-store';

const log = console.log;

Expand Down Expand Up @@ -33,7 +33,7 @@ function run() {
const key = argv.shift();
const value = argv.shift();

const { kvStore, commit } = openLMDBSwingStore(stateDBDir);
const { kvStore, commit } = openSwingStore(stateDBDir);

kvStore.set(key, value);
commit();
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/tools/rekernelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import path from 'path';
import process from 'process';

import bundleSource from '@agoric/bundle-source';
import { openLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { openSwingStore } from '@agoric/swing-store';

function fail(message) {
console.error(message);
Expand Down Expand Up @@ -56,7 +56,7 @@ async function main() {
fail(`can't find a database at ${dbDir}`);
}

const swingStore = openLMDBSwingStore(kernelStateDBDir);
const swingStore = openSwingStore(kernelStateDBDir);
const kvStore = swingStore.kvStore;
assert(kvStore.get('initialized'), 'kernel store not initialized');

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/tools/replace-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@agoric/install-ses';
import process from 'process';
import { openLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { openSwingStore } from '@agoric/swing-store';
import bundleSource from '@agoric/bundle-source';

const log = console.log;
Expand Down Expand Up @@ -35,7 +35,7 @@ async function run() {
const stateDBDir = argv.shift();
const srcPath = argv.shift();

const { kvStore, commit } = openLMDBSwingStore(stateDBDir);
const { kvStore, commit } = openSwingStore(stateDBDir);
log(`will use ${srcPath} in ${stateDBDir} for ${bundleName}`);

if (bundleName === 'kernel') {
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 @@ -32,7 +32,7 @@
"@agoric/import-bundle": "^0.2.28",
"@agoric/install-ses": "^0.5.25",
"@agoric/store": "^0.6.3",
"@agoric/swing-store-lmdb": "^0.5.11",
"@agoric/swing-store": "^0.5.11",
"@agoric/swingset-vat": "^0.21.3",
"@agoric/vats": "^0.3.1",
"@agoric/xsnap": "^0.8.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
loadSwingsetConfigFile,
} from '@agoric/swingset-vat';
import { assert, details as X } from '@agoric/assert';
import { openLMDBSwingStore } from '@agoric/swing-store-lmdb';
import { openSwingStore } from '@agoric/swing-store';
import {
DEFAULT_METER_PROVIDER,
exportKernelStats,
Expand Down Expand Up @@ -137,7 +137,7 @@ export async function launch(
) {
console.info('Launching SwingSet kernel');

const { kvStore, streamStore, snapStore, commit } = openLMDBSwingStore(
const { kvStore, streamStore, snapStore, commit } = openSwingStore(
kernelStateDBDir,
);
const hostStorage = {
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@agoric/promise-kit": "^0.2.25",
"@agoric/spawner": "^0.4.28",
"@agoric/store": "^0.6.3",
"@agoric/swing-store-lmdb": "^0.5.11",
"@agoric/swing-store": "^0.5.11",
"@agoric/swingset-vat": "^0.21.3",
"@agoric/vats": "^0.3.1",
"@agoric/xsnap": "^0.8.2",
Expand Down
Loading

0 comments on commit 3c7e57b

Please sign in to comment.