Skip to content

Conversation

@rodrigopavezi
Copy link
Member

@rodrigopavezi rodrigopavezi commented Jan 26, 2026

Description of the changes

Added a new Substreams module for indexing ERC20FeeProxy payment events on the TRON blockchain. This module:

  • Tracks TransferWithReferenceAndFee events from deployed ERC20FeeProxy contracts on TRON mainnet and Nile testnet
  • Extracts payment details including token address, amount, recipient, payment reference, fee information, and transaction metadata
  • Provides a Rust implementation with WASM compilation for Substreams
  • Includes configuration for deployment as a Substreams-powered subgraph
  • Contains Makefile, build scripts, and package configuration for easy development and deployment
  • Implements Base58 encoding for TRON addresses
  • Supports both mainnet (TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd) and Nile testnet (THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs) contract addresses

Closes RequestNetwork/private-issues#226

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

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

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@rodrigopavezi rodrigopavezi self-assigned this Jan 26, 2026
@rodrigopavezi rodrigopavezi marked this pull request as ready for review January 26, 2026 14:56
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

This PR adds a new Substreams module for indexing ERC20FeeProxy payment events on TRON blockchain (mainnet and Nile testnet). The implementation includes Rust code to parse TransferWithReferenceAndFee events, protobuf definitions, GraphQL schema, and deployment configurations.

Critical Issues Found:

  • Missing bs58 dependency in Cargo.toml - code will not compile
  • Event signature hash is incomplete (40 chars vs 64) AND never validated in the filtering logic, causing the parser to attempt processing ALL events from proxy contracts instead of just TransferWithReferenceAndFee events
  • Missing src/mappings.ts file referenced in subgraph.yaml - subgraph deployment will fail
  • store_payments module declared in substreams.yaml but no corresponding handler function implemented

Positive Aspects:

  • Well-structured protobuf definitions and GraphQL schema
  • Comprehensive README with clear documentation
  • Proper Base58Check encoding implementation for TRON addresses
  • Good separation of concerns with modular parsing functions

Confidence Score: 0/5

  • This PR has critical build and logic errors that will prevent compilation and correct operation
  • Multiple blocking issues: missing dependency will cause build failure, incorrect event validation will process wrong events, missing required file will block deployment, and undefined handler will cause runtime errors
  • Critical attention needed for Cargo.toml, src/lib.rs, subgraph.yaml, and substreams.yaml - all have blocking issues that must be resolved before merge

Important Files Changed

Filename Overview
packages/substreams-tron/Cargo.toml Missing critical bs58 dependency - build will fail
packages/substreams-tron/src/lib.rs Critical logic errors: incorrect event signature, no event validation, will parse wrong events
packages/substreams-tron/substreams.yaml Defines store_payments module without implementation handler
packages/substreams-tron/subgraph.yaml References non-existent mappings.ts file - deployment will fail

Sequence Diagram

