Skip to content

Commit 24557e8

Browse files
authored
Merge pull request #43 from radcrew/feat/go-indexer
Replace Node.js indexer with standalone Go service (indexer-go)
2 parents 7ef35c5 + 7f0ae5a commit 24557e8

89 files changed

Lines changed: 6732 additions & 1027 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/indexer-go.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Indexer Go CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'indexer-go/**'
8+
- 'proto/**'
9+
- '.github/workflows/indexer-go.yml'
10+
pull_request:
11+
paths:
12+
- 'indexer-go/**'
13+
- 'proto/**'
14+
- '.github/workflows/indexer-go.yml'
15+
16+
concurrency:
17+
group: indexer-go-${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-latest
23+
defaults:
24+
run:
25+
working-directory: indexer-go
26+
27+
# Scratch Postgres so the env-gated store integration tests (idempotent
28+
# version-guarded upserts, battle replay) run in CI, not just locally.
29+
services:
30+
postgres:
31+
image: postgres:16-alpine
32+
env:
33+
POSTGRES_PASSWORD: test
34+
ports:
35+
- 5432:5432
36+
options: >-
37+
--health-cmd pg_isready
38+
--health-interval 5s
39+
--health-timeout 5s
40+
--health-retries 10
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- uses: actions/setup-go@v5
46+
with:
47+
go-version-file: indexer-go/go.mod
48+
cache-dependency-path: indexer-go/go.sum
49+
50+
- name: Vet
51+
run: go vet ./...
52+
53+
- name: Test (race, with Postgres integration)
54+
env:
55+
TEST_DATABASE_URL: postgresql://postgres:test@localhost:5432/postgres
56+
run: go test -race -count=1 -timeout 300s ./...
57+
58+
- name: Build binaries
59+
run: |
60+
go build -o bin/indexer ./cmd/indexer
61+
go build -o bin/diff ./cmd/diff
62+
63+
- name: Verify proto stubs are current
64+
run: |
65+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
66+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
67+
go install github.com/bufbuild/buf/cmd/buf@latest
68+
buf generate ../proto --template buf.gen.yaml
69+
git diff --exit-code pb/ || {
70+
echo "::error::pb/ stubs are stale — run 'buf generate ../proto --template buf.gen.yaml' in indexer-go/"
71+
exit 1
72+
}

DEVELOPMENT.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,20 @@ This starts:
5252
do-not-stop/
5353
├── frontend/ # React + Vite frontend
5454
├── backend/ # Node.js + Express + TypeScript
55+
├── indexer-go/ # Go cross-chain indexer (see indexer-go/README.md)
56+
├── proto/ # gRPC contract shared by indexer-go and backend
5557
├── contracts/
5658
│ ├── ethereum/ # Hardhat + Solidity contracts
5759
│ └── solana/ # Anchor + Rust + Docker
5860
└── scripts/ # Deployment automation
5961
```
6062

63+
The Go indexer mirrors the backend's `RosterIndexer` (EVM subgraph polling +
64+
Solana WebSocket push) into `pet_roster`/`battle_history`, and streams settled
65+
battles to the backend over gRPC (`StreamLiveBattles`). Build/test/runbook:
66+
`indexer-go/README.md`. It is optional in local dev — the Node indexers cover
67+
everything until promotion.
68+
6169
## Development Workflow
6270

6371
1. **First time:**

backend/env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ DIRECT_URL="postgresql://postgres.<project-ref>:<password>@aws-1-<region>.pooler
6565
# Optional — restrict CORS in production (comma-separated origins).
6666
# Leave unset to allow all origins (default for local dev).
6767
# CORS_ORIGIN=https://your-frontend.onrender.com,https://your-domain.com
68+
69+
# --- indexer-go gRPC link (optional) ---
70+
# StreamLiveBattles: chain-truth battle pushes from the Go indexer. Unset = off.
71+
# INDEXER_GRPC_ADDR=localhost:50051
72+
# Path to the shared proto contract; defaults to ../proto/cryptopets.proto.
73+
# INDEXER_PROTO_PATH=
74+
# Roster read source: 'grpc' answers matchmaking reads from indexer-go's RAM
75+
# cache (Prisma fallback on any failure); unset/'postgres' = Prisma only.
76+
# Only enable after indexer-go is promoted (ROSTER_CACHE_ENABLED=true there).
77+
# ROSTER_READ_SOURCE=postgres

backend/indexing/evm/indexer.ts

Lines changed: 0 additions & 182 deletions
This file was deleted.

backend/indexing/evm/subgraph/src/battle.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

backend/indexing/solana/indexer.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)