Skip to content

fix: use i64 instead of u64 in limit exceed error to avoid conversion#6872

Merged
akaladarshi merged 1 commit intomainfrom
akaladarshi/fix-limit-exceeded-err
Apr 8, 2026
Merged

fix: use i64 instead of u64 in limit exceed error to avoid conversion#6872
akaladarshi merged 1 commit intomainfrom
akaladarshi/fix-limit-exceeded-err

Conversation

@akaladarshi
Copy link
Copy Markdown
Collaborator

@akaladarshi akaladarshi commented Apr 8, 2026

Summary of changes

Changes introduced in this pull request:

  • uses i64 instead of u64 to avoid casting

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Refactor
    • Improved internal type consistency in error handling for block range validation.

@akaladarshi akaladarshi requested a review from a team as a code owner April 8, 2026 07:52
@akaladarshi akaladarshi requested review from hanabi1224 and sudo-shashank and removed request for a team April 8, 2026 07:52
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

Walkthrough

This pull request changes the block range limit error handling in Ethereum RPC methods from unsigned 64-bit (u64) to signed 64-bit (i64) integers. The EthErrors::BlockRangeExceeded variant and its associated limit_exceeded constructor are updated accordingly, with call sites adjusted to pass native types directly.

Changes

Cohort / File(s) Summary
Error Definition and Type Signature Update
src/rpc/methods/eth/errors.rs
Changed EthErrors::BlockRangeExceeded fields from u64 to i64 for max and given, and updated limit_exceeded() method signature to accept i64 parameters instead of u64.
Error Handler Call Sites
src/rpc/methods/eth.rs, src/rpc/methods/eth/filter/mod.rs
Removed explicit as u64 casts from limit_exceeded() invocations, now passing ChainEpoch-typed values and deltas directly without type conversion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

RPC

Suggested reviewers

  • sudo-shashank
  • hanabi1224
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 accurately describes the main change: replacing u64 with i64 in the limit exceeded error to avoid type conversions across the codebase.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch akaladarshi/fix-limit-exceeded-err
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch akaladarshi/fix-limit-exceeded-err

Comment @coderabbitai help to get the list of available commands and usage tips.

@akaladarshi akaladarshi enabled auto-merge April 8, 2026 07:53
Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
src/rpc/methods/eth/errors.rs (1)

46-50: Add a doc comment to limit_exceeded.

This helper is now the single entry point for the signed range error, so a short note about the expected units/semantics would make future call sites clearer. As per coding guidelines "Document public functions and structs with doc comments".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rpc/methods/eth/errors.rs` around lines 46 - 50, Add a doc comment to the
public helper function limit_exceeded describing its purpose and the
semantics/units of its parameters and returned error: state that
limit_exceeded(max_block_range: i64, given: i64) constructs a BlockRangeExceeded
error where both parameters are signed i64 representing a block-range size
(number of blocks in the requested range, not absolute block numbers), clarify
whether the range is inclusive/exclusive if relevant, and note that the message
uses these counts; attach the comment directly above the limit_exceeded function
so callers of limit_exceeded and users of the BlockRangeExceeded variant
understand the expected units and behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/rpc/methods/eth/errors.rs`:
- Around line 46-50: Add a doc comment to the public helper function
limit_exceeded describing its purpose and the semantics/units of its parameters
and returned error: state that limit_exceeded(max_block_range: i64, given: i64)
constructs a BlockRangeExceeded error where both parameters are signed i64
representing a block-range size (number of blocks in the requested range, not
absolute block numbers), clarify whether the range is inclusive/exclusive if
relevant, and note that the message uses these counts; attach the comment
directly above the limit_exceeded function so callers of limit_exceeded and
users of the BlockRangeExceeded variant understand the expected units and
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2f3674a8-15a3-4cec-9472-42154771823b

📥 Commits

Reviewing files that changed from the base of the PR and between 4cfb27b and 28c608a.

📒 Files selected for processing (3)
  • src/rpc/methods/eth.rs
  • src/rpc/methods/eth/errors.rs
  • src/rpc/methods/eth/filter/mod.rs

@akaladarshi akaladarshi added this pull request to the merge queue Apr 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.02%. Comparing base (19d1045) to head (28c608a).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/rpc/methods/eth.rs 0.00% 1 Missing ⚠️
src/rpc/methods/eth/filter/mod.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/eth/errors.rs 69.38% <100.00%> (ø)
src/rpc/methods/eth.rs 65.46% <0.00%> (ø)
src/rpc/methods/eth/filter/mod.rs 88.33% <66.66%> (ø)

... and 21 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cfb27b...28c608a. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into main with commit 513ae4f Apr 8, 2026
48 of 49 checks passed
@akaladarshi akaladarshi deleted the akaladarshi/fix-limit-exceeded-err branch April 8, 2026 10:18
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