refactor: msg pool to make more structured#6965
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughReplaces the per-address in-memory pending HashMap with a crate-scoped Changes
Sequence Diagram(s)sequenceDiagram
participant Client as "MessagePool API"
participant Store as "PendingStore"
participant MsgSet as "MsgSet (per-sender)"
participant Sub as "Subscriber (broadcast::Receiver)"
Client->>Store: insert(resolved_from, msg, sequence, trust, strictness)
Store->>MsgSet: get_or_create(resolved_from)
MsgSet-->>Store: add(msg, strictness, trust, limits) -> Result
alt insert succeeded
Store->>Store: persist into map
Store->>Sub: broadcast MpoolUpdate::Add(msg)
else insert failed
Store-->>Client: return Error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/message_pool/msgpool/msg_pool.rs`:
- Around line 449-453: The public method subscribe_to_updates currently returns
broadcast::Receiver<MpoolUpdate> but MpoolUpdate is crate-private (declared
pub(in crate::message_pool) in events.rs), so callers outside
crate::message_pool cannot name the type; either re-export MpoolUpdate from a
public module (add a pub use crate::message_pool::msgpool::events::MpoolUpdate
in a public mod) so the type is publicly reachable, or reduce
subscribe_to_updates() visibility to match MpoolUpdate (make
subscribe_to_updates pub(crate) or pub(in crate::message_pool)) so the declared
signature and type visibility align; update the signature or re-export
accordingly and adjust any callers.
In `@src/message_pool/msgpool/msg_set.rs`:
- Around line 183-188: The applied=true branch in msg_set.rs only sets
self.next_sequence = sequence + 1 which can leave already-buffered higher nonces
unaccounted for; change the branch to advance next_sequence past any buffered
successors the same way the unknown-message branch does: set next_sequence =
sequence + 1 and then loop while self.msgs.contains_key(&self.next_sequence) (or
the equivalent buffered map/set used in this struct) incrementing next_sequence
until no buffered message exists, so callers are not told they can reuse a
still-pending nonce.
In `@src/message_pool/msgpool/selection.rs`:
- Around line 853-857: The simulated path run_head_change() is mutating the live
PendingStore because MpoolCtx is constructed with the real pending_store; change
the helper to be side-effect free by giving MpoolCtx a simulation-only context
or snapshot: either construct MpoolCtx with a read-only/snapshot PendingStore
clone or introduce a SimulationPendingStore (or a flag on MpoolCtx) that makes
remove_from_selected_msgs() operate only on the local rmsgs/result map rather
than calling pending_store.remove(...). Update the MpoolCtx construction in
run_head_change() and ensure MpoolCtx::remove_from_selected_msgs() checks the
simulation mode or uses the snapshot store so select_messages() against
non-current tipsets cannot delete entries from the live mempool.
🪄 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: 3914d600-4744-47e8-8b77-311223afc188
📒 Files selected for processing (6)
src/message_pool/msgpool/events.rssrc/message_pool/msgpool/mod.rssrc/message_pool/msgpool/msg_pool.rssrc/message_pool/msgpool/msg_set.rssrc/message_pool/msgpool/pending_store.rssrc/message_pool/msgpool/selection.rs
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Let's ease up on the comments; ideally documentation should explain things high-level, and not repeat the implementation.
|
@akaladarshi Anything with 🐰 comments to address? If not, mark them as resolved. |
c515b49 to
48cdcbe
Compare
48cdcbe to
0d66af3
Compare
Summary of changes
Changes introduced in this pull request:
pending_storethat holds all the pending related data for the mempoolmsetrelated changes into it's own file to reduce the bloat onmsgpoolReference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
New Features
Improvements
Tests