-
Notifications
You must be signed in to change notification settings - Fork 207
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
refactor swing-store/makeSnapStore #3431
Comments
Between the three of us, we might need to make this change now, rather than later, to support @dckc 's #3505 work. Or at least some subset of it, enough to allow the snapstore to be told to delete snapshots at the right time (just after the host has committed to the new swingset state, and before swingset has a chance to change any vat's state). |
yes, I made a small step in 73573da |
In addition to maintaining a mapping from vatID to snapshotID, vatKeeper maintains a reverse mapping. When the reverse mapping is empty, `snapStore.prepareToDelete()` queues the snapshot for deletion. When the host calls `swingstore.commit()`, swingstore calls `snapStore.commitDeletes()`. fixes #3374 refs #3431 * feat(swing-store-lmdb): host commit() deletes snapshots * feat(snapstore): prepare/commit deletes * feat(swing-store-lmdb): provide snapStore with kvStore, streamStore * chore: move snapStore to swing-store-lmdb package * refactor: factor out makeSnapStoreIO - vatKeeper.saveSnapshot() prepares deletes - removeFromSnapshot() returns consumers.length * test: use tmp directories for snapStore in tests * test(swingset): move c.shutdown to caller of runSteps: runSteps didn't create it; its caller still has a reference * chore(cosmis-swingset): use consolidated snapStore API * chore(solo): use consolidated snapStore API * refactor(swingset): static type for kvStore in vatKeeper - getRequired() asserts that get() does not return undefined - fix addHelpers() return type by declaring arg type - where kvStore.get() is ensured by getKeys() or has(), mark the alternative with assert.fail(). * docs(swingset): mark DB keys excluded from consensus * chore(snapstore): assert hash has no path separators * test(snapstore): robust prepare / commit delete * docs(swingstore): document snapStore commit constraint * test: move xsnap/snapstore integration test to solo to avoid @agoric/xsnap in swing-store-lmdb devDependencies * test(snapstore): re-save between prepare and commit delete plus one more /etc/passwd test
|
What is the Problem Being Solved?
We should refactor the various pieces of the kernel's state management library. The kernel currently needs three kinds of storage:
swing-store-lmdb
)swing-store-lmdb
)makeSnapStore
, code inxsnap
)To build a snapshot store, the caller must provide a whole bunch of filesystem authorities, and merge the result with an object that comes back from the kernel's
provideHostStorage()
function, in a pattern that looks like this:This is repeated in both host applications (chain and solo), as well as several swingset unit tests.
I'd like to see this refactored to remove that code duplication.
I don't know how/if that squares with @dckc 's laudable goal of reducing the authority in the imported snapstore source code (i.e. continuing to avoid an
import fs from 'fs'
in that module, and requiring the caller to do that import instead).Also, we need to rationalize the disparate locations of the source code for these three pieces, and make some decisions about how/if to continue supporting alternate DB tools. E.g. most swingset unit tests (and swingset-using tests in downstream consumer packages like Zoe/ERTP) are content with an in-RAM swingstore, which is easier to use because you don't have to pick a directory for it. The tests that need a snapstore must provide a directory, but those tests would be easier to write if it didn't have to pick one (e.g. keep the snapshots in RAM, and use tempfiles to have a real file on disk for the brief period when
xsnap
needs to read or write. Or make an automatically-deleting tempdir when the swingstore is created, and use it, instead of a named outlives-the-test directory).cc @FUDCo @dckc
The text was updated successfully, but these errors were encountered: