Skip to content

Commit

Permalink
Add indexer service & make relayer stateless
Browse files Browse the repository at this point in the history
  • Loading branch information
lok52 committed Apr 2, 2024
1 parent a8e71c9 commit b0abe89
Show file tree
Hide file tree
Showing 86 changed files with 1,192 additions and 836 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ zp-relayer/poolTxs.db

*.md
*.yml
**/lib/
**/build/
**/*.json
75 changes: 45 additions & 30 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,62 @@
version: '3.8'

services:
ganache:
image: trufflesuite/ganache-cli
command: >
--deterministic
--gasLimit 20000000
--allowUnlimitedContractSize
--networkId 1337
--chainId 1337
ports:
- 8545:8545
contracts:
image: lok52/zp-contracts:latest
verifier:
image: lok52/verifier:latest
build:
context: ./docker
dockerfile: Dockerfile.verifier
redis:
redis_indexer:
command: [redis-server, --appendonly, 'yes']
image: redis:6.2.6
indexer:
image: ghcr.io/zkbob/zkbob-relayer:${RELAYER_VERSION:-latest}
build:
context: .
dockerfile: docker/Dockerfile.relayer
command: yarn run start:indexer:prod
volumes:
- ./zp-relayer/params:/app/zp-relayer/params/
env_file: ./zp-relayer/indexer.env
environment:
- INDEXER_PORT=80
- COMMON_REDIS_URL=redis_indexer:6379
ports:
- 6379:6379
- 8000:80
depends_on:
- redis_indexer
redis_relayer:
command: [redis-server, --appendonly, 'yes']
image: redis:6.2.6
relayer:
image: ghcr.io/zkbob/zkbob-relayer:${RELAYER_VERSION:-latest}
build:
context: .
dockerfile: docker/Dockerfile.relayer
volumes:
- relayer_tree:/app/tree.db
- relayer_txs:/app/txs.db
- $PARAMS_PATH:/app/zp-relayer/params/
env_file: ./zp-relayer/relayer.env
- ./zp-relayer/params:/app/zp-relayer/params/
env_file: ./zp-relayer/relayer-decentralized.env
environment:
- RELAYER_PORT=80
- RELAYER_PROVER_URL=http://commitment_watcher:80
- COMMON_INDEXER_URL=http://indexer:80
- COMMON_REDIS_URL=redis_relayer:6379
ports:
- 8000:8000
watcher:
- 8001:80
depends_on:
- redis_relayer
redis_prover:
command: [redis-server, --appendonly, 'yes']
image: redis:6.2.6
commitment_watcher:
image: ghcr.io/zkbob/zkbob-relayer:${RELAYER_VERSION:-latest}
build:
context: .
dockerfile: docker/Dockerfile.relayer
command: yarn run start:direct-deposit-watcher:prod
env_file: ./zp-relayer/watcher.env
volumes:
relayer_tree:
relayer_txs:
command: yarn run start:commitment-watcher:prod
volumes:
- ./zp-relayer/params:/app/zp-relayer/params/
env_file: ./zp-relayer/commitment-watcher.env
environment:
- COMMITMENT_WATCHER_PORT=80
- COMMON_INDEXER_URL=http://indexer:80
- COMMON_REDIS_URL=redis_prover:6379
ports:
- 8002:80
depends_on:
- redis_prover
6 changes: 3 additions & 3 deletions docker/Dockerfile.relayer
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM rust:1.69.0-slim-buster as base
FROM rust:1.77.0-slim-buster as base

WORKDIR /app

RUN apt-get update && \
apt-get -y install curl && \
curl -sL https://deb.nodesource.com/setup_18.x | bash && \
curl -sL https://deb.nodesource.com/setup_20.x | bash && \
apt-get -y install nodejs libclang-dev clang && \
npm install -g yarn cargo-cp-artifact

Expand All @@ -29,7 +29,7 @@ RUN yarn build:relayer
RUN yarn install --frozen-lockfile --production


FROM node:18
FROM node:20

ARG RELAYER_REF
ARG RELAYER_SHA
Expand Down
5 changes: 5 additions & 0 deletions zp-memo-parser/memo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type TxData<T extends TxType> = BaseTxData &
(T extends TxType.WITHDRAWAL ? WithdrawTxData : T extends TxType.PERMITTABLE_DEPOSIT ? PermittableDepositTxData : {})

interface BaseTxDataProverV2 {
proxyAddress: Uint8Array
proverAddress: Uint8Array
treeUpdateFee: string
}
Expand Down Expand Up @@ -138,6 +139,9 @@ export function getTxData<T extends TxType>(m: Buffer, txType: Option<T>): TxDat
export function getTxDataProverV2<T extends TxType>(m: Buffer, txType: Option<T>): TxDataProverV2<T> {
let offset = 0

const proxyAddress = getAddress(m, offset)
offset += 20

const proverAddress = getAddress(m, offset)
offset += 20

Expand All @@ -148,6 +152,7 @@ export function getTxDataProverV2<T extends TxType>(m: Buffer, txType: Option<T>
offset += 8

const base = {
proxyAddress,
proverAddress,
transactFee,
treeUpdateFee,
Expand Down
166 changes: 0 additions & 166 deletions zp-relayer/commitment-watcher/init.ts

This file was deleted.

Loading

0 comments on commit b0abe89

Please sign in to comment.