Skip to content

Remove rpc_config in favor of rpc#940

Open
DZakh wants to merge 4 commits intomainfrom
claude/simplify-rpc-config-j8mVQ
Open

Remove rpc_config in favor of rpc#940
DZakh wants to merge 4 commits intomainfrom
claude/simplify-rpc-config-j8mVQ

Conversation

@DZakh
Copy link
Member

@DZakh DZakh commented Feb 6, 2026

Summary

This PR consolidates the RPC configuration structure by removing the deprecated rpc_config field and merging its functionality into the rpc field. The for field is now optional with intelligent defaults based on HyperSync availability.

Key Changes

  • Removed rpc_config field: The separate rpc_config structure that supported multiple URLs has been deprecated in favor of the unified rpc field
  • Flattened RPC structure: RPC configuration options (initial_block_interval, backoff_multiplicative, etc.) are now directly on the Rpc struct instead of nested under sync_config
  • Made for field optional: The source_for field now defaults to:
    • "fallback" when HyperSync is available for the chain
    • "sync" otherwise
  • Updated schema: JSON schema now reflects the new structure with rpc as the primary field and for as optional
  • Updated test configs: All test configuration files migrated from rpc_config to rpc format
  • Simplified RPC resolution logic: The DataSource::from_evm_network_config method now handles the new structure with automatic default resolution for the for field

Implementation Details

  • The Rpc struct now contains all sync configuration fields directly (no nested sync_config)
  • RPC selection can be a single URL string, a single Rpc object, or a list of Rpc objects
  • Default for value is resolved during config parsing based on HyperSync availability
  • Validation logic updated to check for RPC sync sources using the new structure
  • Code generation templates simplified to access RPC fields directly without nested access

https://claude.ai/code/session_015MisMioiSxUHJDazfN1FfR

Summary by CodeRabbit

  • Refactor
    • Simplified RPC configuration structure by consolidating multiple configuration types into a single rpc field.
    • Renamed rpc_config to rpc throughout configuration files and internal structures.
    • Made RPC route designation optional in configuration schemas.
    • Updated configuration validation and resolution logic to align with new RPC structure.

- Remove `RpcConfig` struct and `rpc_config` field from `Chain` in human config
- Make `source_for` field optional in `Rpc` struct; when omitted, it defaults
  to "fallback" if HyperSync is available for the chain, or "sync" otherwise
- Simplify `from_evm_network_config` to only handle `RpcSelection` variants
- Update `has_rpc_sync_src` detection to account for optional `for` derivation
- Regenerate evm.schema.json from updated Rust types
- Migrate all test configs from rpc_config to rpc format
- Update snapshot tests and file hash expectations

https://claude.ai/code/session_015MisMioiSxUHJDazfN1FfR
Test configs that used rpc_config (always sync) now need explicit
`for: sync` since the `for` field defaults to "fallback" on chains
with HyperSync (e.g. chain 1). Only the config2.yaml snapshot changes:
the fallback URL is now a separate Rpc object without sync config
fields (defaults applied in Config.res).

https://claude.ai/code/session_015MisMioiSxUHJDazfN1FfR
…ions

- codegen_templates.rs: None case for source_for should be unreachable
  after resolution, not silently default to fallback
- config2.yaml: restore original behavior where both URLs in a list
  share the same for: sync and sync config
- test_codegen/config.yaml: add explicit for: sync
- Restore all snapshots to match original expectations

https://claude.ai/code/session_015MisMioiSxUHJDazfN1FfR
The sync config fields (initial_block_interval, backoff_multiplicative,
etc.) were already flattened into Rpc via serde(flatten). This removes
the intermediate RpcSyncConfig struct and places the fields directly
on Rpc, simplifying field access throughout the codebase.

https://claude.ai/code/session_015MisMioiSxUHJDazfN1FfR
@DZakh DZakh requested a review from JonoPrest February 6, 2026 11:49
@DZakh DZakh changed the title Consolidate RPC configuration into single rpc field Remove rpc_config in favor of rpc Feb 6, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

