Skip to content

feat: Add new --requests-per-second parameter to replace misleading --traffic-per-second#3857

Merged
jolestar merged 5 commits into
mainfrom
wegent-fix-misleading-traffic-per-second-param
Dec 10, 2025
Merged

feat: Add new --requests-per-second parameter to replace misleading --traffic-per-second#3857
jolestar merged 5 commits into
mainfrom
wegent-fix-misleading-traffic-per-second-param

Conversation

@jolestar

@jolestar jolestar commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Summary

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.

For example:

Value Actual Meaning Requests/Second
0.01 Replenish 1 quota every 0.01s 100
0.1 Replenish 1 quota every 0.1s 10
100 Replenish 1 quota every 100s 0.01 ❌

This was counterintuitive because:

  • A higher value results in fewer requests per second
  • The name suggested it should be "traffic allowed per second"

Changes Made

  • 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 to verify correct behavior
  • Update existing tests to use the new parameter
  • Prevent usage of both parameters simultaneously with clear error message

Usage Examples

# New parameter - intuitive and clear
rooch server start --requests-per-second 10.0  # Allows 10 requests per second
rooch server start --requests-per-second 0.5   # Allows 0.5 requests per second

# Old parameter - now shows deprecation warning
rooch server start --traffic-per-second 0.1
# WARNING: --traffic-per-second is deprecated. Use --requests-per-second instead. 
# Current value 0.1 means 10 requests per second.

Test Plan

  • Unit tests verify correct conversion between parameters
  • Unit tests verify error handling for invalid combinations
  • Integration tests updated to use new parameter
  • Manual testing confirms deprecation warnings appear
  • Error handling prevents conflicting parameter usage

Migration Guide

  1. Replace --traffic-per-second <interval> with --requests-per-second <rps>
  2. Convert values: New RPS = 1.0 / old_interval
    • --traffic-per-second 0.1--requests-per-second 10.0
    • --traffic-per-second 0.01--requests-per-second 100.0

Impact

  • Backward compatible: Old parameter still works with deprecation warning
  • Reduces confusion: New parameter name matches its behavior
  • Prevents misconfiguration: Clear error when both parameters are used
  • Well tested: Comprehensive test coverage added

Fixes #3823

🤖 Generated with Claude Code

…-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>
Copilot AI review requested due to automatic review settings December 9, 2025 23:13
@vercel

vercel Bot commented Dec 9, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview Comment Dec 10, 2025 4:07am
test-portal Ready Ready Preview Comment Dec 10, 2025 4:07am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
rooch Ignored Ignored Preview Dec 10, 2025 4:07am

@github-actions

github-actions Bot commented Dec 9, 2025

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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-second parameter with intuitive rate-based semantics
  • Deprecated existing --traffic-per-second parameter 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)

Comment thread crates/rooch-config/src/lib.rs
Comment thread crates/rooch-config/src/lib.rs
Comment thread crates/rooch-config/src/lib.rs
Comment thread crates/rooch-rpc-server/src/lib.rs
Comment thread crates/rooch-rpc-server/src/lib.rs
- 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>
@jolestar jolestar merged commit 8cb470d into main Dec 10, 2025
17 checks passed
@jolestar jolestar deleted the wegent-fix-misleading-traffic-per-second-param branch December 10, 2025 07:54
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.

Issue: Misleading parameter name: --traffic-per-second should be renamed for clarity

2 participants