feat: Add new --requests-per-second parameter to replace misleading --traffic-per-second#3857
Merged
Merged
Conversation
…-traffic-per-second The --traffic-per-second parameter name was misleading and caused confusion. It actually represents the interval in seconds to replenish one quota element, not "requests per second" as the name suggests. Changes: - Add new --requests-per-second parameter with intuitive semantics - Add deprecation warning for --traffic-per-second parameter - Implement conversion logic between the two parameters - Add comprehensive unit tests - Update existing tests to use the new parameter - Prevent usage of both parameters simultaneously Examples: - --requests-per-second 10.0 # Allows 10 requests per second - --requests-per-second 0.5 # Allows 0.5 requests per second Fixes #3823 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new --requests-per-second parameter to replace the misleading --traffic-per-second parameter, which actually represented the interval between quota replenishments rather than the rate itself. The change improves usability by providing an intuitive parameter name that matches user expectations (higher value = more requests), while maintaining backward compatibility through deprecation warnings.
Key Changes:
- Added new
--requests-per-secondparameter with intuitive rate-based semantics - Deprecated existing
--traffic-per-secondparameter with warning messages - Implemented conversion logic between rate and interval representations with validation
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
crates/rooch-config/src/lib.rs |
Added new parameter field, deprecation warning for old parameter, conversion method get_traffic_rate_limit_interval(), and comprehensive unit tests |
crates/rooch-rpc-server/src/lib.rs |
Updated server initialization to use new conversion method with default value fallback for both local and non-local networks |
crates/testsuite/tests/integration.rs |
Migrated from deprecated traffic_per_second to new requests_per_second parameter (0.001 → 1000.0 conversion) |
- Remove line continuation in eprintln! message for better formatting - Remove line continuation in anyhow::bail! message for better formatting - Follow Rust standard formatting conventions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Changes made based on PR review feedback: 1. **Enhanced Input Validation**: - Add validation for NaN and infinite values in both parameters - Ensure all inputs are finite positive numbers - Prevent unexpected behavior from edge cases 2. **Improved Error Handling**: - RPC server now properly propagates validation errors - No longer silently ignores invalid parameter values - Users receive clear error messages for misconfigurations 3. **Expanded Test Coverage**: - Add tests for negative values - Add tests for NaN, infinity, and negative infinity - Comprehensive edge case validation testing This ensures the traffic rate limiting is robust and fails fast when invalid configurations are provided. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed clippy::field_reassign_with_default warnings by using struct
initialization syntax instead of creating Default::default() instances
and then reassigning fields.
Changes made:
- Replace 'let mut opt = RoochOpt::default(); opt.field = Some(value)'
- With 'let opt = RoochOpt { field: Some(value), ..Default::default() }'
- Applied to all test functions in the test suite
This resolves all clippy warnings related to field reassignment
and follows Rust best practices for struct initialization.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixed test failure by reordering validation logic: 1. Check for NaN/infinite values first (is_nan() || is_infinite()) 2. Then check for positive values (> 0) This ensures special float values (NaN, infinity, negative infinity) are properly caught and return the correct error message "must be a valid finite number" instead of falling through to the positive value check. The test was failing because NEG_INFINITY <= 0.0 returns true, causing the wrong error message to be returned. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
--traffic-per-secondparameter name was misleading and caused confusion. It actually represents the interval in seconds to replenish one quota element, not "requests per second" as the name suggests.For example:
0.010.1100This was counterintuitive because:
Changes Made
--requests-per-secondparameter with intuitive semantics--traffic-per-secondparameterUsage Examples
Test Plan
Migration Guide
--traffic-per-second <interval>with--requests-per-second <rps>--traffic-per-second 0.1→--requests-per-second 10.0--traffic-per-second 0.01→--requests-per-second 100.0Impact
Fixes #3823
🤖 Generated with Claude Code