-
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
Open
rodrigopavezi
wants to merge
22
commits into
main
Choose a base branch
from
add-tron-substreams
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e02a720
feat: add TRON substreams for ERC20FeeProxy payment detection
rodrigopavezi 8deb691
fix: correct rust-toolchain action name
rodrigopavezi 95f4ffc
feat: add automated subgraph deployment to The Graph Studio
rodrigopavezi 6dd2aed
feat: auto-deploy testnet on merge, mainnet on release
rodrigopavezi 24e7bf3
feat: add comprehensive unit tests for event parsing
rodrigopavezi ec1da40
fix: address PR review comments
rodrigopavezi d05e0bb
feat: configure TRON substream for mainnet-only deployment via Stream…
rodrigopavezi a89be03
Prepare for Easypanel production deployment
rodrigopavezi 720ba6e
Prepare for Easypanel production deployment with new docker compose
rodrigopavezi a2217ad
Add compiled substreams package for production deployment
rodrigopavezi 47480a8
Use single DSN environment variable for Easypanel compatibility
rodrigopavezi 8e1b8db
Fix environment variable passthrough for Easypanel
rodrigopavezi aa4fa7d
Add Easypanel network for cross-service communication
rodrigopavezi f516c22
Remove hardcoded container_name to avoid Easypanel conflicts
rodrigopavezi 8424ce3
Add chain field to payments for multi-network support
rodrigopavezi e47d133
Add comprehensive README with development and deployment guide
rodrigopavezi a26168a
Add The Graph Network integration for decentralized indexing
rodrigopavezi 38b2180
Add automated subgraph deployment to GitHub Actions
rodrigopavezi 9e6e175
Update subgraph naming to match Request Network convention
rodrigopavezi ba3e510
Remove The Graph subgraph integration (not supported for native TRON)
rodrigopavezi 4dba197
Add 0x prefix to payment_reference and document Hasura integration
rodrigopavezi 56aaf4f
Add TRON-native resource fields (energy_used, energy_fee, net_fee)
rodrigopavezi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Streamingfast API Token | ||
| # Get from: https://app.streamingfast.io/ | ||
| SUBSTREAMS_API_TOKEN=your-streamingfast-api-token | ||
|
|
||
| # PostgreSQL Password (for local development) | ||
| POSTGRES_PASSWORD=changeme | ||
|
|
||
| # PostgreSQL Port (optional, defaults to 5432) | ||
| # Use a different port if 5432 is already in use | ||
| POSTGRES_PORT=5433 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Production Environment Variables for Easypanel | ||
| # Copy this to .env.prod and fill in the values | ||
|
|
||
| # PostgreSQL connection (from Easypanel's built-in PostgreSQL service) | ||
| POSTGRES_HOST=your-project-postgres.internal | ||
| POSTGRES_PORT=5432 | ||
| POSTGRES_DB=tron_payments | ||
| POSTGRES_USER=postgres | ||
| POSTGRES_PASSWORD=your-secure-password-here | ||
|
|
||
| # Streamingfast API Token | ||
| # Get from: https://app.streamingfast.io/ | ||
| SUBSTREAMS_API_TOKEN=your-streamingfast-api-token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,262 @@ | ||
| name: Tron Substreams Build | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'tron/**' | ||
| - '.github/workflows/tron-build.yml' | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'tron/**' | ||
| - '.github/workflows/tron-build.yml' | ||
| workflow_dispatch: | ||
| inputs: | ||
| run_integration_tests: | ||
| description: 'Run integration tests against live endpoints' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| publish_package: | ||
| description: 'Build and publish package artifact' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| name: Build and Test Tron Substreams | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Cache Cargo dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| tron/target/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('tron/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Build WASM module | ||
| working-directory: tron | ||
| run: make build | ||
|
|
||
| - name: Run unit tests | ||
| working-directory: tron | ||
| run: make test | ||
|
|
||
| - name: Verify build artifacts | ||
| working-directory: tron | ||
| run: | | ||
| echo "Checking build artifacts..." | ||
| if [ ! -f "target/wasm32-unknown-unknown/release/request_network_tron.wasm" ]; then | ||
| echo "ERROR: WASM file not found!" | ||
| exit 1 | ||
| fi | ||
| echo "Build artifacts verified successfully" | ||
|
|
||
| integration-test-mainnet: | ||
| name: Integration Test (Mainnet EVM) | ||
| runs-on: ubuntu-latest | ||
| needs: build-and-test | ||
| # Run on: push to main (merge) or manual trigger | ||
| # PRs only run unit tests (no API key needed) | ||
| if: | | ||
| github.event.inputs.run_integration_tests == 'true' || | ||
| github.event.inputs.publish_package == 'true' || | ||
| (github.event_name == 'push' && github.ref == 'refs/heads/main') | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Cache Cargo dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| tron/target/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('tron/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Install Substreams CLI | ||
| run: | | ||
| curl -sSL https://github.com/streamingfast/substreams/releases/latest/download/substreams_linux_x86_64.tar.gz | tar xz | ||
| sudo mv substreams /usr/local/bin/ | ||
| substreams --version | ||
|
|
||
| - name: Build WASM module | ||
| working-directory: tron | ||
| run: make build | ||
|
|
||
| - name: Package Substreams | ||
| working-directory: tron | ||
| run: make package | ||
|
|
||
| - name: Verify package created | ||
| working-directory: tron | ||
| run: | | ||
| SPKG_FILE=$(ls -1 *.spkg 2>/dev/null | head -1) | ||
| if [ -z "$SPKG_FILE" ]; then | ||
| echo "ERROR: No .spkg package file found!" | ||
| exit 1 | ||
| fi | ||
| echo "✅ Package created: $SPKG_FILE" | ||
|
|
||
| - name: Deploy and test against Mainnet EVM (Streamingfast) | ||
| working-directory: tron | ||
| env: | ||
| SUBSTREAMS_API_TOKEN: ${{ secrets.SUBSTREAMS_API_TOKEN }} | ||
| run: | | ||
| echo "=== Deploying to TRON Mainnet EVM (Streamingfast) ===" | ||
| echo "Endpoint: mainnet-evm.tron.streamingfast.io:443" | ||
| echo "Block range: 79216121 to 79216221 (100 blocks from mainnet deployment)" | ||
| echo "" | ||
|
|
||
| SPKG_FILE=$(ls -1 *.spkg | head -1) | ||
| echo "Using package: $SPKG_FILE" | ||
|
|
||
| # Run substreams and capture JSON output | ||
| if ! substreams run "$SPKG_FILE" map_erc20_fee_proxy_payments \ | ||
| -e mainnet-evm.tron.streamingfast.io:443 \ | ||
| --start-block 79216121 \ | ||
| --stop-block +100 \ | ||
| -o json 2>&1 | tee output_mainnet.log; then | ||
| echo "" | ||
| echo "❌ FAILED: Substreams command returned non-zero exit code" | ||
| echo "Output:" | ||
| cat output_mainnet.log | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "=== Validating Results ===" | ||
|
|
||
| # If any payments were found, validate the structure | ||
| if grep -q '"payments"' output_mainnet.log; then | ||
| echo "✅ Payments data structure detected in output" | ||
|
|
||
| # Extract and validate payment fields if present | ||
| if grep -q '"token_address"' output_mainnet.log; then | ||
| echo "✅ Payment fields present: token_address" | ||
| fi | ||
| if grep -q '"payment_reference"' output_mainnet.log; then | ||
| echo "✅ Payment fields present: payment_reference" | ||
| fi | ||
| if grep -q '"amount"' output_mainnet.log; then | ||
| echo "✅ Payment fields present: amount" | ||
| fi | ||
| else | ||
| echo "ℹ️ No payments found in block range (expected if no transactions in these blocks)" | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "=== Mainnet Integration Test PASSED ===" | ||
| echo "The substreams module successfully:" | ||
| echo " - Loaded WASM module" | ||
| echo " - Connected to TRON Mainnet EVM endpoint via Streamingfast" | ||
| echo " - Processed 100 blocks without errors" | ||
| echo " - Output valid JSON structure" | ||
|
|
||
| # Publish package artifact for download/deployment | ||
| publish-package: | ||
| name: Publish Mainnet Package | ||
| runs-on: ubuntu-latest | ||
| needs: [build-and-test, integration-test-mainnet] | ||
| # Publish on: push to main (merge) or manual publish selection | ||
| if: | | ||
| (github.event_name == 'push' && github.ref == 'refs/heads/main') || | ||
| github.event.inputs.publish_package == 'true' | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Cache Cargo dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| tron/target/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('tron/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Install Substreams CLI | ||
| run: | | ||
| curl -sSL https://github.com/streamingfast/substreams/releases/latest/download/substreams_linux_x86_64.tar.gz | tar xz | ||
| sudo mv substreams /usr/local/bin/ | ||
|
|
||
| - name: Build WASM module | ||
| working-directory: tron | ||
| run: make build | ||
|
|
||
| - name: Package Substreams | ||
| working-directory: tron | ||
| run: make package | ||
|
|
||
| - name: Get package info | ||
| id: package_info | ||
| working-directory: tron | ||
| run: | | ||
| SPKG_FILE=$(ls -1 *.spkg 2>/dev/null | head -1) | ||
| if [ -z "$SPKG_FILE" ]; then | ||
| echo "ERROR: No .spkg package file found!" | ||
| exit 1 | ||
| fi | ||
| echo "spkg_file=$SPKG_FILE" >> $GITHUB_OUTPUT | ||
|
|
||
| VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "Package created successfully: $SPKG_FILE (version: $VERSION)" | ||
|
|
||
| - name: Upload package artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: request-network-tron-${{ steps.package_info.outputs.version }} | ||
| path: tron/${{ steps.package_info.outputs.spkg_file }} | ||
| retention-days: 90 | ||
|
|
||
| - name: Package ready for deployment | ||
| run: | | ||
| echo "==============================================" | ||
| echo "📦 Substreams Package Ready" | ||
| echo "==============================================" | ||
| echo "" | ||
| echo "Package: ${{ steps.package_info.outputs.spkg_file }}" | ||
| echo "Version: ${{ steps.package_info.outputs.version }}" | ||
| echo "==============================================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Rust build artifacts | ||
| target/ | ||
|
|
||
| # Substreams packages (built during CI) - except production package | ||
| *.spkg | ||
| !tron/*.spkg | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| .vscode/ | ||
| *.swp | ||
| *.swo | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Environment | ||
| .env | ||
| .env.local | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Substreams SQL Sink for TRON Payments | ||
| FROM ubuntu:22.04 | ||
|
|
||
| # Install dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| ca-certificates \ | ||
| curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Download substreams-sink-sql binary (v4.12.0) - detect architecture | ||
| ARG TARGETARCH | ||
| RUN ARCH=$(echo ${TARGETARCH:-amd64} | sed 's/amd64/x86_64/' | sed 's/arm64/arm64/') && \ | ||
| curl -sSL "https://github.com/streamingfast/substreams-sink-sql/releases/download/v4.12.0/substreams-sink-sql_linux_${ARCH}.tar.gz" -o /tmp/sink.tar.gz && \ | ||
| tar xzf /tmp/sink.tar.gz -C /usr/local/bin/ && \ | ||
| rm /tmp/sink.tar.gz && \ | ||
| chmod +x /usr/local/bin/substreams-sink-sql | ||
|
|
||
| # Copy the substreams package and schema | ||
| COPY tron/request-network-tron-v0.1.0.spkg /app/ | ||
| COPY tron/schema.sql /app/ | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Environment variables (override in deployment) | ||
| ENV DSN="" | ||
| ENV SUBSTREAMS_API_TOKEN="" | ||
| # Endpoint configured via SUBSTREAMS_ENDPOINTS_CONFIG_TRON env var | ||
| ENV SUBSTREAMS_ENDPOINTS_CONFIG_TRON="mainnet.tron.streamingfast.io:443" | ||
|
|
||
| # Create entrypoint script - uses sink config from the package | ||
| RUN printf '#!/bin/bash\nset -e\n\n# Setup the database schema first\necho "Setting up database schema..."\nsubstreams-sink-sql setup "$DSN" /app/request-network-tron-v0.1.0.spkg || true\n\n# Run the sink\necho "Starting sink..."\nexec substreams-sink-sql run "$DSN" /app/request-network-tron-v0.1.0.spkg\n' > /entrypoint.sh && \ | ||
| chmod +x /entrypoint.sh | ||
|
|
||
| # Health check | ||
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | ||
| CMD pgrep substreams-sink-sql || exit 1 | ||
|
|
||
| ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: RequestNetwork/payments-substream
Length of output: 1200
🏁 Script executed:
Repository: RequestNetwork/payments-substream
Length of output: 6068
🏁 Script executed:
Repository: RequestNetwork/payments-substream
Length of output: 9908
Remove the
.spkgfile from version control—your CI/CD workflow already handles artifact publishing correctly.The exception pattern
!tron/*.spkgtracks a 636KB build artifact that is never rebuilt (git history shows zero modifications to this file). Meanwhile, your CI/CD workflow (tron-build.yml) already builds, tests, and publishes the.spkgas a GitHub artifact after every push to main, making the committed copy stale and redundant.Remove the exception from
.gitignoreand delete the tracked.spkgfile. Developers and deployments should use the CI-generated artifact from GitHub instead, ensuring they always get the freshly built version that passed integration tests.🤖 Prompt for AI Agents