Skip to content

WordlCoin identity Relayer designed to fetch signatures for identity transfers and after submit transactions with them to the EVM chain

License

Notifications You must be signed in to change notification settings

rarimo/worldcoin-relayer-svc

 
 

Repository files navigation

identity-relayer-svc

License: MIT

The Relayer service as a part of Rarimo cross-chain system designed to finalize transferring flow by submitting final transaction to the target chain.

The goal of WorldCoin identity relayer is to observe and fetch information about new signatures for WORLDCOIN_IDENTITY_TRANSFER operations and after submit the state transit transactions to configured EVM chain by request.


Build

You can use the image from GitHub registry or build the executable by yourself.

Build command:

go build .

Also, you can use the Dockerfile inside the repository.


Configuration

Service configuration consists of two parts:

Environment

export KV_VIPER_FILE=/config.yaml

Config file

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
  enable_tls: false

evm:
  chains:
    - name: "Ethereum"
      ## 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

Use the relayer-svc migrate up && relayer-svc run all command to perform database migrations and run the service.

Explore the simple docker-compose file to run described services:

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:

Using service

  1. Execute the POST /integrations/relayer/state/relay request with the following body to perform state publishing:
{
  "chain": "The name of chain submit to according to the service configuration",
  "hash": "The state hash (the same as on state contract) in 0x... hex format",
  "waitConfirm": true
}

"waitConfirm": true - indicates if request should wait until transaction will be included into the block. Default - false.

The response will be:

  • Code 200, successful relay, tx hash in body.
  • Code 404, state is not transferred yet, wait a little and repeat request.
  • Code 400, state has be relayed before.

About

WordlCoin identity Relayer designed to fetch signatures for identity transfers and after submit transactions with them to the EVM chain

Resources

License

Stars

Watchers

Forks

Languages

  • Smarty 71.1%
  • Go 26.6%
  • Shell 1.9%
  • Dockerfile 0.4%