Show case example how to make chat applications like Zulip decentralized with on-chain data.
- Extract chat messages from Zulip and store it on-chain.
- Read on-chain tables, keys and messages.
- Import messages to Zulip.
npm installControl of the whole process is defined with npm scripts in package.json.
The first step is to start Zulip with its dependencies and RNode instances which will store on-chain data. Starting from fresh it will take a few minutes to complete. Check docker-compose logs and web access for more info.
TODO: Read-only RNode is defined in configuration but not currently used. Additional info should be provided how to read exported on-chain data.
npm run start-dockerTo control docker-compose services which includes both docker-compose.yml and docker-compose-zulip.yml this npm script can be used.
# Get logs from all containers
npm run dc -- logs -f
# Get logs only from bootstrap RNode
npm run dc -- logs -f bootZulip: https://localhost:1443/.
RNode: http://localhost:40403/status.
To login to a locally started Zulip instance it's necessary to follow the Zulip procedure and create an organization with an initial account.
This command will print a temporary link to access the initial Zulip configuration. Follow the link, create your account and login to Zulip server.
npm run zulip-gen-org-linkThis step is necessary to execute only once when RChain nodes are started from a fresh state.
Creates a main contract with operations to insert DB data on-chain.
Result of these deploys will produce URI output which must be updated in .env file.
npm run iddb-deployAfter .env file is updated with IDDB_CONTRACT_URI execute command to create a contract for Zulip DB.
npm run myzulipdb-deployUpdate DB_CONTRACT_URI in .env file which is used as part of private channel for insert operations (chain_replica.mjs) and to get read-only channel for read operations (read-db.mjs).
NOTE: Whenever iddb-deploy and myzulipdb-deploy are deployed again the corresponding record in .env file must be updated.
npm startWhen creating a new instance of Zulip, you can import on-chain messages by running these script. It will copy the data from obtained on-chain tables.
npm run fill-zulipdbTODO: At the moment of this change, the function getTables (from on-chain) returns only zerver_message and zerver_usermessage tables, but there are a few more related to zerver_message such as zerver_userprofile. Copying those tables related to zerver_message could be an improvement to what it is done here.
Stop and remove all containers (data stored on disk will not be touched).
npm run dc -- downDelete all data on disk. sudo is needed because RNode uses root user inside the container, so the mounted folder will be owned by root.
sudo rm -R data