fix(mpool): run_head_change in select message to only simulate the head change#7182
Conversation
Walkthrough
ChangesMpoolSelect live-pool isolation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 17 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/message_pool/msgpool/selection.rs (1)
1095-1097: ⚡ Quick winAssert the simulated selection result too.
This test verifies no live-pool side effects, but it would still pass if the scratch
rmsgssimulation failed to remove the message already included ints2. Capture the return value and assert it does not includepending_msg.Suggested assertion
- let _ = mpool.select_messages(&ts2, 1.0).unwrap(); + let selected = mpool.select_messages(&ts2, 1.0).unwrap(); + assert!( + !selected.iter().any(|msg| msg.cid() == pending_msg.cid()), + "selection for the target tipset must not return a message already applied there" + );🤖 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/msgpool/selection.rs` around lines 1095 - 1097, The test currently discards the return value from the mpool.select_messages(&ts2, 1.0).unwrap() call by using let _. To ensure the simulated selection is working correctly, capture the returned value in a variable instead of discarding it, then add an assertion to verify that the returned selection does not include the pending_msg that was already included in the ts2 tipset. This ensures the test catches cases where the scratch rmsgs simulation fails to properly exclude messages.
🤖 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.
Inline comments:
In `@src/message_pool/msgpool/utils.rs`:
- Around line 75-76: The issue is that rmsgs may be keyed by resolved sender
addresses from the pending snapshot while the from parameter could be an ID
address, causing get_mut(from) to fail to locate the correct message set.
Instead of directly calling rmsgs.get_mut(from), you need to look up the message
set using the actual stored sender address key. Determine the resolved sender
address that corresponds to the message being removed and use that to access the
correct set in rmsgs before calling set.remove(&sequence), ensuring messages are
properly removed regardless of whether from is an ID address or resolved
address.
---
Nitpick comments:
In `@src/message_pool/msgpool/selection.rs`:
- Around line 1095-1097: The test currently discards the return value from the
mpool.select_messages(&ts2, 1.0).unwrap() call by using let _. To ensure the
simulated selection is working correctly, capture the returned value in a
variable instead of discarding it, then add an assertion to verify that the
returned selection does not include the pending_msg that was already included in
the ts2 tipset. This ensures the test catches cases where the scratch rmsgs
simulation fails to properly exclude messages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b99dbbb2-7e17-4dd9-abf6-0b3a05fd0ca2
📒 Files selected for processing (3)
CHANGELOG.mdsrc/message_pool/msgpool/selection.rssrc/message_pool/msgpool/utils.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
filecoin-project/lotus(manual)
Summary of changes
Changes introduced in this pull request:
run_head_changenow only simulates the head change instead of removing the pending messages from the pending storeReference issue to close (if applicable)
Closes #6975
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
Release Notes
Filecoin.MpoolSelectto no longer remove messages from the live message pool when performing selection simulations. The operation now safely simulates head changes without mutating the actual pool state.