The PR refactors the RPC configuration model by consolidating RpcConfig structures into a streamlined Rpc struct and For enum, making the "for" field optional. Chain configurations replace rpc_config with rpc throughout Rust code and test YAML files, simplifying RPC source selection semantics.

Changes

Cohort / File(s) Summary
Schema Definition
codegenerator/cli/npm/envio/evm.schema.json
Removed RpcConfig schema definition and rpc_config property from Chain. Made "for" field optional in Rpc and RpcSelection via anyOf with null. Adjusted required fields from ["url","for"] to ["url"].
Config Structure Initialization
codegenerator/cli/src/cli_args/init_config.rs, codegenerator/cli/src/config_parsing/graph_migration/mod.rs
Removed rpc_config: None field initialization from Chain struct construction in evm module and graph migration logic.
Config Type Definitions
codegenerator/cli/src/config_parsing/human_config.rs
Introduced new public For enum (Sync, Fallback, Live) and Rpc struct with url and optional fields (source_for, initial_block_interval, backoff_multiplicative, etc.). Removed old RpcConfig, RpcSyncConfig, and previous For definitions. Updated Chain struct to remove rpc_config field.
Config System Logic
codegenerator/cli/src/config_parsing/system_config.rs
Updated RPC field references from rpc_config to rpc. Introduced has_rpc_sync_src logic dependent on hypersync_config and default resolution. Added resolve_for helper and validation to error when both hypersync and rpc sources defined for historical sync. Updated rpc_for_sync comparison to check rpc.source_for against Some(For::Sync).
Code Generation
codegenerator/cli/src/hbs_templating/codegen_templates.rs
Updated ESP mapping to match rpc.source_for with Option-wrapped forms: Some(For::Sync), Some(For::Fallback), Some(For::Live), and unreachable None arm. Changed config field propagation to access rpc fields directly instead of nested sync_config.
Test Expectations
codegenerator/cli/src/persisted_state/hash_string.rs
Updated two precomputed hash values to reflect changes in serialized config structures.
Test Configuration Files
codegenerator/cli/test/configs/config-with-all-options.yaml, codegenerator/cli/test/configs/config1.yaml, codegenerator/cli/test/configs/config2.yaml, codegenerator/cli/test/configs/invalid-multiple-sync-config.yaml, codegenerator/cli/test/configs/nested-abi.yaml, codegenerator/cli/test/configs/per-address-start-block-invalid.yaml, codegenerator/cli/test/configs/per-address-start-block-valid.yaml, scenarios/test_codegen/config.yaml
Renamed rpc_config to rpc across all test YAML configs. Added for: sync field under rpc blocks. Updated nested field paths to reflect new rpc structure (e.g., url moved under rpc.url in config2.yaml).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • JonoPrest

Poem

