Skip to content

Conversation

@rodrigopavezi
Copy link
Member

@rodrigopavezi rodrigopavezi commented Jan 29, 2026

  • Move substreams-tron from requestNetwork monorepo
  • Add tron/ folder with Rust WASM module for indexing payments
  • Add GitHub Actions CI workflow with optional integration tests
  • Index TransferWithReferenceAndFee events from ERC20FeeProxy
  • Support both Nile testnet and mainnet contracts

Summary by CodeRabbit

  • New Features

    • TRON support for indexing ERC20FeeProxy payment events on Mainnet and Nile, exposing a Payment entity.
  • Chores

    • Added build/packaging targets, protobuf types, Substreams manifest and subgraph config, and a CI pipeline with conditional integration tests and deploy flows.
  • Documentation

    • Added README with build, run, test, and deployment instructions.

✏️ Tip: You can customize this high-level summary in your review settings.

- Move substreams-tron from requestNetwork monorepo
- Add tron/ folder with Rust WASM module for indexing payments
- Add GitHub Actions CI workflow with optional integration tests
- Index TransferWithReferenceAndFee events from ERC20FeeProxy
- Support both Nile testnet and mainnet contracts
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

Adds a new TRON Substreams module (Rust crate, protobuf, GraphQL schema, Substreams manifests, runtime logic, tests, and docs) and a GitHub Actions CI/CD workflow for building, testing, integration runs against Nile, and deployments to Nile/mainnet.

Changes

Cohort / File(s) Summary
CI/CD Pipeline
.github/workflows/tron-build.yml
Adds a multi-job GitHub Actions workflow: build-and-test, conditional integration-test against Nile, and deploy jobs for Nile and mainnet with artifact checks, versioning, and manual dispatch inputs.
Crate & Build Tooling
tron/Cargo.toml, tron/Makefile, tron/README.md
Adds Rust crate manifest (wasm target deps, release profile), Makefile targets (build, protogen, package, gui, run, test, clean), and README documenting build/run/deploy/test steps and endpoints.
Substreams/Subgraph Manifests
tron/substreams.yaml, tron/subgraph.yaml
Adds Substreams manifest defining package, imports, map module (map_erc20_fee_proxy_payments), parameters for mainnet/Nile, and a subgraph.yaml datasource packaging the module.
Protobuf Definitions & Generated Rust
tron/proto/request/tron/v1/payments.proto, tron/src/pb/mod.rs, tron/src/pb/request.tron.v1.rs, tron/src/pb/sf.tron.type.v1.rs
Adds payments.proto (Payment/Payments), wires generated prost modules, and includes TRON block/transaction protobuf types and enums with prost code.
Core Substreams Implementation
tron/src/lib.rs
Implements map_erc20_fee_proxy_payments handler: event signature detection, ABI parsing helpers, TRON Base58Check address encoding, owner extraction from tx params, payments aggregation, and unit tests.
GraphQL Schema
tron/schema.graphql
Adds Payment entity schema with fields mapping to parsed payment data (id, tokenAddress, to, amount, reference, feeAmount, feeAddress, from, block, timestamp, txHash, contractAddress).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant GH as GitHub Actions
participant CI as Build-and-Test
participant IT as Integration-Test
participant Builder as Rust/WASM Builder
participant SubstreamsCLI as Substreams CLI
participant Nile as Nile Testnet
participant GraphStudio as The Graph Studio

GH->>CI: trigger (push/PR/release/dispatch)
CI->>Builder: checkout, setup Rust+wasm target, cache, build, run unit tests
CI->>CI: verify .spkg/.wasm artifact exists
alt integration tests requested
  GH->>IT: run integration-test job
  IT->>Builder: build/package artifact
  IT->>SubstreamsCLI: run substreams map against Nile
  SubstreamsCLI->>Nile: query blocks/logs
  Nile-->>SubstreamsCLI: responses
  IT->>GH: validate output.json, pass/fail
end
alt deploy to Nile
  GH->>GraphStudio: authenticate, deploy packaged .spkg with version label
  GraphStudio-->>GH: endpoint URL
end
alt deploy to Mainnet
  GH->>GraphStudio: authenticate, deploy using release tag or version label
  GraphStudio-->>GH: endpoint URL
