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

CausalLog CRDT #321

Open
tantaman opened this issue Aug 14, 2023 · 0 comments
Open

CausalLog CRDT #321

tantaman opened this issue Aug 14, 2023 · 0 comments

Comments

@tantaman
Copy link
Collaborator

https://vlcn.io/blog/crdt-substrate outlines how to create a causal log and traverse it so all peers have the same state.

Now that I'm finally implementing #181 today so users can declare CRRs via:

CREATE VIRTUAL TABLE foo USING CLSet

we can start adding more CRDT types to back tables.

E.g.,

CREATE VIRTUAL TABLE foo USING CausalLog
CREATE VIRTUAL TABLE foo USING DeleteWinsSet
CREATE VIRTUAL TABLE foo USING AddWinsSet
...

CausalLog would be a nice way to back tables as it gives us a better audit trail and the user some extra flexibility on merge semantics.

Implementation

We can do it two ways (maybe we even support both).

One way --

CREATE VIRTUAL TABLE todo_schema USING CausalLog (
  id PRIMARY KEY,
  content TEXT,
  complete INT
);

which creates:

  1. the todo table with the desired schema
  2. a companion table to track events about the todo table
CREATE TABLE todo_companion (
  event_id,
  item_id ID_of<todo>,
  event ANY
);

CREATE TABLE todo_event_edges (
  parent_id,
  event_id
);

and a view? or vtab? to do a deterministic traversal of events.

The onus is on the user to create event types and process them to build current state. Given that, maybe we only provide a log structure and nothing about the base item table.

Other way --

We could come up with the events ourselves in a similar way to sqlite.org/undoredo.html

@tantaman tantaman mentioned this issue Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant