Skip to content
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

Write plugin data persistence specification #740

Closed
James-Mart opened this issue Jun 12, 2024 · 0 comments · Fixed by #868
Closed

Write plugin data persistence specification #740

James-Mart opened this issue Jun 12, 2024 · 0 comments · Fixed by #868
Assignees
Labels
Dev Experience Related to the experience of developers documentation Improvements or additions to documentation
Milestone

Comments

@James-Mart
Copy link
Member

James-Mart commented Jun 12, 2024

Task

Write a specification and add it to the mdbook docs for psibase

Specification

Access to database operations

To enable database actions within plugins, a plugin must import database read/write functionality.

Read/write functionality is provided by a system plugin in the clientdata namespace. That plugin provides a high level key/value API for plugins to use that is specific to psibase plugins.

As an MVP implementation, the API will simply provide a get/set implementation such as:

    set      : func(key : string, value : string) -> result<_, error>;
    get      : func(key : string) -> result<string, error>;

Design implications

There is actually no standardized wasi-keyvalue interface (The proposal is still in stage 2 at the time of writing), so any interface we enable today will be subject to future change. This design specifies that plugins should import a custom psibase-plugin-specific API that itself leverages the wasi-keyvalue standard.

Host provided functionality

The clientdata plugin must itself import functionality that allows it to interact with some persistent storage layer.

This host functionality is a browser shim implementation of the wasi-keyvalue API. Technically, any plugin can import this API and use it directly. But using the standard clientdata plugin simplifies the integration (uses standard error types, exposes a more convenient interface).

The wasi-keyvalue implementation currently uses LocalStorage as its data backing, because it is a synchronous interface which is easiest to integrate with wasm.

Persistence

When private user data is written, it is immediately persisted.

Concurrency

All reads/writes are currently synchronous, with no concurrency.

Synchronization across devices

Plugins all run within the domain of the supervisor, which ensures that all plugin data is written-to/read-from a storage backing tied to the supervisor domain. Cloning storage in the supervisor domain between TLDs is a way to synchronize plugin data across devices.

@James-Mart James-Mart self-assigned this Jun 12, 2024
@James-Mart James-Mart changed the title Plugin data persistence Plugin data persistence specification Jun 13, 2024
@James-Mart James-Mart changed the title Plugin data persistence specification Write plugin data persistence specification Sep 3, 2024
@James-Mart James-Mart added documentation Improvements or additions to documentation Dev Experience Related to the experience of developers labels Sep 3, 2024
@James-Mart James-Mart added this to the R2 milestone Sep 3, 2024
@James-Mart James-Mart moved this to In Progress in Psibase Sep 3, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Psibase Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev Experience Related to the experience of developers documentation Improvements or additions to documentation
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant