๐Ÿ”Œ Tronsell Wiki

RPC Infrastructure

Comprehensive guide to TRON's Remote Procedure Call (RPC) infrastructure. Learn about HTTP JSON-RPC, gRPC, load balancing, high availability, security, and scaling strategies for production RPC endpoints.

๐Ÿ”Œ RPC at a Glance
HTTP RPC Port 8090
gRPC Port 50051
Protocols HTTP + gRPC
Load Balancing Round Robin / Least Conn
HA Strategy Active-Active
Security TLS + Rate Limiting

๐Ÿ”Œ RPC Infrastructure Overview

TRON's RPC (Remote Procedure Call) infrastructure is the gateway for applications, developers, and users to interact with the blockchain. It provides a standardized interface for querying blockchain data, submitting transactions, and interacting with smart contracts.

The RPC layer sits on top of the full node and exposes two primary interfaces:

  • HTTP JSON-RPC โ€” REST-like endpoints on port 8090 for simple, language-agnostic access.
  • gRPC โ€” High-performance, strongly-typed RPC on port 50051 using Protocol Buffers.
๐Ÿ“Œ RPC Importance

RPC infrastructure is critical for dApps, exchanges, wallets, and analytics platforms. It must be reliable, scalable, and secure to handle production workloads.

๐Ÿงฉ RPC Infrastructure Components

๐ŸŒ
HTTP JSON-RPC

Port 8090. Simple REST endpoints for wallet, contract, and block operations. Easy to integrate with any programming language.

โšก
gRPC

Port 50051. High-performance RPC with Protocol Buffers. Supports streaming and bidirectional communication.

๐Ÿ”„
Load Balancer

Distributes RPC traffic across multiple nodes. Supports round-robin, least connections, and health checking.

๐Ÿ”’
API Gateway

Provides authentication, rate limiting, request logging, and TLS termination for RPC endpoints.

๐ŸŒ HTTP JSON-RPC Endpoints

The HTTP JSON-RPC API is the most accessible way to interact with a TRON node. All endpoints accept POST requests with a JSON body.

Common HTTP Endpoints

Endpoint Method Description
/wallet/getnowblock POST Get the current block header
/wallet/getaccount POST Get account balance and resources
/wallet/createtransaction POST Create a transfer transaction
/wallet/broadcasttransaction POST Broadcast a signed transaction
/wallet/triggersmartcontract POST Execute a smart contract method
/contract/deploycontract POST Deploy a smart contract
# Example HTTP RPC request curl -X POST http://localhost:8090/wallet/getnowblock \ -H "Content-Type: application/json" -d '{}'
๐Ÿ’ก HTTP vs gRPC

HTTP JSON-RPC is easier to use for quick prototyping and debugging. For production applications with high throughput, gRPC is recommended for its performance and type safety.

โšก gRPC Infrastructure

gRPC is a modern RPC framework developed by Google. TRON uses gRPC for its high-performance API, offering significant advantages over HTTP JSON-RPC.

gRPC Features

  • Protocol Buffers โ€” Binary serialization for smaller payloads and faster parsing.
  • Streaming โ€” Support for server-streaming, client-streaming, and bidirectional streaming.
  • Type Safety โ€” Strongly-typed interfaces generated from .proto files.
  • Multiplexing โ€” Multiple calls over a single connection.
# Example gRPC call using grpcurl grpcurl -plaintext localhost:50051 protocol.Wallet/GetNowBlock

gRPC Services

  • Wallet โ€” Account, transaction, and block operations.
  • Contract โ€” Smart contract deployment and execution.
  • Network โ€” Node status, peer information.
  • Database โ€” Historical data queries.
โšก gRPC Performance

gRPC can handle 10x-100x more requests per second than HTTP JSON-RPC for the same hardware, making it the preferred choice for production RPC infrastructure.

โš–๏ธ Load Balancing & High Availability

For production RPC infrastructure, a single node is a single point of failure. Load balancing distributes traffic across multiple nodes, ensuring reliability and scalability.

Load Balancing Strategies

