Skip to content

Commit

Permalink
Merge remote-tracking branch 'forked/feat/builder' into feat/generic-…
Browse files Browse the repository at this point in the history
…relayer
  • Loading branch information
SoraSuegami committed Nov 30, 2024
2 parents e8e6b52 + d47a108 commit de6ba5b
Show file tree
Hide file tree
Showing 17 changed files with 272 additions and 348 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SMTP.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM rust:latest
WORKDIR /app

# Clone the GitHub repository
RUN git clone https://github.com/zkemail/relayer-smtp.git
RUN git clone https://github.com/zkfriendly/relayer-smtp.git

# Change to the directory of the cloned repository
WORKDIR /app/relayer-smtp
Expand Down
62 changes: 62 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Docker Compose configuration for local development environment
# This setup provides a playground environment for developing and testing the relayer
# It includes:
# - A PostgreSQL database for storing relayer data
# - The relayer service built from local source code
version: '3.8'

services:
db:
image: postgres:15
environment:
POSTGRES_USER: relayer
POSTGRES_PASSWORD: relayer_password
POSTGRES_DB: relayer
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U relayer" ]
interval: 5s
timeout: 5s
retries: 5

smtp:
build:
context: .
dockerfile: SMTP.Dockerfile
environment:
- SERVER_HOST=${SMTP_INTERNAL_SERVER_HOST}
- SERVER_PORT=${SMTP_INTERNAL_SERVER_PORT}
- SMTP_DOMAIN_NAME=${SMTP_DOMAIN_NAME}
- SMTP_LOGIN_ID=${SMTP_LOGIN_ID}
- SMTP_LOGIN_PASSWORD=${SMTP_LOGIN_PASSWORD}
- MESSAGE_ID_DOMAIN=${SMTP_MESSAGE_ID_DOMAIN}
- JSON_LOGGER=${SMPT_JSON_LOGGER}
ports:
- "${SMTP_PORT}:${SMTP_INTERNAL_SERVER_PORT}"
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:${SMTP_INTERNAL_SERVER_PORT}/api/ping" ]
interval: 1m30s
timeout: 30s
retries: 5
start_period: 30s

imap:
build:
context: .
dockerfile: IMAP.Dockerfile
environment:
- RELAYER_ENDPOINT=http://host.docker.internal:8000/api/receiveEmail
- IMAP_LOGIN_ID=${IMAP_LOGIN_ID}
- IMAP_LOGIN_PASSWORD=${IMAP_LOGIN_PASSWORD}
- IMAP_DOMAIN_NAME=${IMAP_DOMAIN_NAME}
- IMAP_PORT=${IMAP_PORT}
- AUTH_TYPE=${IMAP_AUTH_TYPE}
- JSON_LOGGER=${IMAP_JSON_LOGGER}
extra_hosts:
- "host.docker.internal:host-gateway"

volumes:
postgres_data:

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

2 changes: 2 additions & 0 deletions packages/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ sqlx = { version = "0.8.2", features = [
"uuid",
"time",
"chrono",
"bigdecimal",
] }
bigdecimal = "0.3.1"
tokio = { version = "1.40.0", features = ["full"] }
tower-http = { version = "0.6.1", features = ["cors"] }
relayer-utils = { git = "https://github.com/zkemail/relayer-utils.git", branch = "main" }
Expand Down
32 changes: 32 additions & 0 deletions packages/relayer/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# Generic Relayer

## Build

make sure to build the contracts before building the relayer

```
cd ../contracts
yarn && yarn build
```

cd back into the relayer and build it

```
cargo build
```

## Setup the local development environment

cd into the root directory and run

```
docker compose up --build
```

This will build the docker images for the node, bundler, scanner, smtp, and imap services.

## Applying the migrations

```
cd packages/relayer
DATABASE_URL=postgres://relayer:relayer_password@localhost:5432/relayer sqlx migrate run
```
16 changes: 10 additions & 6 deletions packages/relayer/config.example.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"port": 8000,
"databaseUrl": "postgres://test@localhost:5432/relayer",
"smtpUrl": "http://localhost:3000",
"databaseUrl": "postgres://relayer:relayer_password@db:5432/relayer",
"smtpUrl": "http://smtp_server_1:3000",
"proverUrl": "https://zkemail--email-auth-prover-v1-5-4-flask-app.modal.run",
"alchemyApiKey": "",
"path": {
Expand All @@ -18,15 +18,19 @@
"privateKey": "",
"rpcUrl": "https://sepolia.base.org",
"explorerUrl": "https://sepolia.basescan.org",
"chainId": 84532,
"alchemyName": "base-sepolia"
"chainId": 84532
},
"sepolia": {
"privateKey": "",
"rpcUrl": "https://rpc.sepolia.org",
"explorerUrl": "https://sepolia.etherscan.io",
"chainId": 11155111,
"alchemyName": "eth-sepolia"
"chainId": 11155111
},
"anvil": {
"privateKey": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"rpcUrl": "node:8545",
"explorerUrl": "http://scanner:3001/tx/",
"chainId": 1337
}
},
"jsonLogger": false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS email_auth_messages;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE email_auth_messages (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
request_id TEXT NOT NULL,
response JSONB NOT NULL
);

CREATE INDEX idx_email_auth_messages_request_id ON email_auth_messages(request_id);
Loading

0 comments on commit de6ba5b

Please sign in to comment.