Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FOC_API_URL=https://your-deployment.example.com
# Server port
FOC_SERVER_PORT=17824

# Lotus RPC endpoints
# Lotus RPC endpoints. Compose passes each URL to a separate indexer and
# selects its network with PONDER_NETWORK; no network-specific image is needed.
# For local Lotus gateway via the lotus-proxy container:
# CALIBNET_RPC_URL=http://host.docker.internal:11235/rpc/v1
# MAINNET_RPC_URL=http://host.docker.internal:11234/rpc/v1
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ jobs:
cache: npm
cache-dependency-path: indexer/package-lock.json
- run: npm ci
# typecheck symlinks ponder.config.mainnet.ts -> ponder.config.ts,
# runs ponder codegen to materialize ponder-env.d.ts, then tsc --noEmit.
# No DB or RPC needed; codegen accepts dummy connection strings.
# Tests load the actual config under both networks and strict-mode failures.
- run: npm test
# Typecheck runs mainnet codegen to materialize ponder-env.d.ts, then
# tsc --noEmit. No DB or RPC is needed; codegen accepts dummy values.
- run: npm run codegen:calibnet
- run: npm run typecheck
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ cp .env.example .env
docker compose up -d
```

When upgrading to this unified configuration, rebuild the indexers before restarting them. The unified
`ponder.config.ts` is baked into the indexer image, so mounting the updated source directories alone does not update it:

```bash
docker compose up -d --build ponder-calibnet ponder-mainnet
```

### Configuration

All configuration is via `.env`. Copy `.env.example` for a template.
Expand Down Expand Up @@ -219,7 +226,19 @@ npm test

### Indexer

The Ponder indexer uses a [Filecoin-compatible fork](https://github.com/rvagg/filecoin-ponder) of Ponder. The Docker build clones this fork automatically.
The Ponder indexer uses a [Filecoin-compatible fork](https://github.com/rvagg/filecoin-ponder) of Ponder. Set `PONDER_NETWORK` to `mainnet` or `calibnet`; the default is `mainnet` for local development. Set `PONDER_STRICT_ENV=true` to require `PONDER_NETWORK`, `DATABASE_URL`, and `RPC_URL`, as the Docker Compose services do.

Useful commands:

```bash
cd indexer
npm run dev:mainnet
npm run dev:calibnet
npm run codegen:mainnet
npm run codegen:calibnet
npm test
npm run typecheck
```

To regenerate contract ABIs:

Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
PONDER_NETWORK: calibnet
PONDER_STRICT_ENV: "true"
DATABASE_URL: postgres://ponder:ponder@postgres-calibnet:5432/ponder
RPC_URL: ${CALIBNET_RPC_URL:?}
PORT: 17827
Expand All @@ -63,7 +65,6 @@ services:
command: ["npm", "start", "--", "--schema", "${CALIBNET_DATA_SCHEMA:-data_v1}", "--views-schema", "public"]
restart: unless-stopped
volumes:
- ./indexer/ponder.config.calibnet.ts:/app/ponder.config.ts
- ./indexer/ponder.schema.ts:/app/ponder.schema.ts
- ./indexer/src:/app/src
- ./indexer/abis:/app/abis
Expand All @@ -76,14 +77,15 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
PONDER_NETWORK: mainnet
PONDER_STRICT_ENV: "true"
DATABASE_URL: postgres://ponder:ponder@postgres-mainnet:5432/ponder
RPC_URL: ${MAINNET_RPC_URL:?}
PORT: 17828
PONDER_EXPERIMENTAL_DB: platform
command: ["npm", "start", "--", "--schema", "${MAINNET_DATA_SCHEMA:-data_v1}", "--views-schema", "public"]
restart: unless-stopped
volumes:
- ./indexer/ponder.config.mainnet.ts:/app/ponder.config.ts
- ./indexer/ponder.schema.ts:/app/ponder.schema.ts
- ./indexer/src:/app/src
- ./indexer/abis:/app/abis
Expand Down
1 change: 0 additions & 1 deletion indexer/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ node_modules
dist
.env
.env.local
ponder.config*.ts
4 changes: 0 additions & 4 deletions indexer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ dist/
.ponder/
generated/
ponder-env.d.ts
# Symlinked at runtime (Docker volume mount selects the network) and at
# typecheck time (npm run typecheck symlinks mainnet's config). Either way
# this file is generated, not authored.
ponder.config.ts
5 changes: 1 addition & 4 deletions indexer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund

COPY tsconfig.json ponder.schema.ts ./
COPY tsconfig.json ponder.config.ts ponder.schema.ts ./
COPY abis ./abis
COPY src ./src
COPY docker-entrypoint.sh ./
RUN chmod +x /app/docker-entrypoint.sh

ENV NO_COLOR=1
RUN chown -R node:node /app
USER node
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["npm", "start"]
9 changes: 0 additions & 9 deletions indexer/docker-entrypoint.sh

This file was deleted.

9 changes: 8 additions & 1 deletion indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
"type": "module",
"scripts": {
"dev": "ponder dev",
"dev:calibnet": "PONDER_NETWORK=calibnet ponder dev",
"dev:mainnet": "PONDER_NETWORK=mainnet ponder dev",
"start": "ponder start",
"start:calibnet": "PONDER_NETWORK=calibnet ponder start",
"start:mainnet": "PONDER_NETWORK=mainnet ponder start",
"codegen": "ponder codegen",
"codegen:calibnet": "PONDER_NETWORK=calibnet RPC_URL=http://localhost:1235/rpc/v1 DATABASE_URL=postgres://noop:noop@localhost:5432/noop ponder codegen",
"codegen:mainnet": "PONDER_NETWORK=mainnet RPC_URL=http://localhost:1234/rpc/v1 DATABASE_URL=postgres://noop:noop@localhost:5432/noop ponder codegen",
"generate-abis": "./scripts/generate-abis.sh",
"typecheck": "ln -sf ponder.config.mainnet.ts ponder.config.ts && RPC_URL=http://localhost:1234 DATABASE_URL=postgres://noop:noop@localhost:5432/noop ponder codegen && tsc --noEmit; rc=$?; rm -f ponder.config.ts; exit $rc"
"test": "node --experimental-strip-types --test test/*.test.ts",
"typecheck": "npm run codegen:mainnet && tsc --noEmit"
},
"dependencies": {
"hono": "^4.12",
Expand Down
104 changes: 0 additions & 104 deletions indexer/ponder.config.calibnet.ts

This file was deleted.

102 changes: 0 additions & 102 deletions indexer/ponder.config.mainnet.ts

This file was deleted.

Loading