Skip to content

Commit

Permalink
fix: CI failures in other packages
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Nov 14, 2022
1 parent a00519b commit 85fd98a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 33 deletions.
14 changes: 5 additions & 9 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 5 additions & 10 deletions packages/solo/src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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() {
Expand Down
16 changes: 8 additions & 8 deletions packages/swing-store/src/swingStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
8 changes: 2 additions & 6 deletions packages/swingset-runner/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -445,7 +441,7 @@ export async function main() {
}
}
const controller = await makeSwingsetController(
hostStorage,
swingStore,
deviceEndowments,
runtimeOptions,
);
Expand Down

0 comments on commit 85fd98a

Please sign in to comment.