Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Turn local JavaScript State into KVStore Protocol Messages Outside Realm #57

Closed
wants to merge 32 commits into from

Conversation

katelynsills
Copy link
Contributor

Description

This PR turns the kernel state (including device state and vat state "owned" by the kernel, and not including vat objects in general) into messages that can be sent outside of the SwingSet.

Kernel state is currently all in local, non-persistent JavaScript objects. This PR creates a KVStore abstraction that allows access to the kernel state to be attenuated and passed to sub-portions of the code, such as Vat managers and devices. A KVStore has get, set, has, keys, values, and a few other methods, and provides a clear interface to accessing the state that should be able to withstand the actual implementation changing underneath. vatState and kernelState have been separated into the KVStore, which is passed in, and a Keeper, which is the only way to be able to access the KVStore. The keeper should not have any other access or state within it, and should be able to be wrapped around the KVstore at various points (especially attenuation points, e.g. getting a vat sub-kvstore and wrapping a vatKeeper around it) without it being a problem.

Right now, the gets and sets etc that happen within the inner Realm turn into stringified messages that are sent out, through controller.js. These stringified messages can eventually be sent elsewhere, but for now, the receiving end is JS state.

Currently, we still use writing JSON to disk as our persistence, but we should be able to do significantly better and get rid of that entirely.

Tests

Because this is not a new feature, these changes need to be tested against the current tests - npm test

Instead of a state entirely held in JS objects, move to get/set/has/delete on a kvstore held outside. May still need some "ephemeral" JS state for vat managers etc.
Transcript is loaded correctly (I think), but there seems to be a superficial difference in the dumps
@katelynsills katelynsills requested a review from warner May 28, 2019 13:30
Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.. landing now (rebasing to current trunk first)

@warner warner closed this in 3d55729 May 29, 2019
@warner warner deleted the kvstore-pattern branch May 29, 2019 00:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants