Skip to content

Commit

Permalink
README update: update mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadeuchi committed Oct 26, 2023
1 parent 39960c0 commit 087a92b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
2 changes: 1 addition & 1 deletion docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ services:
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=dre-u
- POSTGRES_DB=postgres
ports:
- '21726:5432'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/db/pgRolesAndSchemasSetup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 087a92b

Please sign in to comment.