-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add TRON substreams for ERC20FeeProxy payment detection #2
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
base: main
Are you sure you want to change the base?
Conversation
- 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
WalkthroughAdds 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
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
- 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
There was a problem hiding this 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).
There was a problem hiding this 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 includingCargo.lockin the cache key for reproducible builds.The cache key only uses
Cargo.tomlhash, which doesn't capture locked dependency versions. IfCargo.lockexists 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/latestcan 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_TOKENor similar environment variables for authentication. Thegraph auth --studiocommand 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
MantisClone
left a comment
There was a problem hiding this 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
-
Amount format (
tron/src/lib.rs) - see pending comment thread about hex vs decimal -
Package filename (
tron/subgraph.yaml:19) - please verify the filename produced bymake packagematches what's referenced here (underscores vs hyphens)
Suggestions
-
Package naming (
tron/substreams.yaml:3) - worth considering what naming convention will work as the repo grows to support other protocols (see inline comment) -
CI error handling (
.github/workflows/tron-build.yml:153) -set +emasks failures; consider explicit exit code checking
Questions
- What's the plan for
packages/substreams-tronin 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

Summary by CodeRabbit
New Features
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.