feat(subgraph): introduce mustache templates#96
Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a Mustache-template-based build pipeline for the subgraph so that network-specific configuration (mainnet vs calibration) is centralized in subgraph/config/network.json, and network-targeted builds can generate the correct subgraph.yaml and constants automatically.
Changes:
- Added Mustache templates + generation scripts to produce
subgraph.yamlandsrc/generated/constants.tsfromconfig/network.json. - Updated subgraph mappings to consume generated constants (
ContractConstants) instead of hardcoded per-network values. - Removed legacy per-network subgraph YAML files and updated build scripts/docs to use
npm run build:<network>.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| subgraph/utils/index.ts | Re-exports generated ContractConstants and removes hardcoded proving-period constants. |
| subgraph/src/pdp-verifier.ts | Switches proving-period config to generated ContractConstants. |
| subgraph/templates/subgraph.template.yaml | Parameterizes network, address, and start block via Mustache. |
| subgraph/templates/constants.template.ts | New Mustache template for generated contract constants. |
| subgraph/config/network.json | New centralized per-network configuration source. |
| subgraph/scripts/utils/config-loader.js | New helper to load/validate selected network config. |
| subgraph/scripts/generate-constants.js | New generator for src/generated/constants.ts. |
| subgraph/scripts/generate-config.js | New generator for subgraph.yaml. |
| subgraph/package.json | Adds generation + network build scripts and mustache dependency. |
| subgraph/package-lock.json | Updates lockfile for new deps and Graph tooling versions. |
| subgraph/.gitignore | Ignores generated subgraph.yaml. |
| subgraph/subgraph_mainnet.yaml | Removed legacy mainnet manifest file. |
| subgraph/subgraph_testnet.yaml | Removed legacy testnet manifest file. |
| README.md | Documents the new configuration and build flow. |
Files not reviewed (1)
- subgraph/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@FilOzone/storswift : can you please review? @juliangruber : it may be good to look at this since I assume we'll want to do something similar with the filecoin-pay subgraph. |
|
@FilOzone/storswift : any concerns with merging this? This has been open for over a month now... |
Summary
This PR introduces a template-based build system using Mustache templates to streamline subgraph deployment across different networks (
mainnetandcalibration). The new system centralizes network configuration in a single JSON file and automatically generates network-specific constants and YAML files.Migration Guide
Before
cp subgraph_mainnet.yaml subgraph.yaml # Edit utils/index.ts to set constants graph codegen graph buildAfter
# Single command npm run build:mainnetBreaking Changes
None - this is an internal build system change that doesn't affect the deployed subgraph functionality.
Related to #89