-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added guide for setting up World ID State Replication (#9)
* Added the first version of world id state replication setup guide * Corrected the suggested changes and refactored document * Added todo comment * Proofreading * removed confusing comment --------- Co-authored-by: Ihor Diachenko <[email protected]>
- Loading branch information
1 parent
28563aa
commit 6153271
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# Setting Up Cross-Chain Identity State Replication for World ID | ||
|
||
In this guide, we'll set up the cross-chain identity state replication for World ID. It enables the usage of World ID zero-knowledge proofs on any chain supported by Rarimo. | ||
|
||
## Pre-Requisites | ||
|
||
- [Postgres DB 13+](https://www.postgresql.org/download/) instance for the relayer service; | ||
- [Docker](https://docs.docker.com/engine/install/) and [docker-compose](https://docs.docker.com/compose/install/) (optional) | ||
|
||
## Setting Up Relayer | ||
|
||
The Relayer service is responsible for replicating the World ID state on demand. It exposes a REST endpoint for the DApps that performs the state replication to the target chain. | ||
|
||
### Build | ||
|
||
You can pull the pre-build docker image: | ||
|
||
```sh | ||
docker pull ghcr.io/rarimo/worldcoin-relayer-svc:v0.1.0 | ||
``` | ||
|
||
Or clone the [worldcoin-relayer-svc repository](https://github.com/rarimo/worldcoin-relayer-svc) and build it from the source: | ||
|
||
```sh | ||
git clone [email protected]:rarimo/worldcoin-relayer-svc.git | ||
|
||
CGO_ENABLED=1 go build . | ||
``` | ||
|
||
## Configuration | ||
|
||
Service configuration consists of two parts: | ||
|
||
### Environment | ||
|
||
```shell | ||
export KV_VIPER_FILE=/config.yaml | ||
``` | ||
|
||
### Config file | ||
<!-- TODO: add a real contract_address in the config (evm -> chains section) --> | ||
```yaml | ||
log: | ||
disable_sentry: true | ||
level: debug | ||
|
||
# The port to run on | ||
listener: | ||
addr: :8000 | ||
|
||
# PostgreSQL DB connect | ||
db: | ||
url: "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" | ||
|
||
# Rarimo core RPCs | ||
core: | ||
addr: tcp://validator:26657 | ||
|
||
cosmos: | ||
addr: validator:9090 | ||
|
||
evm: | ||
chains: | ||
- name: "Avalanche" | ||
## Address of the modified state contract on target chain | ||
contract_address: "" | ||
## Private key HEX (without leading 0x) that will pay the tx fee | ||
submitter_private_key: "" | ||
## RPC address. Example https://mainnet.infura.io/v3/11111 | ||
rpc: | ||
## Target chain id | ||
chain_id: 1 | ||
|
||
relay: | ||
# Flag the indicates should service iterate over all existing transfer operation and fill the database | ||
catchup_disabled: true | ||
``` | ||
|
||
---- | ||
|
||
## Run | ||
|
||
### Binary Built From Source | ||
|
||
```sh | ||
# apply DB migrations and run the service | ||
./relayer-svc migrate up && ./relayer-svc run all | ||
``` | ||
|
||
### Using `docker-compose` | ||
|
||
1. Put the config at `./config.yaml` | ||
1. Create `./docker-compose.yml`: | ||
```yaml | ||
version: "3.7" | ||
|
||
services: | ||
relayer-db: | ||
image: postgres:13 | ||
restart: unless-stopped | ||
environment: | ||
- POSTGRES_USER=relayer | ||
- POSTGRES_PASSWORD=relayer | ||
- POSTGRES_DB=relayer | ||
- PGDATA=/pgdata | ||
volumes: | ||
- relayer-data:/pgdata | ||
|
||
relayer: | ||
image: path/to/image:hash | ||
restart: on-failure | ||
ports: | ||
- "8000:8000" | ||
depends_on: | ||
- relayer-db | ||
volumes: | ||
- ./config/relayer.yaml:/config.yaml | ||
environment: | ||
- KV_VIPER_FILE=/config.yaml | ||
entrypoint: sh -c "relayer-svc migrate up && relayer-svc run all" | ||
volumes: | ||
relayer-data: | ||
``` | ||
1. Run the service: | ||
```sh | ||
docker-compose up | ||
``` | ||
|
||
## Using Service | ||
|
||
Execute the POST `/integrations/relayer/state/relay` request with the following body to fetch state publishing: | ||
```json | ||
{ | ||
"chain": "Avalanche", | ||
"hash": "0x1851e2c82ba946e9ba978a40571e4c1294a282d24912ff26496106445299f099", | ||
"waitConfirm": true | ||
} | ||
``` | ||
`"waitConfirm": true` - indicates if request should wait until transaction will be included into the block. Default - `false`. | ||
|
||
The response will be: | ||
|
||
- `200` – successful relay, tx hash in the response body; | ||
- `404` – the state wasn't ingested by Rarimo Core yet; wait a little and repeat the request; | ||
- `400` – the state has been relayed before; <!-- TODO: fix me --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters