-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add relayer e2e ci and relayer service optimizations #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6d8d0fc
feat: fix stellar routing issues
JoE11-y 849a41e
feat: add backend relayer e2e ci
JoE11-y 00632da
chore: fix cis
JoE11-y 5d2d9e3
chore: fix raised issues
JoE11-y db52c84
chore: fix ci
JoE11-y c9f198c
chore: fix ci build issue
JoE11-y 16cc190
chore: fix ci build issue
JoE11-y eb19efa
chore: fix bad test url in scripts
JoE11-y fa5c3eb
chore: fix api req body mismatch
JoE11-y 6054050
chore: fix fund issue and optimizations
JoE11-y a968c00
chore: fix env setup issue
JoE11-y f39c571
chore: add more observability
JoE11-y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,155 @@ | ||
| name: Backend Relayer E2E | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "apps/backend-relayer/**" | ||
| - "contracts/**" | ||
| - "proof_circuits/**" | ||
| - "scripts/**" | ||
| - "packages/**" | ||
| - "package.json" | ||
| - "pnpm-workspace.yaml" | ||
| - "pnpm-lock.yaml" | ||
| - ".github/workflows/backend-relayer-e2e.yml" | ||
| pull_request: | ||
| paths: | ||
| - "apps/backend-relayer/**" | ||
| - "contracts/**" | ||
| - "proof_circuits/**" | ||
| - "scripts/**" | ||
| - "packages/**" | ||
| - "package.json" | ||
| - "pnpm-workspace.yaml" | ||
| - "pnpm-lock.yaml" | ||
| - ".github/workflows/backend-relayer-e2e.yml" | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| SNAPSHOT_PATH: ${{ github.workspace }}/scripts/relayer-e2e/deployed.json | ||
| COMPOSE_FILE: apps/backend-relayer/docker-compose.e2e.yaml | ||
| COMPOSE_PROJECT_NAME: relayer-e2e | ||
| HOST_DATABASE_URL: postgresql://relayer:relayer@localhost:5433/relayer | ||
| RELAYER_URL: http://localhost:2005 | ||
| STELLAR_CHAIN_ID: "1000001" | ||
| EVM_CHAIN_ID: "31337" | ||
|
|
||
| jobs: | ||
| backend-relayer-e2e: | ||
| name: Backend Relayer E2E | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 45 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
|
|
||
| - uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Install wasm32v1-none target | ||
| run: rustup target add wasm32v1-none | ||
|
|
||
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
|
|
||
| - name: Install Stellar CLI | ||
| env: | ||
| STELLAR_CLI_VERSION: "23.3.0" | ||
| STELLAR_CLI_SHA256: "b3a5455d7113a53a8bd0f1ba0148a14b7aa7a46ee2f49c3b9277424775b309ad" | ||
| run: | | ||
| set -euo pipefail | ||
| url="https://github.com/stellar/stellar-cli/releases/download/v${STELLAR_CLI_VERSION}/stellar-cli-${STELLAR_CLI_VERSION}-x86_64-unknown-linux-gnu.tar.gz" | ||
| curl -fsSL "$url" -o /tmp/stellar-cli.tar.gz | ||
| echo "${STELLAR_CLI_SHA256} /tmp/stellar-cli.tar.gz" | sha256sum -c - | ||
| mkdir -p "$HOME/.local/bin" | ||
| tar -xzf /tmp/stellar-cli.tar.gz -C "$HOME/.local/bin" stellar | ||
| chmod +x "$HOME/.local/bin/stellar" | ||
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | ||
|
JoE11-y marked this conversation as resolved.
|
||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Install Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| cache: "pnpm" | ||
|
|
||
| - name: Install Node dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Cache cargo directories | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| contracts/stellar/target | ||
| key: ${{ runner.os }}-cargo-relayer-e2e-${{ hashFiles('contracts/stellar/Cargo.lock') }} | ||
|
|
||
| - name: Generate Prisma client | ||
| run: pnpm --filter backend-relayer exec prisma generate | ||
|
|
||
| # ── 1. chains ──────────────────────────────────────────────────── | ||
| - name: Start chains (Stellar + Anvil) and build contracts | ||
| run: bash scripts/start_chains.sh | ||
|
|
||
| - name: Export chain env | ||
| run: | | ||
| # .chains.env uses `export KEY='value'`; $GITHUB_ENV expects KEY=value. | ||
| sed -E "s/^export[[:space:]]+([A-Za-z_][A-Za-z0-9_]*)='(.*)'$/\1=\2/" .chains.env >> "$GITHUB_ENV" | ||
|
|
||
|
JoE11-y marked this conversation as resolved.
|
||
| # ── 2. deploy ──────────────────────────────────────────────────── | ||
| - name: Deploy contracts | ||
| run: pnpm --filter relayer-e2e exec tsx cli.ts deploy --out "$SNAPSHOT_PATH" | ||
|
|
||
| # ── 3. postgres + backend-relayer containers ───────────────────── | ||
| - name: Start postgres + backend-relayer | ||
| env: | ||
| STELLAR_NETWORK_PASSPHRASE: "Standalone Network ; February 2017" | ||
| run: docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT_NAME" up -d --build --wait | ||
|
|
||
| # ── 4. seed ────────────────────────────────────────────────────── | ||
| - name: Seed database | ||
| run: DATABASE_URL="$HOST_DATABASE_URL" pnpm --filter relayer-e2e exec tsx cli.ts seed --in "$SNAPSHOT_PATH" | ||
|
|
||
| # ── 5. flows ───────────────────────────────────────────────────── | ||
| - name: Run lifecycle flows | ||
| run: pnpm --filter relayer-e2e exec tsx cli.ts flows | ||
|
|
||
| # ── teardown ───────────────────────────────────────────────────── | ||
| - name: Dump relayer logs | ||
| if: always() | ||
| run: | | ||
| echo "::group::backend-relayer logs" | ||
| docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT_NAME" logs --no-color --tail=500 backend-relayer | tee .relayer.log || true | ||
| echo "::endgroup::" | ||
| echo "::group::postgres logs" | ||
| docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT_NAME" logs --no-color --tail=200 postgres | tee .postgres.log || true | ||
| echo "::endgroup::" | ||
| echo "::group::container state" | ||
| docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT_NAME" ps -a || true | ||
| echo "::endgroup::" | ||
|
|
||
| - name: Stop containers | ||
| if: always() | ||
| run: docker compose -f "$COMPOSE_FILE" -p "$COMPOSE_PROJECT_NAME" down --remove-orphans --volumes || true | ||
|
|
||
| - name: Stop chains | ||
| if: always() | ||
| run: bash scripts/stop_chains.sh || true | ||
|
|
||
| - name: Upload logs + snapshot | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: relayer-logs | ||
| path: | | ||
| .relayer.log | ||
| .postgres.log | ||
| .chains.anvil.log | ||
| scripts/relayer-e2e/deployed.json | ||
| if-no-files-found: ignore | ||
This file contains hidden or 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,74 @@ | ||
| name: Backend Relayer Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "apps/backend-relayer/**" | ||
| - "packages/**" | ||
| - "package.json" | ||
| - "pnpm-workspace.yaml" | ||
| - "pnpm-lock.yaml" | ||
| - ".github/workflows/backend-relayer-tests.yml" | ||
| pull_request: | ||
| paths: | ||
| - "apps/backend-relayer/**" | ||
| - "packages/**" | ||
| - "package.json" | ||
| - "pnpm-workspace.yaml" | ||
| - "pnpm-lock.yaml" | ||
| - ".github/workflows/backend-relayer-tests.yml" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| unit: | ||
| name: Unit tests | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Install Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| cache: "pnpm" | ||
|
|
||
| - name: Install Node dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Generate Prisma client | ||
| run: pnpm --filter backend-relayer exec prisma generate | ||
|
|
||
| - name: Run unit tests | ||
| run: pnpm --filter backend-relayer test | ||
|
|
||
| e2e: | ||
| name: Jest e2e tests | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 25 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Install Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| cache: "pnpm" | ||
|
|
||
| - name: Install Node dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Generate Prisma client | ||
| run: pnpm --filter backend-relayer exec prisma generate | ||
|
|
||
| - name: Run Jest e2e tests | ||
| run: pnpm --filter backend-relayer test:e2e | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| ADMIN_SECRET="" | ||
| DATABASE_URL="" | ||
| EVM_RPC_API_KEY="" | ||
| JWT_EXPIRY="" | ||
| JWT_REFRESH_EXPIRTY="" | ||
| JWT_SECRET="" | ||
| NODE_ENV="" | ||
| PORT="" | ||
| SECRET_KEY="" | ||
| EVM_ADMIN_PRIVATE_KEY= | ||
| DATABASE_URL= | ||
| EVM_RPC_API_KEY= | ||
| JWT_EXPIRY= | ||
| JWT_REFRESH_EXPIRY= | ||
| JWT_SECRET= | ||
| NODE_ENV= | ||
| PORT= | ||
| SECRET_KEY= | ||
| SIGN_DOMAIN=proof-bridge.vercel.app | ||
| SIGN_URI=https://proof-bridge.vercel.app | ||
| # Stellar SEP-10 server signing key. Generate with: Keypair.random().secret() | ||
| STELLAR_AUTH_SECRET="" | ||
| STELLAR_RPC_URL="" | ||
| STELLAR_NETWORK_PASSPHRASE="" | ||
| STELLAR_ADMIN_SECRET="" | ||
| STELLAR_AUTH_SECRET= | ||
| STELLAR_RPC_URL= | ||
| STELLAR_NETWORK_PASSPHRASE= | ||
| STELLAR_ADMIN_SECRET= |
This file contains hidden or 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,68 @@ | ||
| # syntax=docker/dockerfile:1.7 | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 1 — builder | ||
| # ----------------------------------------------------------------------------- | ||
| FROM node:20-slim AS builder | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends python3 make g++ openssl ca-certificates \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN corepack enable && corepack prepare pnpm@10.10.0 --activate | ||
|
|
||
| WORKDIR /repo | ||
|
|
||
| # Copy workspace manifests first for better cache hits. | ||
| COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./ | ||
| COPY apps/backend-relayer/package.json apps/backend-relayer/ | ||
| COPY packages/proofbridge_mmr/package.json packages/proofbridge_mmr/ | ||
|
|
||
| # Prefetch all workspace deps once. | ||
| RUN pnpm fetch --ignore-scripts | ||
|
|
||
| # Now pull in the sources we need to build. | ||
| COPY apps/backend-relayer apps/backend-relayer | ||
| COPY packages/proofbridge_mmr packages/proofbridge_mmr | ||
|
|
||
| # Install & build the relayer (and only the relayer — avoid compiling every | ||
| # workspace package). | ||
| RUN pnpm install --frozen-lockfile --offline \ | ||
| && pnpm --filter backend-relayer exec prisma generate \ | ||
| && pnpm --filter backend-relayer build | ||
|
|
||
| # `pnpm deploy` only copies files listed in the package's `files` field, so | ||
| # copy dist/ and prisma/ explicitly, then re-run prisma generate inside /out | ||
| # so .prisma/client lands in the final node_modules. | ||
| RUN pnpm --filter backend-relayer deploy --prod --legacy /out \ | ||
| && cp -r apps/backend-relayer/dist /out/dist \ | ||
| && cp -r apps/backend-relayer/prisma /out/prisma \ | ||
| && cd /out && npx prisma generate --schema=prisma/schema.prisma | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Stage 2 — runtime | ||
| # ----------------------------------------------------------------------------- | ||
| FROM node:20-slim AS runtime | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends openssl ca-certificates tini \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY --from=builder /out/package.json ./package.json | ||
| COPY --from=builder /out/node_modules ./node_modules | ||
| COPY --from=builder /out/dist ./dist | ||
| COPY --from=builder /out/prisma ./prisma | ||
|
|
||
| RUN chown -R node:node /app | ||
| USER node | ||
|
|
||
| ENV NODE_ENV=production | ||
| ENV PORT=2005 | ||
| EXPOSE 2005 | ||
|
|
||
| # `tini` keeps signal forwarding sane. Migrations run on every boot — idempotent | ||
| # for an already-migrated DB. | ||
| ENTRYPOINT ["/usr/bin/tini", "--"] | ||
| CMD ["sh", "-c", "npx prisma migrate deploy && node dist/src/main.js"] | ||
|
JoE11-y marked this conversation as resolved.
|
||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.