end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding a TRON substreams module for detecting ERC20FeeProxy payment events. It aligns with the PR objectives and the changeset content.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@rodrigopavezi rodrigopavezi marked this pull request as ready for review January 29, 2026 01:23
- Add deploy_subgraph workflow input to trigger deployment
- Add deploy_network choice (nile or mainnet)
- Install Graph CLI and authenticate with deploy key
- Package substreams and deploy to The Graph Studio
- Requires GRAPH_STUDIO_DEPLOY_KEY secret
- Push to main → deploy to Nile testnet (with commit SHA in version)
- GitHub release published → deploy to mainnet (with release tag as version)
- Manual workflow_dispatch still available for both networks
- Integration tests run before testnet deployment
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tron/subgraph.yaml`:
- Around line 16-19: The subgraph source.file references a package file with
hyphens ("./request-network-tron-v0.1.0.spkg") but the actual built package name
uses underscores from the substreams package (request_network_tron), so update
the source.package.file value in tron/subgraph.yaml to
"./request_network_tron-v0.1.0.spkg" so it matches the package name; keep the
same moduleName (map_erc20_fee_proxy_payments) and ensure the filename spelling
matches the package name used in tron/substreams.yaml (request_network_tron).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/tron-build.yml:
- Around line 227-234: The deploy-mainnet job currently only depends on
build-and-test, so it can run without running integration-test; update the job's
needs array for the deploy-mainnet job to include integration-test (i.e., change
needs: [build-and-test] to needs: [build-and-test, integration-test]) so mainnet
deployments wait for integration tests to pass.
- Around line 129-143: The current step runs "substreams run ./substreams.yaml
map_erc20_fee_proxy_payments" and redirects output to output.json but masks
failures with "|| true" and then uses a fragile grep -q "error" on output.json;
remove the "|| true" so the command's exit code is preserved, check the
command's exit status immediately (fail if non-zero), and replace the blind grep
with a precise JSON check against output.json (e.g., using jq to test for a
top-level error field or non-success status) instead of matching any substring
"error"; update references to the exact symbols "substreams run
./substreams.yaml map_erc20_fee_proxy_payments", "output.json", and the current
grep -q "error" usage when making this change.
🧹 Nitpick comments (4)
.github/workflows/tron-build.yml (4)

49-60: Consider including Cargo.lock in the cache key for reproducible builds.

The cache key only uses Cargo.toml hash, which doesn't capture locked dependency versions. If Cargo.lock exists in the repository, including it ensures cache invalidation when dependencies are updated.

Also, caching ~/.cargo/bin/ may persist stale tool binaries across workflow runs. Consider removing it unless specific tools are installed there.

♻️ Suggested improvement
-          key: ${{ runner.os }}-cargo-${{ hashFiles('tron/Cargo.toml') }}
+          key: ${{ runner.os }}-cargo-${{ hashFiles('tron/Cargo.lock', 'tron/Cargo.toml') }}

112-116: Consider pinning the Substreams CLI version for reproducible CI.

Using releases/latest can cause unexpected CI failures or behavior changes when a new CLI version is released with breaking changes.

♻️ Suggested fix
       - name: Install Substreams CLI
         run: |
-          curl -sSL https://github.com/streamingfast/substreams/releases/latest/download/substreams_linux_x86_64.tar.gz | tar xz
+          # Pin to a specific version for reproducible builds
+          SUBSTREAMS_VERSION="v1.12.1"  # Update as needed
+          curl -sSL "https://github.com/streamingfast/substreams/releases/download/${SUBSTREAMS_VERSION}/substreams_linux_x86_64.tar.gz" | tar xz
           sudo mv substreams /usr/local/bin/

292-308: Consider validating version format before deployment.

The mainnet deployment extracts version from release tag or Cargo.toml without validation. Malformed versions could cause deployment issues or make it harder to track releases.

♻️ Suggested improvement
       - name: Deploy to Mainnet
         working-directory: tron
         run: |
           # For releases, use the release tag as version
           if [ "${{ github.event_name }}" = "release" ]; then
             VERSION="${{ github.event.release.tag_name }}"
           else
             VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
             VERSION="v${VERSION}"
           fi
           
+          # Validate version format (basic semver check)
+          if ! echo "$VERSION" | grep -qE '^v?[0-9]+\.[0-9]+\.[0-9]+'; then
+            echo "WARNING: Version '$VERSION' may not follow semver format"
+          fi
+          
           echo "Deploying to request-payments-tron with version: $VERSION"

207-208: The suggested environment variable approach is not supported by Graph CLI.

Graph CLI does not support GRAPH_AUTH_TOKEN or similar environment variables for authentication. The graph auth --studio command expects the deploy key as a direct argument, which is the documented pattern. While the security concern about passing secrets via command-line arguments is valid, the suggested alternative will not work.

For CI environments, consider using graph deploy --access-token <token> instead, which is designed for non-interactive usage and avoids keychain storage complications.

- Add unit tests for base58 encoding, address parsing, uint256 parsing
- Add test for full TransferWithReferenceAndFee event data structure
- Add test for edge cases (short data, zero values)
- Improve integration test to output JSON and validate structure
- Integration test processes 100 blocks and validates payment fields
Copy link
Member

@MantisClone MantisClone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Thanks for moving the Tron substreams to the dedicated payments-substream repo - this follows the established convention (like price-aggregators-subgraph) and keeps the SDK repo focused.

Items to Address

  1. Amount format (tron/src/lib.rs) - see pending comment thread about hex vs decimal

  2. Package filename (tron/subgraph.yaml:19) - please verify the filename produced by make package matches what's referenced here (underscores vs hyphens)

Suggestions

  1. Package naming (tron/substreams.yaml:3) - worth considering what naming convention will work as the repo grows to support other protocols (see inline comment)

  2. CI error handling (.github/workflows/tron-build.yml:153) - set +e masks failures; consider explicit exit code checking

Questions

  • What's the plan for packages/substreams-tron in the requestNetwork monorepo PR #1691? Should that code be removed now that this repo is the canonical location?

What Looks Good

  • Rust implementation is solid with good test coverage
  • Base58Check address encoding is correct
  • Event signature detection is properly validated
  • CI/CD pipeline is comprehensive (build, test, deploy stages)
  • README documentation is helpful

- Fix package filename in subgraph.yaml (use underscores to match substreams.yaml)
- Improve CI error handling by checking exit code directly instead of fragile grep
- Convert uint256 to decimal strings for TheGraph BigInt compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants