Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
fubhy wants to merge 4 commits into master
base: master
Choose a base branch
Loading
from feature/extensible-rpc-compression

Conversation

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 3 times, most recently 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
fubhy and others added 2 commits August 26, 2025 13:00
- 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 8dc6615 to acb0979 Compare August 26, 2025 11:01
- Add missing Compression parameter to all Transport::new_rpc test calls
- Import Compression type in config tests module
- Ensures all tests compile and pass with the new compression parameter
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
@fubhy fubhy requested review from lutter and fordN August 26, 2025 11:14
When reqwest gzip feature is enabled globally, Client::default() enables
automatic gzip compression which removes content-length headers from responses.
ArweaveClient needs content-length to check file sizes, so explicitly disable
gzip for Arweave requests.
Fixes test: polling_monitor::ipfs_service::test::arweave_get
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Member Author

fubhy commented Aug 26, 2025

@lutter This is also building now ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@isum isum Awaiting requested review from isum

@lutter lutter Awaiting requested review from lutter

@fordN fordN Awaiting requested review from fordN

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /