Skip to content

chore: constrain ticket quality in mpool - #7361

Merged
LesnyRumcajs merged 1 commit into
mainfrom
constrain-probability-mpool
Jul 15, 2026
Merged

chore: constrain ticket quality in mpool#7361
LesnyRumcajs merged 1 commit into
mainfrom
constrain-probability-mpool

Conversation

@LesnyRumcajs

@LesnyRumcajs LesnyRumcajs commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • constrain ticket quality in mpool to avoid some weird outputs

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

  • Bug Fixes

    • Improved handling of invalid or extreme ticket quality values by safely constraining them to valid ranges.
    • Prevented potential failures when processing undefined or infinite numeric values.
    • Made message selection and probability calculations more reliable in edge cases.
  • Tests

    • Added coverage for extreme, undefined, and infinite inputs to verify stable behavior.

@LesnyRumcajs
LesnyRumcajs requested a review from a team as a code owner July 15, 2026 12:15
@LesnyRumcajs
LesnyRumcajs requested review from akaladarshi and hanabi1224 and removed request for a team July 15, 2026 12:15
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Message pool ticket-quality inputs are sanitized before probability and message-selection decisions. Approximate floating-point comparison now handles NaN safely. Tests cover extreme, out-of-range, and non-finite values.

Changes

Message pool numeric safety

Layer / File(s) Summary
Probability input sanitization
src/message_pool/block_prob.rs
block_probabilities clamps finite ticket-quality values to [0.0, 1.0], defaults non-finite values to 0.0, and tests finite results across invalid inputs.
Selection input sanitization
src/message_pool/msgpool/selection.rs
select_messages sanitizes ticket quality before selecting the greedy or optimal path, with asynchronous coverage for invalid values.
NaN-safe chain comparison
src/message_pool/msg_chain.rs
approx_cmp uses total_cmp for non-equal values and tests NaN and infinity combinations without panicking.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: hanabi1224

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main change: constraining ticket quality values in the message pool.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 constrain-probability-mpool
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch constrain-probability-mpool

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

@LesnyRumcajs
LesnyRumcajs enabled auto-merge July 15, 2026 12:17

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/message_pool/msg_chain.rs (1)

609-614: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard the tolerance check for non-finite operands.
approx_cmp(f64::INFINITY, 1.0) returns Equal here because the epsilon check runs before total_cmp, so ±∞ can compare equal to finite values and break antisymmetry in chain ordering. Require both operands to be finite before applying the tolerance check, and extend the regression test to assert the ordering for (+∞, 1.0), (1.0, +∞), and (+∞, -∞).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/message_pool/msg_chain.rs` around lines 609 - 614, Update approx_cmp so
the epsilon-based equality check runs only when both operands are finite;
otherwise use total_cmp to preserve correct ordering for infinities. Extend the
regression test to assert ordering for (+∞, 1.0), (1.0, +∞), and (+∞, -∞).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/message_pool/msg_chain.rs`:
- Around line 609-614: Update approx_cmp so the epsilon-based equality check
runs only when both operands are finite; otherwise use total_cmp to preserve
correct ordering for infinities. Extend the regression test to assert ordering
for (+∞, 1.0), (1.0, +∞), and (+∞, -∞).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e2e0c1e7-b1b0-44c6-ae45-518e7cc6fccc

📥 Commits

Reviewing files that changed from the base of the PR and between b436194 and 9d506a0.

📒 Files selected for processing (3)
  • src/message_pool/block_prob.rs
  • src/message_pool/msg_chain.rs
  • src/message_pool/msgpool/selection.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 64.82%. Comparing base (09a872e) to head (9d506a0).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/message_pool/msgpool/selection.rs 97.43% 0 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/message_pool/block_prob.rs 97.16% <100.00%> (+9.52%) ⬆️
src/message_pool/msg_chain.rs 86.43% <100.00%> (+0.34%) ⬆️
src/message_pool/msgpool/selection.rs 87.36% <97.43%> (+0.37%) ⬆️

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b436194...9d506a0. 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.

@LesnyRumcajs
LesnyRumcajs added this pull request to the merge queue Jul 15, 2026
Merged via the queue into main with commit 0ccf75d Jul 15, 2026
34 checks passed
@LesnyRumcajs
LesnyRumcajs deleted the constrain-probability-mpool branch July 15, 2026 12:57
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.

3 participants