sequenceDiagram
    participant TB as TRON Blockchain
    participant SS as Substreams Module
    participant Map as map_erc20_fee_proxy_payments
    participant Parser as Event Parser
    participant Store as store_payments
    participant SG as Subgraph (mappings.ts)
    
    TB->>SS: Block Stream (sf.tron.type.v1.Block)
    SS->>Map: Process Block
    
    loop For each transaction
        Map->>Map: Extract transaction logs
        
        loop For each log entry
            Map->>Map: Check contract address<br/>(MAINNET or NILE proxy)
            
            alt Contract address matches
                Map->>Parser: parse_transfer_with_reference_and_fee()
                Parser->>Parser: Extract payment reference from topics[1]
                Parser->>Parser: Parse ABI-encoded data:<br/>- token_address<br/>- to<br/>- amount<br/>- fee_amount<br/>- fee_address
                Parser->>Parser: Extract sender from transaction
                Parser->>Parser: base58_encode() addresses
                Parser-->>Map: Payment object
                Map->>Map: Add to payments collection
            end
        end
    end
    
    Map-->>Store: Payments (proto:request.tron.v1.Payments)
    Store->>Store: Index by payment reference
    Store-->>SG: Payment events
    SG->>SG: Transform to GraphQL entities
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from 7928566 to 5ac332a Compare January 27, 2026 01:49
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from 5ac332a to 984a642 Compare January 27, 2026 01:53
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch 2 times, most recently from 41e33e8 to d03f1db Compare January 27, 2026 01:58
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-substreams branch 2 times, most recently from cc6dc3b to 5775865 Compare January 27, 2026 02:02
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch 2 times, most recently from 7d73139 to 6dce563 Compare January 27, 2026 02:15
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from 6dce563 to dbed330 Compare January 27, 2026 02:25
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-substreams branch 2 times, most recently from 0d5df81 to 55ba0a1 Compare January 27, 2026 02:34
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch 2 times, most recently from 1797a69 to d5e25df Compare January 27, 2026 02:39
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from d5e25df to b5ce760 Compare January 27, 2026 02:45
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch 2 times, most recently from c5a8b72 to 96fe3e0 Compare January 27, 2026 09:10
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-substreams branch 2 times, most recently from 6e8e3f4 to d55f2f5 Compare January 27, 2026 09:16
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from 96fe3e0 to 5c45f73 Compare January 27, 2026 09:16
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from 19beedb to f8bb525 Compare January 27, 2026 09:29
- Add substreams configuration for Tron payment indexing
- Add protobuf definitions and schema
- Add Rust implementation for payment extraction
- Fix truncated TRANSFER_WITH_REF_AND_FEE_TOPIC (was 40 chars, now 64 chars)
- Add validation to check topics[0] matches expected event signature
- Prevents parsing non-TransferWithReferenceAndFee events
- Add hexAddress to deployment files (mainnet.json and nile.json)
- Move tron/nile chain definitions from declarative to tron folder
- Update DeclarativeChainName type to remove tron/nile
- Use erc20FeeProxyArtifact.getDeploymentInformation() instead of hardcoded values
- Rename tron-fee-proxy.ts to trc20-fee-proxy.ts for clarity
- Make fee limit configurable in utils-tron.ts with defaults
- Remove hardcoded MAINNET_PROXY_ADDRESS and NILE_PROXY_ADDRESS constants
- Add parse_proxy_addresses function to read addresses from params
- Update substreams.yaml to pass params to the map module

This allows the proxy addresses to be configured without recompiling.
Proto package directory mismatch:
- Move payments.proto to proto/request/tron/v1/ to match package declaration
- Update build.rs and substreams.yaml with new path

Transaction success validation:
- Add TronTransactionInfo interface
- Add getTransactionInfo method to TronWeb interface
- Add waitForTransactionConfirmation helper function
- Add optional waitForConfirmation parameter to approveTrc20 and processTronFeeProxyPayment
- Add missing bs58 dependency to Cargo.toml
- Fix subgraph.yaml to use correct substreams/graph-entities pattern
- Remove store_payments module (no handler implemented)
- Add dedicated build-substreams-tron job with Rust 1.75 image
- Install wasm32-unknown-unknown target for WebAssembly compilation
- Add cargo caching for faster builds
- Run tests as part of the CI job
- Update package.json to skip lerna build (requires Rust toolchain)
… crate

The substreams-tron crate doesn't exist on crates.io. Instead, we now
include pre-generated protobuf types from the StreamingFast tron-foundational
module. This includes:
- sf.tron.type.v1 types (Block, Transaction, etc.)
- protocol types (TransactionInfo, Log, Contract, etc.)
- request.tron.v1 types (Payment, Payments)

Also fixed type references in lib.rs to use the correct Transaction
structure instead of the non-existent TransactionTrace.
The home crate v0.5.12 requires Rust edition 2024 which was
stabilized in Rust 1.85.
substreams v0.5.22 uses prost v0.11.9, so we need to use the same
version to avoid trait incompatibility errors.
- Add engines, bugs, and homepage fields
- Add period at end of description
- Reorder properties with description after private
The substreams-tron tests require Rust/cargo which is only available
in the dedicated build-substreams-tron CI job, not the general
Node.js test environment.
The test was importing from 'tron-fee-proxy' but the source file
is named 'trc20-fee-proxy.ts'.
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-processor branch from f8bb525 to ceec59f Compare January 28, 2026 14:50
- Remove packages/substreams-tron (moved to payments-substream/tron)
- Remove build-substreams-tron job from CircleCI config
- Update graphql.config.yml to use local schema
- Substreams now maintained in separate repo for cleaner separation
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.

Now that the Tron substreams code has moved to the payments-substream repo (PR #2), what's the plan for packages/substreams-tron in this PR? Should it be removed, or is there a reason to keep both?

The Sepolia subgraph no longer exists on The Graph Studio, causing
GraphQL code generation to fail during builds.
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