🐰 wiggles nose happily
Config hops simpler, optional "for",
RpcConfig rests forevermore,
One path forward, clean and bright,
Refactored fields align just right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing the deprecated rpc_config field and consolidating RPC configuration into a single rpc field, which aligns with all files modified in this changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/simplify-rpc-config-j8mVQ

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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@codegenerator/cli/test/configs/config2.yaml`:
- Around line 25-41: The second RPC entry's inline comment ("Fallback RPC URL")
contradicts its setting `for: sync`; either update the comment to reflect that
this RPC is used for "sync" or change the `for` value to `fallback` if it truly
should be a fallback; locate the second mapping under the `rpc:` list (the entry
with url: https://eth.com/fallback) and make the corresponding change so the
comment and the `for:` field are consistent.
🧹 Nitpick comments (2)
codegenerator/cli/src/hbs_templating/codegen_templates.rs (1)

1461-1475: unreachable! on None arm is a valid invariant, but consider a safer alternative.

The None arm on Line 1465 panics at runtime if source_for was somehow not resolved. While the resolution in DataSource::from_evm_network_config guarantees Some(...) for all RPCs that reach this path, a defensive anyhow::bail! or error return would be safer against future refactors that might introduce a new path bypassing resolution.

That said, since the InternalRpcConfig.source_for is &'static str (non-optional), there's no sensible fallback value, so unreachable! is a reasonable choice here given the current design.

codegenerator/cli/src/config_parsing/system_config.rs (1)

563-577: Duplicated "default for" resolution logic — consider extracting a shared helper.

The defaulting logic (None → sync when no hypersync, fallback otherwise) is implemented twice:

  1. Here in has_rpc_sync_src (lines 566-570), using is_sync closure
  2. In from_evm_network_config (lines 1026-1033), using default_for + resolve_for

If these diverge in the future, the detection and resolution would disagree, causing subtle bugs (e.g., field selection validation could permit/reject fields incorrectly). Consider extracting the "default for" derivation into a shared helper.

♻️ Sketch of shared helper
// Shared helper at module level or on a relevant type
fn default_rpc_for(chain_id: u64, hypersync_config: &Option<HypersyncConfig>) -> For {
    let has_hypersync = hypersync_config.is_some()
        || hypersync_endpoints::get_default_hypersync_endpoint(chain_id).is_ok();
    if has_hypersync { For::Fallback } else { For::Sync }
}

Then both call sites can use this single source of truth.

Comment on lines +25 to +41
rpc:
- url: https://eth.com # RPC URL that will be used to subscribe to blockchain data on this network
for: sync
initial_block_interval: 10000
backoff_multiplicative: 0.8
acceleration_additive: 2000
interval_ceiling: 10000
backoff_millis: 5000
query_timeout_millis: 20000
- url: https://eth.com/fallback # Fallback RPC URL
for: sync
initial_block_interval: 10000
backoff_multiplicative: 0.8
acceleration_additive: 2000
interval_ceiling: 10000
backoff_millis: 5000
query_timeout_millis: 20000
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stale comment contradicts for: sync on the second RPC entry.

Line 34's comment says "Fallback RPC URL" but for is set to sync on Line 35. This is misleading after the migration. Consider updating the comment to reflect the actual role, or if this entry is genuinely intended as a fallback, change for to fallback.

-      - url: https://eth.com/fallback # Fallback RPC URL
-        for: sync
+      - url: https://eth.com/fallback # Secondary sync RPC URL
+        for: sync
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rpc:
- url: https://eth.com # RPC URL that will be used to subscribe to blockchain data on this network
for: sync
initial_block_interval: 10000
backoff_multiplicative: 0.8
acceleration_additive: 2000
interval_ceiling: 10000
backoff_millis: 5000
query_timeout_millis: 20000
- url: https://eth.com/fallback # Fallback RPC URL
for: sync
initial_block_interval: 10000
backoff_multiplicative: 0.8
acceleration_additive: 2000
interval_ceiling: 10000
backoff_millis: 5000
query_timeout_millis: 20000
rpc:
- url: https://eth.com # RPC URL that will be used to subscribe to blockchain data on this network
for: sync
initial_block_interval: 10000
backoff_multiplicative: 0.8
acceleration_additive: 2000
interval_ceiling: 10000
backoff_millis: 5000
query_timeout_millis: 20000
- url: https://eth.com/fallback # Secondary sync RPC URL
for: sync
initial_block_interval: 10000
backoff_multiplicative: 0.8
acceleration_additive: 2000
interval_ceiling: 10000
backoff_millis: 5000
query_timeout_millis: 20000
🤖 Prompt for AI Agents
In `@codegenerator/cli/test/configs/config2.yaml` around lines 25 - 41, The second
RPC entry's inline comment ("Fallback RPC URL") contradicts its setting `for:
sync`; either update the comment to reflect that this RPC is used for "sync" or
change the `for` value to `fallback` if it truly should be a fallback; locate
the second mapping under the `rpc:` list (the entry with url:
https://eth.com/fallback) and make the corresponding change so the comment and
the `for:` field are consistent.

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.

2 participants