From 087a92b6eaf181b0bfc107b5d3005ce87f97a41a Mon Sep 17 00:00:00 2001 From: Tadeuchi Date: Thu, 26 Oct 2023 14:11:38 +0200 Subject: [PATCH] README update: update mode --- .env.defaults | 2 +- README.md | 30 +++++++++++++++++++++++++----- docker-compose-local.yml | 2 +- package.json | 2 +- src/db/pgRolesAndSchemasSetup.sql | 8 ++++---- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.env.defaults b/.env.defaults index 3ba30798..71b50d63 100644 --- a/.env.defaults +++ b/.env.defaults @@ -5,7 +5,7 @@ WARP_GW_URL='https://gw.warp.cc' # PG config PG_HOST='localhost' -PG_DATABASE='dre-u' +PG_DATABASE='postgres' PG_USER_WARP='warp' PG_USER_WARP_PASSWORD='warp_password' PG_USER_DRE='dre' diff --git a/README.md b/README.md index 398b67cf..47c95ca8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,24 @@ A Delegated Resolution Environment for Warp Contracts. Docs are available [here](https://academy.warp.cc/docs/dre/overview). +## Update mode +DRE can run in two different modes. +Each of them listens on gateways notification and registers new contracts, but upcoming new interactions are handled differently. + +#### Poll +Node fetches interactions directly from gateway in time intervals. +Interaction are grouped and executed sequentially. +This is the default mode. + + +#### Subscription +Node listens on new interactions events and evaluates contracts immediately after every interaction. +This offers a faster contract evaluation and serves the latest contract state + +Update mode can be set up using env config +``UPDATE_MODE='poll'`` or +``UPDATE_MODE='subscription'`` + ## Deployment ### 1. Database @@ -31,8 +49,10 @@ TBA 1. `npm install --force` 2. `npm install pm2 -g` 3. `cp .env.defaults .env` -4. Update `.env` `NODE_JWK_KEY` with your Arweave wallet JWK -5. Update `.env` passwords for your local postgres (only if you changed them!). -6. `pm2 install pm2-logrotate` -7. `pm2 start src/syncer.js` -8. `pm2 start src/listener.js` +4. Update `.env` config file. + 1. Set `NODE_JWK_KEY` with your Arweave wallet JWK + 2. Update `.env` passwords for your local postgres (only if you changed them!). + 3. Optionally you can change the 'UPDATE_MODE'. By default, it is set to poll mode. +5. `pm2 install pm2-logrotate` +6. `pm2 start src/syncer.js` +7. `pm2 start src/listener.js` diff --git a/docker-compose-local.yml b/docker-compose-local.yml index 18d74d3c..6d98385f 100644 --- a/docker-compose-local.yml +++ b/docker-compose-local.yml @@ -14,6 +14,6 @@ services: environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=dre-u + - POSTGRES_DB=postgres ports: - '21726:5432' diff --git a/package.json b/package.json index cdc88142..96509c97 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "generate-arweave-wallet": "node src/tools/generateArweaveWallet.js", "run-bullmq": "docker-compose up -d bullmq", "run-postgres:local": "docker-compose -f ./docker-compose-local.yml up -d postgres", - "db-setup:local": "psql -U postgres -h localhost -p 21726 -d dre-u -f ./src/db/pgRolesAndSchemasSetup.sql", + "db-setup:local": "psql -U postgres -h localhost -p 21726 -d postgres -f ./src/db/pgRolesAndSchemasSetup.sql", "run-docker": "docker-compose up -d", "run-docker:local": "docker-compose -f ./docker-compose-local.yml up -d", "stop-docker": "docker-compose down", diff --git a/src/db/pgRolesAndSchemasSetup.sql b/src/db/pgRolesAndSchemasSetup.sql index 401e7153..cfcbce67 100644 --- a/src/db/pgRolesAndSchemasSetup.sql +++ b/src/db/pgRolesAndSchemasSetup.sql @@ -8,10 +8,10 @@ GRANT dre TO postgres; CREATE SCHEMA IF NOT EXISTS AUTHORIZATION dre; ALTER ROLE dre SET search_path TO dre; -GRANT CONNECT ON DATABASE "dre-u" TO dre; -GRANT CONNECT ON DATABASE "dre-u" TO warp; -GRANT CREATE ON DATABASE "dre-u" TO warp; -GRANT CREATE ON DATABASE "dre-u" TO dre; +GRANT CONNECT ON DATABASE "postgres" TO dre; +GRANT CONNECT ON DATABASE "postgres" TO warp; +GRANT CREATE ON DATABASE "postgres" TO warp; +GRANT CREATE ON DATABASE "postgres" TO dre; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA dre TO dre; GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA dre TO dre;