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

distributed zulip store: restore zulip from on-chain mirror #10

Open
2 of 6 tasks
dckc opened this issue Jun 17, 2020 · 5 comments
Open
2 of 6 tasks

distributed zulip store: restore zulip from on-chain mirror #10

dckc opened this issue Jun 17, 2020 · 5 comments
Assignees

Comments

@dckc
Copy link

dckc commented Jun 17, 2020

@leithaus asked if the on-chain mirror is sufficient to stand up another zulip server with the same history, ready to continue.

This restore feature depends on getting the mirror / backup part to be reliable as well:

@dckc
Copy link
Author

dckc commented Jun 17, 2020

@leithaus w/ @steverosstalbot are taking the ball

critical for the goal of decentralizing the chat

@dckc dckc changed the title restore zulip from on-chain mirror distributed zulip store: restore zulip from on-chain mirror Jun 27, 2020
@dckc
Copy link
Author

dckc commented Jun 27, 2020

When asked what he might like to see, @leithaus said taking one zulip service with its store on rchain, and then standing up a new zulip instance and backing it up from rchain would be a cool end-to-end demo of distributed storage for a chat service.

@dckc
Copy link
Author

dckc commented Jul 11, 2020

GSJ writes:

Next time we meet, talk about what needs to be done to recover Zulip from rchain?

As we discussed, chain_replica.js adds a postgres trigger to each table for op=INSERT, UPDATE, and DELETE and when the trigger fires, it deploys something of the form db!(${lit(op)}, ${lit(table_name)}, ${lit(OLD)}, ${lit(NEW)}, Nil)

where OLD and NEW are the contents of the record before and after the operation. There is no OLD in the op=INSERT case (nor NEW in the DELETE case), so we use Nil in that case. An example from the README is:

new deployerId(`rho:rchain:deployerId`) in {
    for(db <<- @{[*deployerId, "zulip_iddb3"]}) {
        db!("INSERT", "zerver_reaction", Nil,
        {"id":11,"user_profile_id":8,"message_id":59,
         "emoji_name":"heart","emoji_code":"2764",
         "reaction_type":"unicode_emoji"}, Nil)
    }
  }

To restore Zulip from rchain:

  1. look up the db
  2. get the set of tables
  3. for each table
    1. get the set of keys
    2. for each key
      1. get the contents of the record at this key in this table
      2. Insert it into postgres
        • perhaps write it to a file in JSON or CSV format and then load into postgres in batch in a separate step

Details / limitations:

  1. myzulipdb.rho should share a read-only facet in the registry (#32).
    • work-around: if you have the deployer private key, you can find the db at @{[*deployerId, "zulip_iddb3"]}
    • "zulip_iddb3" should probably be parameterized
  2. iddb.rho seems to be missing a "get tables" method. Oops (also part of iddb read-only facet #9).
  3. we do have contract self(@"keys", @table_name /\ String, return).
    • The read-only facet should have a "get record" method too (#32).
    • work-around: if you have the closely-held db, the contents of each record is stored at @{[*db, table_name, key]}, so you can get it (using peek).

@dckc
Copy link
Author

dckc commented Jul 26, 2020 via email

@dckc dckc removed their assignment Sep 6, 2020
@dckc
Copy link
Author

dckc commented Sep 15, 2020

This is now nice-to-have

@jimscarver jimscarver transferred this issue from rchain-community/rvote Oct 3, 2020
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

2 participants