Strategy Description Pros Cons
Round Robin Distributes requests evenly across nodes Simple, fair distribution Does not account for node load
Least Connections Sends requests to the node with fewest active connections Better load distribution under varying loads Requires connection tracking
Health Check Routes only to healthy nodes Prevents routing to dead or lagging nodes Adds monitoring overhead
Geo-aware Routes to nodes closest to the client Reduces latency Requires geo-location data

Load Balancer Tools

  • Nginx โ€” HTTP/gRPC load balancing with health checks.
  • HAProxy โ€” High-performance TCP and HTTP load balancing.
  • Envoy โ€” Modern edge proxy with advanced traffic management.
  • Cloud Load Balancers โ€” AWS NLB, GCP Cloud Load Balancing.
# Example Nginx configuration for gRPC load balancing upstream tron_grpc { server node1:50051; server node2:50051; server node3:50051; } server { listen 50051 http2; location / { grpc_pass grpc://tron_grpc; } }
๐Ÿ“Œ HA Architecture

For high availability, deploy at least 3โ€“5 full nodes behind a load balancer. This provides redundancy and allows you to perform maintenance without downtime.

๐Ÿ”’ RPC Security

RPC endpoints are a primary attack vector. Securing them is critical for production deployments.

๐Ÿ”
TLS/SSL

Encrypt all RPC traffic with TLS. Use valid certificates from a trusted CA. gRPC requires HTTP/2 over TLS.

๐Ÿšฆ
Rate Limiting

Limit requests per IP or API key to prevent abuse and DDoS attacks. Implement at the gateway level.

๐Ÿ”‘
Authentication

Use API keys or JWT tokens for authenticated endpoints. Restrict access to trusted applications.

๐Ÿ›ก๏ธ
IP Whitelisting

Restrict RPC access to specific IP ranges or VPNs for internal services.

# Example Nginx rate limiting limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s; server { location /wallet/ { limit_req zone=api burst=20; proxy_pass http://tron_node:8090; } }
๐Ÿ”’ Security Checklist

โœ… Enable TLS for all RPC traffic
โœ… Implement rate limiting
โœ… Use API keys for authentication
โœ… Restrict IP ranges where possible
โœ… Enable access logging and monitoring
โœ… Regularly update TLS certificates

๐Ÿ“ˆ Scaling RPC Infrastructure

As demand grows, your RPC infrastructure must scale. Here are strategies for scaling:

  • Horizontal Scaling โ€” Add more full nodes behind the load balancer.
  • Read Replicas โ€” Use dedicated nodes for read-only queries to reduce load on write-capable nodes.
  • Caching โ€” Cache frequently accessed data (e.g., account balances) at the API gateway.
  • Connection Pooling โ€” Reuse gRPC connections to reduce overhead.
  • Geo-distribution โ€” Deploy nodes in multiple regions to reduce latency for global users.
๐Ÿ“Š Monitoring

Monitor RPC latency, error rates, and request volume. Use tools like Prometheus, Grafana, or Datadog to visualize metrics and set up alerts.

โ“ Frequently Asked Questions

What ports does TRON use for RPC?

TRON uses 8090 for HTTP JSON-RPC and 50051 for gRPC. These are configurable in config.conf.

What is the difference between HTTP RPC and gRPC?

HTTP RPC uses JSON over REST โ€” simple and human-readable. gRPC uses Protocol Buffers for binary serialization โ€” significantly faster, strongly typed, and supports streaming.

How do I load balance gRPC traffic?

gRPC traffic can be load balanced using L7 (application-level) load balancers that support gRPC, such as Envoy, Nginx (with grpc_pass), or HAProxy. Client-side load balancing is also possible.

Should I expose RPC ports publicly?

Only if you are providing a public RPC service. In all cases, implement TLS, rate limiting, and authentication. For internal services, use IP whitelisting or VPNs.

How many nodes do I need for production RPC?

For high availability, deploy at least 3 nodes behind a load balancer. This allows you to handle traffic spikes and perform rolling upgrades without downtime.

โšก Build on TRON's RPC Infrastructure

Running RPC endpoints or building dApps? Pair your infrastructure with Tronsell Energy to power your transactions at the lowest cost.