Skip to content

Add extensible compression support for RPC requests #6084

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fubhy
Copy link
Member

@fubhy fubhy commented Jul 22, 2025

Summary

Implements extensible compression support for Graph Node's outgoing JSON-RPC requests to upstream providers, addressing issue #5671. The implementation uses an enum-based design that makes it easy to add new compression methods in the future without breaking existing configurations.

Key Changes

  • Enum-based compression configuration: Replaced boolean compression_enabled field with Compression enum (None, Gzip)
  • Per-provider configuration: Each RPC provider can have independent compression settings
  • Future-extensible design: Clear pattern for adding Brotli, Deflate, and other compression methods
  • Backward compatible: Defaults to no compression, existing configs continue to work
  • Type-safe: Prevents invalid compression method strings in configuration

Configuration Format

Enable gzip compression:

[chains.mainnet]
provider = [
  { 
    label = "mainnet-rpc", 
    details = { 
      type = "web3", 
      url = "http://rpc.example.com", 
      features = ["archive"],
      compression = "gzip"
    }
  }
]

Disable compression (default):

compression = "none"  # or omit field entirely

Implementation Details

  • Configuration: Compression enum in node/src/config.rs with serde support
  • Transport layer: Updated Transport::new_rpc() to handle compression enum with match statement
  • Future ready: Commented placeholders show how to add new compression methods
  • Testing: Unit tests for both gzip and none compression parsing
  • Dependencies: Added gzip feature to reqwest dependency

Future Extensions

Adding new compression methods requires only:

  1. New enum variant: #[serde(rename = "brotli")] Brotli
  2. Match arm in transport: Compression::Brotli => client_builder.brotli(true)
  3. Corresponding reqwest feature in Cargo.toml

Test plan

  • Unit tests pass for compression configuration parsing
  • Configuration examples validate correctly
  • Transport layer handles enum variants properly
  • Manual testing with real RPC providers that support gzip
  • Performance testing to verify compression benefits
  • Integration tests with actual compressed RPC traffic

🤖 Generated with Claude Code

@fubhy fubhy force-pushed the feature/extensible-rpc-compression branch 3 times, most recently from a2eba9c to 4917aef Compare July 22, 2025 18:02
@fubhy fubhy force-pushed the feature/extensible-rpc-compression branch 2 times, most recently from eaf6470 to 4fb2574 Compare July 22, 2025 19:39
- Replace boolean compression_enabled with Compression enum (None, Gzip)
- Support per-provider compression configuration via "compression" field
- Add placeholders for future compression methods (Brotli, Deflate)
- Update transport layer to handle compression enum with match statement
- Add comprehensive unit tests for compression configuration parsing
- Update example configuration and documentation

Configuration examples:
  compression = "gzip"   # Enable gzip compression
  compression = "none"   # Disable compression (default)

Addresses issue #5671 with future-extensible design.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fubhy fubhy force-pushed the feature/extensible-rpc-compression branch from 4fb2574 to b8939aa Compare July 22, 2025 19:40
@leoyvens leoyvens removed their request for review July 22, 2025 20:22
@DaMandal0rian DaMandal0rian removed their request for review July 23, 2025 12:06
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.

1 participant