-
Notifications
You must be signed in to change notification settings - Fork 117
refactor(l2): use Url instead of String in EthClient #5060
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the EthClient to use Url type instead of String for RPC URLs, improving type safety and making the API more explicit about expecting valid URLs.
Key Changes:
- Updated
EthClient::new()and related constructors to acceptUrlinstead of&str/String - Removed internal URL parsing logic from
EthClient::new_with_config()since URLs are now pre-validated - Updated all call sites across the codebase to parse URLs before passing to
EthClient
Reviewed Changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/networking/rpc/clients/eth/mod.rs | Modified EthClient constructors to accept Url type and removed internal URL parsing |
| crates/l2/sequencer/configs.rs | Changed EthConfig.rpc_url field type from Vec<String> to Vec<Url> |
| cmd/ethrex/l2/options.rs | Updated EthOptions.rpc_url to Vec<Url> and modified default initialization |
| cmd/ethrex/l2/deployer.rs | Changed DeployerOptions.rpc_url to Url type |
| cmd/ethrex/l2/initializers.rs | Added URL parsing when creating L2 RPC URL from address and port |
| crates/l2/sequencer/*.rs | Updated multiple sequencer components to work with Url type |
| crates/l2/tests/*.rs | Added URL parsing for test client initialization |
| tooling//src/.rs | Updated tooling code to parse URLs before creating EthClient |
| */Cargo.toml | Added url workspace dependency where needed |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Url::parse(&format!("http://{}:{}", opts.http_addr, opts.http_port)) | ||
| .expect("Error parsing RPC URL") |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message 'Error parsing RPC URL' should include the actual URL that failed to parse for easier debugging. Consider using unwrap_or_else to include the formatted URL in the panic message.
| Url::parse(&format!("http://{}:{}", opts.http_addr, opts.http_port)) | |
| .expect("Error parsing RPC URL") | |
| let url_str = format!("http://{}:{}", opts.http_addr, opts.http_port); | |
| Url::parse(&url_str).unwrap_or_else(|e| panic!("Error parsing RPC URL '{}': {}", url_str, e)) |
Lines of code reportTotal lines added: Detailed view |
Motivation
Urlis the correct type for theEthClientDescription
Replace all
Stringuses withUrlwhen used forEthClient